detecting when a M4L device has been moved from one track to another

    Apr 16 2012 | 5:12 pm
    I recently learned how a device can obtain the number of the track on which it is located, using [live.path this_device]
    Here's the patcher example I originally found on the first reply on this forum post:
    The problem with this patcher is that it does not update itself when you move the device from one track to another. It seems that while the [loadbang] object does bang when you first drop the device onto a track, it does not bang when the device has been moved to another track (it's not being 'loaded' in that sense) so the old track number is still shown.
    I've tried setting up a object to monitor the device path for changes, but it seems that 'path' is not a property that can be observed in that way.
    I can think of two options, neither of which seem very nice:
    * replace the loadbang with a metro object that bangs once per second, so the track number will be regularly updated * set up an observer that monitors the number of devices on each track, and when any track loses/gains a device, send out a bang to start the process of getting the new track number
    I'm hoping someone will be able to tell me a cleaner way :)

    • Apr 17 2012 | 12:35 am
      I figured it out! I must say I am feeling rather awesome right now... this is what late night Max sessions are all about!
      I found the answer by thinking about the problem in a different way. Don't watch this_device, looking for when the path changes. Instead, watch the path, and look for when the device on it changes. A subtle difference... but it works.
      I've attached the patcher here - it's fully commented up so anyone who is interested should be able to work out what's going on. Please try it and let me know whether it works for you.
    • Apr 09 2016 | 5:03 pm
    • Nov 12 2021 | 6:53 am
      Thank you!
    • Nov 12 2021 | 7:24 am
      Glad this still gets used occasionally :)
    • Nov 12 2021 | 6:14 pm
      This is actually pretty vital for parameter mapping with M4L without your patch I probably would have been behind by a week on updates so big ups for the help! I made an abstraction of sorts for a robust MAP button for M4L which now features this patch so i'll be giving you a little shoutout on my channel for the help.
    • Nov 13 2021 | 4:53 pm
      Cheers Jack! Post me a link when you do ๐Ÿ™‚
    • Nov 13 2021 | 5:23 pm itโ€™s up now! hopefully this helps funnel more people who need the help to this post