detecting when a M4L device has been moved from one track to another
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: http://www.cycling74.com/forums/topic.php?id=33310
----------begin_max5_patcher---------- 647.3ocyVFsjZBCEF9Z7oHCWiNjfnXuoS6c8InWryNLQHUSKDbHAqs6ru6Mb B5xtJZDXb5EDkS.x+4K+4j7xDG20EGXRWzmPOgbbdYhiCDpNfSy8Nt4zCIYT I7XtB1uKV+SWOSWJ1AEDVhlNcpZKWFqJoI+5X++nPnDzbF7LeojSyPesHKsc 2R9egtw9yvMgEU4bQFSAiXqfEUpiQ8ahtipR1xEahKYIJSdP7il46gHgKp+Y IbCV2hdt4c3ofbzowTbnacrWmLotwyRFjTjmyDpyfv22RUHH+Qzbz2PEhO2O PbJ6JYR8.QU7BQ6LDC4DAZ8WbVBNP9Y.GInyueaY0dHZA1k8gqc3sTnMLkVn aQYVhSShp9yNlIkbc8zWmze+scjtw1xU.mlC3ZQ30bcqBGQ5TI1Ua3L7gumE KYMlPIhOHd0bw0N8Q.cyuE5H9yAnE5eU1EMhrKqfltlJ1zWLAu6HvF7UXCT+ ZIvjvEWkLq5EYpxWyJ6K.p8FdVxgNJlgIlJzvj+El6G1pxiaFXJlcgOuE0xv 9jwzyoWiNS2QsD66py6xxQtaKmoRVj+sqjg8CNpRIcOKM1jXwTkpjutRYNag yIB43FuiUJ4RESj.p1GhCn8dAbNSJoaXmQXnTHbVjT1ddB6+ZLuJ.ZM6nunK JOerMf0LZvaNLBU9BtoMjXV4hutM7c6nBOhNOEe7nsvnTG+8TSVTUlbL6Z1j wCEbZjRYREWbpDwSuUVvC8ld1xSSYh1GtJmmtqPWhrQEnmu3jnshp1Ezd75R UgOTUo20wFQM+9DUzxYgdnHn1sts4+CFfgVn0UOX9EZE+Bd7hBaknvOP+efM SeQO3EkDal+FhmReyqS9Gb8+kFA -----------end_max5_patcher-----------
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 live.observer 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 :)
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.
Forums > Max For Live