Change led colors from an external midi message

Welcome to the forum!

This would almost certainly need to be with an Ableton Remote Script along with some custom LUA on the controller itself. Changing which Rack is in focus doesn’t send any sort of MIDI information from what I know.

You’ll want to look into the ‘Blue Hand’ feature. Intech has posted some stuff about it on this forum I believe. The ‘Blue Hand’ is on any Ableton device/rack and it denotes the device/rack that is being currently controlled or interacted with (I think).

Remote scripting is needed to allow a control surface to interact with ‘Blue Hand’ devices. Somewhere in those interactions, it would be coded to send a track color to Grid so that it can be used to update LEDs (super simplified explanation but something to that effect).

I’ve not looked into remote scripts before but it’s my understanding that they are written in Python. I’m sure there’s a lot of tutorials and information on the subject but I’d wager that it can get pretty complex fairly quickly.

With a custom remote script for the PO16 (or any Grid device), you could do a lot of integration. It would take a lot of some effort though.

Perhaps the Intech devs have some suggestions though. :slight_smile:

the case is that I already have the midi remote script working, i’m selecting the device from my monome, sending midi messages to Live for selecting them, i’d route that same message to the PO16 to change the colors, but I don’t know how to do it in LUA

You’ll want to look at the ‘MIDI rx’ tab on Element 16 (System). This is where you’ll map incoming MIDI messages to trigger events/functions on the PO16.

The only thing is that, the Monome is likely just selecting the track. It has no idea what color the track is. I assume you’re talking about a Monome Grid controller of some sort? The LEDs are monochromatic, yes? As such, whatever script you’re using doesn’t need to receive track color back from Ableton and the Monome doesn’t know what color the track is either (I assume).

You could certainly send some type of MIDI message to the PO16 whenever you send a track select message from the Monome. But, how will the PO16 know what color the track is? Unless, you’re working off of the same Ableton project and the track colors remain the same then, you could hard code the colors into the PO16.

Start with looking into the ‘MIDI rx’ feature and then think a little bit about how you might be able to send messages from the Monome to trigger events.

Yes i have that in mind
To do a list of specific colors :+1:
This is what i’m trying to achieve
Thanks for the info, will try to deep into it

ok, with this code, on the Midi RX, I can change by midi messages the color of 1 knob (4 colors)
but ca’t add more code, it says i’ve reached the limit. So no 5 colors and even less 8 colors for 8 knobs.
sure it can be done.
At least I’ve learned how to change by midi the color of one knob, and if i can avoid the code limit i’m pretty sure I know how to do it.

What you could look at is using a table to store the color values. On the ‘Init’ tab of the ‘System’ element (same element as the ‘MIDI rx’ tab), you can define a function that you can call instead. This function/table can be called from anywhere on that module’s page (like, from any of the element pages). You could have a table with the RGB values that you need and use the function to look up and assign those values to each element’s LED.

Are you wanting all top 8 knobs to have the same color at the same time based on the active track? If so, you could use a function to iterate the LED value assignments. So, you’d just need a table with 8 sets of RGB values representing each color.

Edit: A link to a reply from one of the devs:

You could setup an array on the ‘Init’ tab of the ‘System Element’ page:

rgb = {
         {255,0,0},
         {125,50,0},
         {etc......},
         }

Then define a function on the same ‘Init’ tab to be called by a midi_rx event to set the color for the first 8 LEDs:

function set_color()

for i = 0, 8, 1 do
element[i]:led_color(LAYER, rgb[1][1]. rgb[1][2], rgb[1][3])
end

Hi, first of all, thanks for your time
but sorry, still lost :sweat_smile:
this is what I have now, but can’t commit the code with the function line,
and don’t really understant how can I call the RGBs from the midi RX
let’s say I’m trying to do it with Midi Ch1 CC4, first 8 values

and this is the MIDI RX tab

You’re missing an end at the end of your function!
image

You’ll need two, one to end the loop and another to end the function declaration!

ok, now with that code commited, how can I connect the MIDI RX (midi.p2) to it?
thanks

Good morning :slight_smile:

I’m glad you were able to get the table setup and the function defined. I’ve not used ‘MIDI rx’ before but I’ve been wanting to learn it properly.

So, what is the exact MIDI channel, CC, and value you are sending to the PO16 from the Monome for each of the 8 tracks you’re controlling in Ableton? I’ll need to know what you’re sending to the PO16 first before I can look into how to implement the code.

I’m sending CC 4 on CH 1
Would like get response from 1 to 8 for example

Thanks

So, you’d be sending CC 4 with a value of 1 through 8 (representing each track) on channel 1?

Just scripting something up so, I’ll use exactly what you’re needing.

Yes exactly :clap::clap::clap:
Thanks so much man

Have most of it setup. I’m just looking at how to process the incoming MIDI to trigger the function. Again, I’ve not used this myself so just wrapping my head around it.

