Stepping through a MIDI Clip with m4l

hthaw's icon

Hi all -

I've seen this topic broached elsewhere, but I still am not sure if this is possible or not..

I'd like to send a simple bang from Max to Ableton, to cycle through a MIDI clip, step-by-step. Is there any way to do this or something equivalent?

hthaw's icon

Preferably not reprogramming the MIDI with the live.step abstraction.

hthaw's icon

No one has tried to do this?

mooter's icon

Do you mean cycle through the notes like round robin? Because I'm just tidying up a device that's about to be released.

Wetterberg's icon

I just rolled up something that... kind of works, but I can't get the get_notes method to work. Like, at all. Mooter, is that your approach?

The way I'd do it is with select_all_notes, which has its usability downfalls.

mooter's icon

Yeah I used the get note, but within the boundaries of Live's clip loop.

Max Patch
Copy patch and select New From Clipboard in Max.

Here's a straight copy from my "extract" encapsulation:

First you want to have your midi clip selected since it uses [detail_clip] to get the notes.
Then the notes are placed by order of time into a dictionary, which you can then use a counter to fire off the keys to send the midi notes. That's pretty much it.

One handy thing (thanks to some assistance on here) is that notes that are close together under 1/16th note will be rounded off to be put in the same dictionary key. This is because if you have human input playing some chords, obviously the notes in the chord won't be recorded at the exact same time, which means they would be entered as single notes in the dictionary and the chord wouldn't be fired, it would fire each note independently.

I hope this is helpful!

hthaw's icon

Alright- GetSelectedNotes dumps MIDI to a Jitter Matrix, which then has to be reinterpreted to translate back to MIDI- I think that makes sense - I'm unfamiliar with M4L, so I'm a little unclear about how to get the MIDI Clip into the GetSelectedNotes API, though.

Wetterberg's icon

wow, thanks mooter, this was exactly what I was looking for!

How did you figure out the syntax for get_notes? It's very very different from what's in the LOM; there's no specification of get_notes "type" and then it's double int double int afterwards, it's weird. :?

In my little patch I've done without the jitter matrix, since they're basically dumping into a matrix and then going straight back out; instead I've opted to simply sort them with a coll, but then your little wonder comes along with that nice rounding there, I may stick with this. It looks really slick :)

mooter's icon

Thanks. The syntax was trial and error. Yes the LOM says to use double for all but really for pitch and velocity it's int. And yes jitter matrix can be overkill for some tasks and I stick to coll when I just need a temp cache. I initially used a coll to dump the notes but then I needed them to be saved with the live set so I replaced it with a dict:) Dict is going to be pretty essential for most of my stuff, I think, while coll is still useful as a temp cache. I really like that you push and pull between the 2.

I'll be releasing my advanced round robin device soon ("AdRoRob"?) to open up a lot of possibilities using that encapsulation so keep your eyes open!

Wetterberg's icon

Yeah, looking forward to seeing that! It really helped to crossreference the LOM with your patch... man, this documentation...

the possibilities for my group are pretty immense; this means I can make any clip available over the network. I've been pondering this for quite a while.

It also solves a problem of handling polyphonic midi recording and sequencing for me. Doing it in-clip is pretty cool; combining the sequencing madness of max with the easy-in,easy-out of Live is going to be fun.

odonjohn's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Hello, I m using this patch to see + active/deactivate, on a korg nano control 2, notes from a step sequencer patch I built.

How could I make it recieve infos from and control a midi clip instead of the stepsequencer ?
The answer must be here but I m really new to LOM and it's still chinese to me for the moment.
Got a live set in a month and would love to be able to control both, my step sequencer And already built midi clips

the korg patch is recieving a list of 0 & 1's
"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0" is 16 steps with no notes and Live isnt playing.

When playing, on every step move, the 0 changes to 1 then get back to 0, showing on the korg (led blink) the actual movement of the sequence.

A 16 steps sequence with notes is like this :
"1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0" (ex. kick drum)
when a 1 is triggered it changes to 0 for few ms and get back to 1.

So basically I need to start with getting a list of the notes present in the last midi clip launched, in a 16 steps "grid" way.

jrs1's icon

quick note about Mooter's patch.

He has a route hooked up to get the 'done' message, however you need to use a select. The done message is not a list, so you won't actually get a bang coming from that route. I just spent a lot of time working this out myself.

The done messages seem a bit confusing, I'm still getting 'strange' behaviour. In debug mode it seems like there is a done message after every note sent out of live.object, but when I run in none debug mode I only get one done message.

I'm working on a large number of notes (around 1000), I found that live.object is outputting the list too fast for a counter (to store in a coll) so I am batching the notes up into beat lengths of 100, which seems to work, just creates extra headache (loops, boundaries, messages, timing etc)

Max Patch
Copy patch and select New From Clipboard in Max.

jrs1's icon

another reply for this thread (for reference purposes)

in Mooter's patch the last value of the 'call get_notes' is 127, however after painful debugging and testing (total get_notes was not equal to a counter countnig each note), I have discovered that the pitch_span parameter counts from 1, so you need to specify 128 to ensure midi note 127 is actually captured by the 'get_notes' call. I tested this by creating a midi clip with all 128 notes, and then examined the output, it kept missing note 127, the 128th note - drove me crazy.

call get_notes $1 0 $2 128

get_notes

Parameter:
from_time [double/int]
from_pitch [int]
time_span [double/int]
pitch_span [int] - JRS1: First midi note is 1, not 0. So enter 128 for full range!
Returns a list of notes that start in the given area. The output is similar to get_selected_notes.

I hope this saves someone 30-60 mins of debugging!

Max Patch
Copy patch and select New From Clipboard in Max.

mooter's icon

Yikes, 2013. I'm not surprised there were some errors in there...I'd go the JS route these days. It's worth learning if you want to manipulate the LOM. A much more elegant and time-saving solution.

jrs1's icon

good to know JS is simpler. I'm spending a lot of time ordering messages and doing loops, not max's strong point. My JS is ok, so I'll investigate for a future project.

Mario Fernando Cardoso's icon

Hi!

How I use this in a max for live midi device? Or how do I initialize this?
I'm trying to use it in a M4l midi device and I'm getting this error message: live.object: call get_notes 0 0 0 128: no valid object set

Do I need to change some name, number or id?

Thanks!

Max Patch
Copy patch and select New From Clipboard in Max.

schlam's icon

Hello

I posted on maxforlive.com a device that seems to do what you are looking for.
Maybe it can help...

It takes all the notes of the selected midi clip and you can then "scrub" all the notes/chords of this clip..

https://maxforlive.com/library/device/7607/scan-clip-midi-clip-scrub-device