How to color all Selected tracks with a Custom Color ?

ergo erdori's icon

Hello guys,

I'm building a patch that includes a live.text message. What I want is for all selected tracks in Ableton Live to be colored with a custom color (in this case, blue) when I trigger a button.

The patch works, but there's one small issue: it only colors one selected track. If I select multiple tracks and press the button (I use a keyboard shortcut), only one track gets colored blue, not all the selected tracks.

How can I modify this patch to color all selected tracks with the custom color? I've tried different approaches, but I couldn't find a solution, it always colors just one selected track.

Here’s the patch for reference:

Max Patch
Copy patch and select New From Clipboard in Max.

Here is an image as well

TFL's icon

Apparently, selected_track sadly only returns one track id, as stated in the LOM.

But what you could do is to iterate over all the tracks and check for their is_part_of_selection property, which returns true if the track is part of the selection.

While doing so, I would remove that [delay 50] because it could mess with the order of execution.

ergo erdori's icon

Thanks @TFL . just a quick question: I'm relatively new to Max , I understand the concept of iterating, I kindff don know how to implement the steps you described in M4L. could you provide some guidance or an example of how to iterate over all tracks and check their is_part_of_selection property?

Also, regarding the delay, I can remove it for now. It serves another purpose in my patch, but it's not critical to what I'm trying to achieve at the moment.

TFL's icon

Here is an example of iteration giving you a list of zeroes and ones representing all tracks selected state:

Here, all tracks are selected but not the first one.
Max Patch
Copy patch and select New From Clipboard in Max.

Then you need to add the few bits to change the color of a track if its is_part_of_selection property is 1.