How to know if a Device has been deleted in a Live Set
Giovanni Soggiu
9月 11 2023 | 5:11 午前
Hi everyone!
I've got a question which may sound stupid, and i know that something similar has been asked in this forum beforex, but that solution does not work for me.
My question is: what's the easiest way to know if a device in a Live Set has been deleted?
I need something that works like a live.observer.
Thank you!
(PS: i mean in a Live Set, not in a specific track!)
Marc Assenmacher
9月 11 2023 | 7:12 午前
You can target any device over its path in the live set. Once you have the device you can get its ID and use a live.observer on the ID.
I assume that you get an error when you live.observe the ID and the device gets deleted. Maybe try to use that?
EDIT: You will get an id 0 when the device is deleted.
Giovanni Soggiu
9月 11 2023 | 7:25 午前
Thank you for answering Marc!
No errors actually, i'm just trying to figure out what's the best way to reset my plugin everytime i delete a mapped device. And since my plugin can map others parameters all over the Live Set it's all more difficult to keep everything under control.
It's just i need something like [live.path live.set] - [property devices] - [live.observer] but it can't work so easily.
Marc Assenmacher
9月 11 2023 | 1:28 午後
I think you got me wrong here. Here is a working test patch.
Off course you need to gather the ids of all devices that you mapped parameters to, but I think you got these ids anyways. In my example I use the device 1 on the currently selected track. I am basically using the live.observer on the device id. As soon as you delete the device the live.observer returns an "id 0". You can covert that into a bang and use it to trigger anything you like.
Source Audio
9月 11 2023 | 1:29 午後
even a non live user can think of a solution:
observe all tracks in set, get all devices and count or list them.
if something changes, than reset your plugin.
tyler mazaika
9月 11 2023 | 6:58 午後
@SOURCE Frankly brute forcing this is not a good solution at all. Maybe because you're not a live user you don't know that in any given track the device hierarchy can have nested device chains and basically arbitrary complexity. Couple that with the fact that any Track's (or DeviceRack's) list of device ids notifies for changes for Deletes, AND Adds, AND re-ordering, would mean you'd need to filter out tons of notifications and maintain a backing store of the relevant id information from a "last known state" to make decisions. Plus, use can move a device from one Track into another, which would appear as a 'delete' in one track and an 'add' in another. Just... no.
Marc's solution is the right approach. I'm pretty sure the "MapButton" patch that is used throughout the stock M4L devices (e.g. LFO, Envelope) does something similar to that.
Giovanni Soggiu
9月 12 2023 | 2:53 午前
Tyler your idea made it, thank you! Watching in the LFO mapping has been the right way, and the result is surprisingly way easier than i thought.
I'll thank Marc too, because of the effort made for me and the good idea, but it was still more complex than i needed.
Are you ready?
Ok guys, watch out!