Get LED colors from DAW channels and use in EN16

Hello,

I am using page 2 of my 2 EN16 to control the volume, pan and sends of my channels 1-8 from Cubase. The controls work already, now I would like to map the colors of the tracks in Cubase to the colors of the LEDs on my EN16.
From the Cubase side the color data of a track can be sent out as SysEx message:

// Track Color
selectedTrackChannel.mOnColorChange = function (activeDevice, activeMapping, r, g, b, a, isActive) {
var rgbaString = r.toString() + g.toString() + b.toString() + a.toString()
sendSysEx(activeDevice, rgbaString)
}

Now, from the Grid side, how do I configure an encoder LED to receive and react to that information?

Thanks in advance!!!

Best regards,
Carlos

This is a nice coding gymnastic task as Grid works now. A global buffer should be implemented in lua code. The buffer should wait together incoming MIDI data, and split up by checking sysex start and end messages. We don’t have right now any configs like that.

Hi Kristof

Thanks for the reply!
Do you mean that I could program that myself already (if I get the Lua skills… :smile: ) or do you mean that you would need to program something on the firmware or editor (and of course only if many users request that and it aligns with your roadmap/strategy).
This is not a deal-breaker, but would be really cool nice to have.

I think I got something.

System event config link: grid-editor://?config-link=qlikj4hIixmivgj9MS1v

I implemented couple helper functions, which should give a starting point to work with sysex messages on Grid. The “init” event’s function scope is maxed out in this case, so refactoration might be needed to add more complex calculations. On midi rx itself, there are plenty of characters left.

Init:

buffer = {}
function len(arr)
	local c = 1;
	while arr[c] do
		c = c + 1
	end;
	return c - 1
end;
function ins(x)
	local l = len(buffer)
	buffer[l + 1] = x;
	return
end;
function rs(arr)
	local c = 1;
	while arr[c] do
		c = c + 1;
		if arr[c] == 240 then
		elseif arr[c] == 247 then
			print("stop")
			log()
			buffer = {}
			break
		end
	end;
	return
end;
function log()
	local x = ""
	for i = 1, len(buffer), 1 do
		x = x .. " " .. buffer[i]
	end;
	print(x)
	return
end

midi rx:

local ch, cmd, p1, p2 = midi.ch, midi.cmd, midi.p1, midi.p2
ins(midi.ch)
ins(midi.cmd)
ins(midi.p1)
ins(midi.p2)
rs(buffer)

I have written the instructions into the preset on Profile Cloud, copying it here:

Implemented helper functions to process incoming SysEx messages. SysEx received by Grid come in decimal values, 240 marks message start, 247 message end.

Global buffer variable holds the sysex messages. On midi rx the data is passed into the ins() insert function, that’s how the bits are collected. After every midi rx trigger, rs() function checks if the stop value is received. the log() is used to print the sysex in the debug window.

Functions:

  • len: calculates the length of the input array
  • ins: puts the input value to the end of the buffer array
  • rs: checks for reset, the start and stop value
  • log: debug print

This is how debug looks like if I send a test sysex command to Grid, using SysEx Librarian on MacOS:

A special function should be needed to get the correct indexes of the buffer to set the LED color of the LEDs, happy to help if you can send me the .syx file for demo data coming out of cubase.

Awesome! Thanks a lot for that!!! I will deep dive into this this weekend!

Hi Kristof,

I got a Cubase developer to help me implement the correct code in my script to send the track color data.

hostMixerBankChannel.mOnColorChange=function(activeDevice,activeMapping,r,g,b,a,isActive){

    //here we're translating the r,g,b response to the proper 0-127 range
    var r127=Math.round(127*r)
    var g127=Math.round(127*g)
    var b127=Math.round(127*b)

    //Here we have to construct the sysex
    //Normally it is a collection of bytes specified by the manufacturer, followed by the channel number (it's the variable I have below "channelIndex"), and then the RGB color in bytes as I've set them up above
    
    var channelIndex=this.channelIndex
    
    var sysex=[]

    //Here we send the sysex
    midiOutput.sendMidi(activeDevice,sysex)

}.bind({channelIndex})

However, he said now the sysex data need to be aligned with the device manufacturer. Based on your last post with code, what would be the sysex message bytes for sending color info to Grid? And where does the sysex file would need to be stored for Grid to be able to read it?
Sorry if my comments sounds too stupid, I am a total newbie in sysex and scripting…

Yeah, no prob. Could you please let me know the cubase version where this scripting is available?

Hi Kristof,
Thanks a lot! I am using Cubase 13 Pro.
Here is the link to their API reference

Here is the link to my full script: