Forums > Max For Live

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

June 24, 2011 | 11:17 am

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
June 24, 2011 | 11:52 am

do you mean track or clip?

you can read and it from the clip:

http://cycling74.com/docs/max5/refpages/m4l-ref/m4l_live_object_model.html#Clip

Reference pages are friends not enemies … ;)


June 24, 2011 | 3:00 pm

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


June 24, 2011 | 4:25 pm

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.

– Pasted Max Patch, click to expand. –

June 24, 2011 | 5:50 pm

Ben with this configuration only 2 colors for a track.

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


June 24, 2011 | 6:00 pm

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

All the best,
-Ben


June 24, 2011 | 6:16 pm

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


June 28, 2011 | 4:15 pm

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).

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

– Pasted Max Patch, click to expand. –

September 25, 2011 | 7:57 pm

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

Thanks


September 25, 2011 | 8:04 pm

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.


September 25, 2011 | 11:29 pm

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 + 3×16 + 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??


September 26, 2011 | 3:22 am

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.


September 26, 2011 | 11:10 am

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

– Pasted Max Patch, click to expand. –

September 27, 2011 | 9:06 pm

Awesome, thanks for the suggestion!


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