Coding with M4L : let's help each other

Hi everyone !
This thread is an attempt to gather all questions, issues, etc regarding coding with M4L, aka Max for Live.

(Personally I’m maybe not the best expert in the world but I’ve been using since day 1 so I’m happy to help if I can !)

22 Likes

Is there a way I can learn it all overnight in my sleep without any effort? :smiley:

4 Likes

Have you tried sleeping with your computer on your face?
I can’t verify this at the moment, but in theory it should work.

5 Likes

Ok, serious thread attempt officially failed.

2 Likes

Maybe post what you’re working on, to encourage the others…

I’m planning on giving M4L a good go in the coming weeks so serious posts are imminent!

1 Like

Hi, actually this is quite some good timing for this thread since I am currently fighting with m4l a bit. I am not too happy with the way push is sequencing automation curves so I started writing a device that should bring elektron style trig locks to push (or at least improve sequencing of automation curves with push). This should not be a sequencer by itself but more a layer on top of push’s own step sequencer. I have implemented the user facing functionality mostly in javascript and the performance relevant part with max for live nodes.
This device uses grab_control to take over the button-matrix and other buttons.
As of now I expose a button to grab_control and I listen to changes of the “appointed_device” to release control.
I think this is not ideal and I would prefer to grab control whenever the user click himself “into” the device. Not sure what the official name for that is but I mean the gui-page where push shows '< DeviceName". I already figured out that this is not possible out-of-the-box so I tried thinking outside the box.
Unfortunately I am lacking experience to properly do this.
The most promissing idea that I had was:
Check the light pattern of the upper and lower display buttons.
If the upper display buttons have this pattern: 1 0 0 0 0 0 0 1
and the lower display buttons have this pattern 1 0 0 0 0 0 0 0
and the appointed_device is this device
and the selected device is this device
then I know that the user is in the device.

I was not able to find a way to do this (getting the light status of a button). I am able to grab_control the button and then set the brightness but I am not able to retrieve the current brightness of the button. Also the button-press events do not provide this info. I am now looking if I can get this info by using grab_midi but this also does not seem to be possible easily since this is just showing the midi heartbeat and midi that is going from push to live (not the other way around).
After reading this push-interface/doc/AbletonPush2MIDIDisplayInterface.asc at main · Ableton/push-interface · GitHub
I started hoping that I may be able to decipher the sysex midi response of the midi commands (using grab_midi) but I am not too sure if this is worth the effort or even a good idea since I would need to continously watch and analyze the midi heartbeat which may slow down the system too much.

Another idea I had which I will maybe try is to see if there is a way to figure out if the display shows the buttons that I have assigned to a bank or not. If the device is just selected these buttons are not shown, if the user clicked into the device these buttons are shown. … so, maybe there is a visible flag somewhere.

I also tried lots of other stupid ideas but I am slowly getting to the conclusion that this is defenitely not possible (currently).
So, the question: What do you think:
Is this not possible?
Could this be possible with one of the mentioned approaches?
or, do you have an even better idea?

Another question you may know, where I already have given up: Can you confirm that it is not possible to create automation/envelopes via LOM like I can create notes in a clip. This is for baking the locks to an automation curve when the user decides that the jam sounds nice.
As of now I am deciding if I have to commit the lock value based on the clip-local ticks. Much better would be if my device could write the automation curve directly into the current clip and only if I want to bake a complicated curve (maybe because I am modulating the locks with an lfo) use this time based method which is a bit awkward since I would need to create another track, pipe my midi into it and copy the curves back into the current one (if this is even possible). Baking is not yet implemented though … just something for the future.

2 Likes

Regarding the first issue :
If I get it right, you’re looking for a good way to know when to take control of the button matrix and when to release it, right ?
You wish to grab it when you’re controlling the device with Push and release it when not, right ? I’m not sure what’s wrong with the appointed_device and what you mean by “click himself into the device”. I’m not super familiar with Push although I own one.

Regarding the second question, I can confirm it’s not possible to draw automation with the Max API.

2 Likes

I’ve heard tell about a Max4Live course for beginners that’s available as a suppository.

4 Likes

Count me in

1 Like

If I get it right, you’re looking for a good way to know when to take control of the button matrix and when to release it, right ?

Yes, this is correct for the button matrix and all other controls that I grab. What I mean with click into the device":
When selecting the device in live, then push typically shows the default parameter bank without buttons. In my case this is 8 dials. If I want to see all parameters or change the bank, then I have to click the button above the device name and now push will allow me to select any bank I want to make changes to and also shows the buttons I have assigned in live.banks. Also push will show the device name in the upper left corner with a < beforehand.
I mean this ui-level with “in the device”.

Currently to grab control the user has to go into the device and then push the button. which is already one click more than needed which felt wrong to me when trying it out while jamming. I also dont want to grab by default when appointed since this device can also be used just as a midi 8 cc device where no grabbing is needed. To me it feels more natural to grab, when going into the ui-level where everything that the device can do is shown anyways (buttons and bank pages) than doing one additional indirection (press the button). Also it felt confusing to me that with the current method the way to release the controls (change device selection) is different than the way I grab control (button press).

