How to know if a Device has been deleted in a Live Set

    Max For Livebeginneradvanced

    Giovanni Soggiu
    Sep 11 2023 | 5:11 am
    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 Thank you!
    (PS: i mean in a Live Set, not in a specific track!)

    • Marc Assenmacher's icon
      Marc Assenmacher
      Sep 11 2023 | 7:12 am
      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 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's icon
      Giovanni Soggiu's icon
      Giovanni Soggiu
      Sep 11 2023 | 7:25 am
      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] - [] but it can't work so easily.
    • Marc Assenmacher's icon
      Marc Assenmacher's icon
      Marc Assenmacher
      Sep 11 2023 | 1:28 pm
      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 on the device id. As soon as you delete the device the returns an "id 0". You can covert that into a bang and use it to trigger anything you like.
      amxd 27.57 KB
    • Source Audio's icon
      Source Audio's icon
      Source Audio
      Sep 11 2023 | 1:29 pm
      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's icon
      tyler mazaika's icon
      tyler mazaika
      Sep 11 2023 | 6:58 pm
      @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's icon
      Giovanni Soggiu's icon
      Giovanni Soggiu
      Sep 12 2023 | 2:53 am
      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!
      maxpat 2.99 KB