A realtime detection of comming midi notes

zion's icon

Hi
I saw many options in the LOM page to manipulate midi notes in a midi clip but couldn't see the exact code to get in realtime playing the comming midi notes with thier velocity and duration, can someone help ?
Thanks

Andy Maskell's icon

Do you not have access to the standard Max MIDI objects, like MIDIIn, NoteIn, etc., in Max for Live?

zion's icon

It took me a second to understand your surprise.. I didn't mention that what I realy need is the duration of comming notes while clip is playbacking, and at the same moment that they are triggered from a clip (I need to scale duration into another feature on my device).
Max Midi objects do not share duration of recorded midi notes(why??)
So how can I get durations of notes that are comming from a midi clip on a midi track while playback?
Thanks again!

broc's icon

I think it can only be done with some workaround.
For example, convert the clip notes into [coll] with entry format
<start_time, pitch, velocity, duration>
Then play the coll notes where the durations are known.

Andy Maskell's icon

Live MIDI only sends note on's and note off's with the note durations controlled by the sequencer (or performer) playing them. A raw MIDI file will store notes with the elapsed time for each note on and note off event but not a note duration. MIDI message protocol has no implementation for a note duration either so Max can't work this out directly. You can only do this by calculating the interval between corresponding note on and note off MIDI messages. As suggested, you could use a coll object to store the MIDI stream with the note durations calculated by some code. Be aware that a note off can also be sent using a note on with a velocity of zero!