Forums > Max For Live

observer selected_track

Jul 09 2011 | 2:59 pm


Im wondering if anyone knows a way to display the currently selected track? I realise I can do this through this_device. However, the device im using wont always be on the same track as is selected.

Im also struggling to understand how to listen for when the track is selected. Im guessing I should use loadbang?



Jul 09 2011 | 4:16 pm

The seledcted_track is a property of the song.view as are selected_scene, highlighted_clip_slot, and seelcted_parameter. This code lets you observe selecting tracks on the fly. Please click the button to start this in an existing patcher.

This works within a Live Max device or a sub patcher of it. It seems it doesn’t work in a patcher started from the MFL menu: File -> New patcher.

-- Pasted Max Patch, click to expand. --

Jul 09 2011 | 6:51 pm

Hey Xanadu,

thx for the snippet. It seems to display the selected track. However, it only selects for every 3rd track i click on. I can see its using deferlow, which should sort this problem out. I cant see how I can make it always display the selected track – would be grateful if you have any ideas?



Jul 09 2011 | 7:50 pm


I just tried the snippet and it seemed to work fine for me even clicking frantically…?

Here’s what I did. I went into Live and created an empty m4l patch, then opened it to edit in Max, selected all, deleted it… then I copied the above snippet, did "New From Clipboard" from the menu, then copied all of _that_ and pasted it into the empty m4l patch and saved it… then I went back to Live and selected various tracks and saw the results in Max.

What I want is to set the selected_track, which I have so far failed to do… :-( and rather need now, any hints welcome!

Jul 10 2011 | 10:33 am

This MFL device listens to changes of the selected path. The sub patcher also has a menu control to select a track yourself. It had to be a subpatcher else it would only be visible when the path it is on is selected. This device does not work for return tracks and the master track.

Jul 10 2011 | 11:45 am

This is a little update on the device.

Jul 10 2011 | 12:35 pm

This third version works for the return_tracks and the master_track too.

Jul 10 2011 | 4:58 pm

Came back to clear up my previous post!

Of course, within Max it’s pretty easy to set the selected track by calling M4L.api.SetSelectedTrackIndex (although looking at how hard it is to do by directly using live.object and live.path is pretty daunting)… my issue is that I can’t do this in Javascript! I think I need to post this on the JS forum though.

Xanadu: thanks for these great examples! If you’re going to post code in the longer term, I strongly suggest you get a free github account and put the examples there – the advantage is that you can link to the source code and fix errors there instead of having to come back to the thread and update it again, but also that people can read and share your code.

I did this:

Jul 11 2011 | 5:08 pm

Hello tom,

For javascript you can use the LiveAPI object, which is documented at . As it references the same interface in Live I suppose you can perform the same tasks as with live.xx objects in MFL.

I’ve published some devices om, but I consider these code snippets just as proof-of-concept and didn’t bother to make it an official publucation.



Viewing 9 posts - 1 through 9 (of 9 total)

Forums > Max For Live