getting the color of a track in m4l api. is it possible ??????

miguelvb's icon

Hi,

i am trying to get the color of a track in ableton live, using the live api in m4l.
Can it be done? (no possibility found in the docs).
I know i can access the color of a clip, but of the track? should be simple....

thank you !

Jan M's icon

do you mean track or clip?

you can read and it from the clip:

Reference pages are friends not enemies ... ;)

xanadu's icon

I'm afraid you mean the clips of a track in arrangement view. We have no access to them.

Ben Bracken's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Although it is missing from the docs, track 'color' is a gettable/settable property. I'll try to make sure that it gets in the next update.

alersito's icon

Ben with this configuration only 2 colors for a track.

i think that get the color of a track is not useful

Ben Bracken's icon

Not sure what you mean. You can refer to the clip color property for how it works.

All the best,
-Ben

alersito's icon

if we run your patch we only set the track in 2 colors

Ben Bracken's icon

As outlined in the clip color ref entry, the RGB value of the color is in the form 0x00rrggbb or (2^16 * red) + (2^8) * green + blue, where red, green and blue are values from 0 (dark) to 255 (light).

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

Here is an example that does the conversion for you from rgb:

StvDee's icon

Nice solution Ben Bracken, but I would like to know the expression for the opposite conversion. Could you share please?

Thanks

ShelLuser's icon

Just 'get' the property just like you'd get any other property.

Edit:

Ah; I think I understand what you meant; going from the big int value back to the rgb notation ?

Well, the ref page mentioned above should make that obvious IMO... Simply convert the int value to a hex value and split it apart; you'll end up with rr gg bb.

StvDee's icon

Hey, thanks for the reply. I tried your method by using the number box with the hex selection. However I am facing a problem: When I want to convert i.e. the red value in hex is FF0000 and if you split it you get FF=255, 00=0, 00=0. But when you set to blue, which is 00FF00, the first digits are discarded from the number box. This leaves me one option to do the whole hex conversion which is the following:

i.e. number 35432 in hex to dec:

2x(16^0) + 3x(16^1) + 4x(16^2) + 5x(16^3) + 3x(16^4) =
2 + 3x16 + 4*256 + 5*4096 + 3*65536 =
2 + 48 + 1024 + 20480 + 196608 =
218162

Do I have to do the whole calculation in Max, or is there a better method??

ShelLuser's icon

Check the original refpage again.

Its not ff0000, its 00ff0000. As in 0x00rrggbb.

Edit: I also wonder if you didn't mix up hex -> dec with dec -> hex, but at this time I'm not going to check myself to be sure.

broc's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Here is Ben's solution complemented with the opposite conversion.

StvDee's icon

Awesome, thanks for the suggestion!

encoder audio's icon

Old topic, sorry for the resurrection.
Is it possible to monitor the tracks color change in realtime?
I mean, if I change it, can I get the new colour without sending a bang?

tyler mazaika's icon

Yes, color is an observable property of tracks.