I do have the function and table setup and I am receiving my test MIDI. But, it’s not being passed to the function (I have some print() stuff setup in the function so I can see if it’s receiving data). I have to grab breakfast and go drop off my car at the shop. I’ll be back in 1.5 hours and I’ll take a look again while I’m doing my remote work. Pretty confident I can get it sorted out though. I’ll post everything once I’ve got it done.

:slight_smile:

Here’s what I have so far but it’s not working and throwing an error in debug that I can’t figure out. Perhaps @narayb could take a look to see what I’m missing:

-- 'Init tab'

midirx_enabled(1)
rgb = {
    {255, 0, 0},
    {125, 50, 0},
    {100, 100, 100},
    {200, 200, 200},
    {0, 0, 0},
    {0, 255, 0},
    {255, 255, 255},
    {50, 50, 250}
}
function set_color(cl)
    for i = 0, 8, 1 do
        element[i]:led_color(2, rgb[cl][1], rgb[cl][2], rgb[cl][3], 1)
    end
end

-- 'MIDI rx' tab

local ch, cmd, param1, param2 = midi.ch, midi.cmd, midi.p1, midi.p2
if cmd == 176 and ch == 0 then
    set_color(param2)
else
end

I have tested that the correct RGB values are pulled by adding print() inside the set_color() function to show the table values being pulled. They are correct. My element:led_color() looks properly formatted (though I’m always needing to look up the layer. I tried both layers).

The error in debug is: [0,0] LUA not OK! EL: 16 EV: 5

It only throws this error when I’m sending MIDI to update the colors. Just poking at this during my work day so don’t have piles of time to debug it. It looks correct to my eye and it value checks with print()`` nested in the set_color()``` function.

Thoughts?

Also, in the debug output, what would event 5 ( EV: 5) be? The 5th event called starting at the ‘Init’ tab and moving to the right? That would be the set_color() function call in the ‘IF’ control block.

not working here either, same error
where in the code are you specifying the CC?
should it be in the IF function? param1 == 4

thanks again for your time

And yes, I should also check that CC 4 == true. :slight_smile: But, I’m only checking channel and that the message is a CC. I’m just testing so didn’t account for needing to only call the function if it explicitly matches things. It’s not what’s breaking things but the final code should have:

if cmd == 176 and ch == 0 and param1 == 4 then
    set_color(param2)

What that is saying is if ‘cmd’ equals 176 which is Intech’s numeric code for a ‘CC’ message, AND the MIDI channel is ‘0’, which is channel 1 as Intech counts MIDI channels from 0 to 15, THEN call the set_color() function and pass param2 as the value. ‘param2’ is the value of the CC message. So CC 4, value 1 through value 8 will select the correct RGB values from the rgb{} table.

I’ve tested that part by adding a print() call in the function code itself. I think the issue is the element[i]:led_color() part. The syntax looks correct but I think that’s where the issue is.

I can somewhat test this by calling print() before and after that statement inside the function. I’ll do that like this:

function set_color(cl)
    for i = 0, 8, 1 do
        print("Before")
        element[i]:led_color(2, rgb[cl][1], rgb[cl][2], rgb[cl][3], 1)
        print("After")
    end
end

I’ve already tested that ‘param2’ gets passed to that function correctly and that the correct rgb{} values are being pulled.

And, as expected, the element[i]:led_color() breaks it. I get ‘Before’ but not ‘After’.

Lunchtime so I can look into this and I think I see the issue now…checking.

Bingo! Got i!

midirx_enabled(1)
rgb = {
    {255, 0, 0},
    {125, 50, 0},
    {100, 100, 100},
    {200, 200, 200},
    {0, 0, 0},
    {0, 255, 0},
    {255, 255, 255},
    {50, 50, 250}
}
function set_color(cl)
    for i = 0, 8, 1 do
        led_color(i, 2, rgb[cl][1], rgb[cl][2], rgb[cl][3])
        led_value(i, 2, 50)
    end
end

The functions led_color() and led_value() do not need to be called with element[i] as they already take parameters to indicate which element to address. Also, I needed to call led_value() so that the new color settings apply.

Tested on mine as working.

Full proper code:

-- 'Init tab'

midirx_enabled(1)
rgb = {
    {255, 0, 0},
    {125, 50, 0},
    {100, 100, 100},
    {200, 200, 200},
    {0, 0, 0},
    {0, 255, 0},
    {255, 255, 255},
    {50, 50, 250}
}
function set_color(cl)
    for i = 0, 7, 1 do
        led_color(i, 2, rgb[cl][1], rgb[cl][2], rgb[cl][3])
        led_value(i, 2, 50)
    end
end

-- 'MIDI rx' tab

local ch, cmd, param1, param2 = midi.ch, midi.cmd, midi.p1, midi.p2

if cmd == 176 and ch == 0 and param1 == 4 then
    set_color(param2)
else
end

To add to this, delete all blocks in both ‘Init’ and ‘MIDI rx’ on the ‘System’ element. Create a new ‘Code’ block in each and copy the appropriate snippets of code.