monitoring when a clip is inserted on/removed from any of a track's clipslots

discopatrick's icon

I'm trying to work out how to achieve the above.

The ultimate goal is this: I want to create a device that will reflect the state of it's clipslots (e.g. clip or no clip) without requiring a manual refresh from the user.

The M4L.Chooser patch (in the patches/m4l-patches/LiveAPI resources/tools folder of the Max app) does not quite achieve this - it requires a manual refresh by clicking the 'list' button.

Previously I managed to create a device that monitors the path it currently occupies, listening out for a change of id (in other words, listening for when this device has moved away from that path) and then notifies when that happens, triggering a refresh. This works pretty well, you can find it here: https://cycling74.com/forums/detecting-when-a-m4l-device-has-been-moved-from-one-track-to-another

So I'm thinking I might apply this method to the clipslots. Because there are several clipslots to monitor, and the number of them is subject to change, I plan to do this in dynamically in javascript rather than using a patcher window. This would involve setting up a LiveAPI js object for every single clipslot on the current track, using mode 0 (following the path) and then using the callback when any of their ids changed, triggering a refresh so that my device immediately reflects the new state.

It all sounds doable in theory... but it does seem a bit clunky, and I'm wondering whether there might be some other really simple way to do this that I just can't see.

Hopefully someone will be able to offer me some advice on this - thanks.