Send bang on track change - "Setting the Id cannot be triggered by notifications. you will need to defer your response"

Learn about building and using Max for Live devices.
Post Reply
agent314
Posts: 1458
Joined: Wed Apr 07, 2010 3:07 am

Send bang on track change - "Setting the Id cannot be triggered by notifications. you will need to defer your response"

Post by agent314 » Mon Jun 06, 2022 5:26 am

I have created a device that allows a MIDI-mappable dial to be used to trigger clips on its respective track.

It gets the current track number, counts the number of clips in that track, then uses that value to set the number of clips to trigger, interpolating/scaling the MIDI input value to match the number of clips.

The problem I am running into is that whenever I add a new track or move the track containing the device, the track number changes and I have to manually retrigger the find-the-track-number code path with a button.

This feels like it should be trivial to implement using [live.observer] with [live.path live_set tracks] to send a bang to the code path that sets the track number to the current track (rather than do it manually with a button), but I am running into the "you will need to defer your response" issue and cannot seem to get live.observer working, no matter how many [deferlow] objects I add to my path.

Is there no way to send a single bang message when adding/changing tracks, or is there a non-obvious way to accomplish this that I simply haven't found?

agent314
Posts: 1458
Joined: Wed Apr 07, 2010 3:07 am

Re: Send bang on track change - "Setting the Id cannot be triggered by notifications. you will need to defer your respon

Post by agent314 » Mon Jun 06, 2022 5:32 am

As soon as I posted this I had the idea, "why not just trigger the code path to choose the track every time the dial changes?"

I updated that to send the bang, and it appears to be working as expected, but it feels wasteful to recalculate that value every time I move the dial.

Is that something I shouldn't worry about since the performance cost is relatively trivial, or is it worthwhile to try to find a solution using an event notification whenever the tracks update, to save on performance?

chapelier fou
Posts: 6025
Joined: Mon May 15, 2006 12:15 pm

Re: Send bang on track change - "Setting the Id cannot be triggered by notifications. you will need to defer your respon

Post by chapelier fou » Mon Jun 06, 2022 12:54 pm

If you don't mind sharing the patch, I'd be happy to take a look and see if I can help.

Cheers.
MacBook Pro 13" Retina i7 2.8 GHz OS 10.13, L10.0.1, M4L.
MacStudio M1Max 32Go OS 12.3.1

Post Reply