MIDI Remote API Help with LED activation

@Jochen_Trappe - of course. I’ve attached it.
akai_apcmini.js.zip (1.5 KB)

Here is the solution:

button.mSurfaceValue.mOnProcessValueChange = function(activeDevice, value) { 
                if (value) {
                    turnOnLED(activeDevice, this.note_number)
                    console.log("GRID ACTIVE =>" + note_number)
                    }
                else
                    {
                    turnOffLED(activeDevice, this.note_number)
                    console.log('off')
                }
            }.bind({note_number})

when registering a callback function, best thing is to use the “bind”-method to bind members to the “this” object within the callback function. If you get used to it, you’ll see you don’t even need the activeDevice.getState/setState any more. Didn’t know this when I designed the getState/setState thing. Now, I know better :wink:

3 Likes

@Jochen_Trappe Thanks very much for fixing that and showing me what to do - I’ll look into bind as this is clearly key! I’ll be able to use this to fix my other issues elsewhere, no doubt…

1 Like

Hey Djaychela,
I’m diving for the first time into this Midi remote API , unfortunately without relevante knowledge yet.
Would it be possible to share the final working Cubase script for the apc mini so I can learn something?
Thanks I appreciate
Rgds
P

Hi,

Lot of useful info here!
I’m trying to work out LED feedback on a BCR2000 and I thought maybe you could help with the following:

I’m using a set of buttons to navigate between different pages of the controller script. I’d like to be able see the active page by switching on the corresponding LED.

The problem I’m facing is this:

The buttons send momentary CC messages and to switch on the LED I need to use the same CC.

When using page.mOnActivate to trigger the TurnOnLED function what happens is:

  • button pressed down → CC value 127 sent to script
  • page activated → CC value 127 sent back to LED
  • button released → CC value 0 sent → LED switched off

Obviously if I use a different button to activate the page, everything works fine. But since the CC number of the button used to activate the page and the CC of the LED are the same, this clearly won’t work as intended.

Any recommendations?