SOLVED: mOnColorChange for channels in mixerBankZone not working properly

Dear forum members,
I´m sending out the rgb values of my mixerBankZone channels via mOnColorChange but somehow the message data is getting messed up.
Here is my color data vs log data:

SOURCE r g b - r g b - r g b
original color data 255 120 0 0 200 180 70 0 220
logged data 0 109 126 99 89 126 0 109 126

The values get halfed which is reasonable I guess because the way the process works. But there is also a shift of the values and some values seem to leak through to newer messages.
This is my code:

for (var channelIndex = 0; channelIndex < 4; channelIndex++) {
  surfaceElements.buttons_tracks[channelIndex].mSurfaceValue.mOnColorChange = function (activeDevice, activeMapping, r, g, b, a, isActive) {

      var displayIdx = this.channelIndex + 1; // displayIdx starting at 1

      var msg = [
          0xf0, 0x43, 0x4f, 0x4c, 0x52,
          displayIdx, 
          Math.floor(127 * r), 
          Math.floor(127 * g), 
          Math.floor(127 * b), 
          0xf7
      ];
    console.log('At displayIndex='+displayIdx+ ' r=' +Math.floor(127 * r) + ' g=' + Math.floor(127 * g)+' b='+Math.floor(127 * b)+ ' --> msg= ' + msg)

      midiOutput.sendMidi(activeDevice, msg);
  }.bind({ channelIndex }); 
}

Any help is much appreciated, thanks.
Emre

MIDI 1.0 supports the 0-127 range.

Your code looks correct to me.
Where do the original color data and logged data come from?

Hello Minas, thanks for chiming in!
The original color data is from my project color settings, eg here for first color:


The logged data is from the console.log entry in the code. Here a picture of the console:
image
Beware, the console logs are not in the right order…

Ah, now I see. I recall a similar case in my thread for the Keylab MK2. From what I can remember right now, this has to do with a property of the color out of the r,g,b, perhaps a? Was it a multiplier? I really can’t remember now, sorry… If I find the post I will share it here :slight_smile:

Oh interesting, hear from you later then, thanks.

This is my console log for all params printed:
image

    console.log('At displayIndex='+displayIdx+ ' r=' +Math.floor(127 * r) + ' g=' + Math.floor(127 * g)+' b='+Math.floor(127 * b)+ ' a=' + a + ' isActive=' + isActive + ' --> msg= ' + msg)

Ah, sorry, now I see the problem.
It was hidden, because I was unfortunately too lazy to scroll right :slight_smile:

Your function has wrong arguments. The surfaceElements do not support the activeMapping argument. I guess you pasted it from a source where a hostValue.mOnColorChange was used.
Here’s how to correct this:

surfaceElements.buttons_tracks[channelIndex].mSurfaceValue.mOnColorChange = function (activeDevice, r, g, b, a, isActive) {
1 Like

You are just WOW! After spending hours of investigation this is it finally, thanks a lot!!
Exactly, I copied the code from:

  page.mHostAccess.mTrackSelection.mMixerChannel.mOnColorChange = function (activeDevice, activeMapping,r,g,b,a,isActive){

The devil lies in the detail… :grin:

1 Like