1 Like

does live_set view selected_parameter change ?
That might do the trick.
If needed I can try with my Push tomorrow.

No, unfortunately not. “live_set view selected_parameter” triggers when the user selects a parameter from a device with the mouse within live. Just with push I haven’t been able to let it trigger. But many thanks for thinking about it. Having a confirmation that this is not something obvious I have overlooked helps a lot in stopping wasting time and tackle the next issue.

2 Likes

I’ll try to take a look when I have time !
And what about a “manual” grab, like a button on the Push to grab the matrix ?
If I understand well, the matrix is used for some of the functions of your device, and that’s why you don’t want to be automatically grabbed with appointed_device, right ?
Or you could observe the state of the button that “enters” the mode that needs to grab the matrix ?
Sorry it’s still a bit abstract !

2 Likes

Many Thanks, I appreciate it.

And what about a “manual” grab, like a button on the Push to grab the matrix ?

If I understand you correctly then I thought about it. You mean a 2 step process?
for example grab_control the automate button when appointed and when clicking this button then grabbing the button-matrix, right?
I decided against this since I would change default push behavior and this may confuse other people than me if I dont explain this somewhere.

If I see that this device does not explode when testing it on real projects with multiple tracks and longer than 1 bar clips, then I may open-source it and for this I would prefer if I dont need to write a manual :wink:

Yes, the button-matrix is used like the 32-step sequencer - just not for notes but for cc locks. All notes in the clip are lit up in a certain color and adding a parameter lock works by holding down a pad and changing the dial value at the same time.
And yes, grabbing the grid seems to be an operation with hickups thats why I prefer to only do it when needed. There may be something else I have to learn yet but I had several unexpected and hard to debug issuess with it. For example when coloring the pads (using send_value) right after grabbing the button-matrix then that worked while the max window is open but when just in live without running max at the same time it just would’nt want to show the colors. I assume this is because grab_control returns immediately but still does stuff under the hood and while trying to send a color value to a pad while this stuff is still ongoing the pad wouldn’t receive that color value. For a lack of a better solution I solved this for now by using a Task and schedule the task some ms later.

I’ve made a few devices where you press shift/select at the same time on push to grab/release the matrix. I liked it a little better than having to dive into the device to do it and those aren’t two buttons I’d normally press together so it doesn’t interfere with normal operation. If you add checks for if the device is selected and if push is in keyboard vs session layout it’s not too in the way of normal use and the matrix only gets grabbed if the device is in focus in keyboard layout and you either press or previously pressed shift/select. Maybe something like that would work for you?

2 Likes

Thanks, you are right, shift/select is actually a nice combo since I believe it is not normally used by push.
I’ll try it out and see how it feels. Still, I hope ableton will provide an event for “in the device” at some point since this would have been ideal for this device and now I am curious how they would name that state ;-).

I can’t check now but doesn’t live.banks provide outputs that could be useful ?

Hey @chapelierfou I’d love your advice. I’m making a simple patch using groove~ that at the moment just has variable speed playback controls. It’s designed specifically for the Stanton SCS3.d (a touch sensitive DJ midi controller from the late 00s). Basically I just want to be able to start playback (either in time with Ableton’s clock or not), then change the playback rate by scrubbing using the “jog wheel”. Playback can go into reverse, and there is also a ‘slew’ function that works the same as vinyl speed adjust on a CDJ (i.e. how long it takes to return to normal playback speed).

I’m still learning Max and haven’t really stepped into the MSP world, so I’m sure this will look like a mess. Here is my issue, and it’s not even really to do with the patch. I have my patch inside a M4L Instrument, so to send MIDI back to the controller for LED feedback I need to set up another MIDI track, set Monitor to In, select the instrument, and then send out to the controller. Ableton seems to strip Note Off information, which means I can turn LEDs on but not off…

I copied the entire contents of the patch into a new Max patch (not a M4L Instrument) and set the midiin/midiout to the controller and it works fine. So my question: is there a clean way to send MIDI from a M4L Instrument without Ableton stripping some of the messages? This thread seems to say no, but I’m interested to hear if you’ve come up against this before.

dascratch-sampler.amxd (60.4 KB)

Edit: the patch originally started as standalone Max anyway

As demonstrated in the attached patch, notes and CCs are sent just fine from a Max Instrument in Live.
There is just one major limitation : midi channel will be ignored as it can only be set by the track itself.
As a side note, beware when using sends and receives, it’s a good practice to always add “—” before their names, so it remains local to the patch.



MIDI_Tester.amxd (9.8 KB)

EDIT :
I guess it’s just a patching error from your side. In this section, there are many potential issues. For instance, sending the message "1 " to another message box will make this bow output “1” as well. If you want to trigger 0, you’d want to insert a bang between the two boxes.

2 Likes