Events getting triggered before device's activation

Hi, while creating a new script, I got to an issue concerning some events that get triggered before the device.mOnActivate one. I’ve noticed this one before, however I didn’t find it that critical.

Some examples:

page.mHostAccess.mTransport.mTimeDisplay.mPrimary.mTransportLocator

page.mHostAccess.mTransport.mTimeDisplay.mPrimary.mCycleLocatorLeft (and right)

page.mHostAccess.mTransport.mTimeDisplay.mOnChangeTempoBPM

channel.mInstrumentPluginSlot.mOnChangePluginIdentity, where channel=mixerBankZoneChannels[aChannelsIndex]

At the same time, no issue with other channel parameters (volume, pan, title, color).

Anyway, I’m reading all of the above (and some other ones) and update my controller’s display accordingly.
Now, since these events are triggered before the device’s activation, activeDevice is still not set (pretty logical), so the sysexes I use to update my display are not sent.
I’m really not sure, if this is a bug, i.e., if all of the above should get triggered only after device’s activation, but even if it is not, it would make life easier to set everything to get triggered only after our device’s activation. At the same I must note that this issue is not there when activating another controller I have, so I have to suspect that this particular controller’s activation process takes less time, so I hadn’t witnessed this behaviour.

Anyway, my workaround (?) for now is to check if device is activated upon trying to send my commands. If it’s still not activated, I’m pushing these sysexes to an array. Finally, when our device is activated, I’m iterating through this list and send my commands.

Inside my script I’ve set:

controllerVariables.initialized=false 
controllerVariables.lstOfSysexUponActivating=[]

where controllerVariables is an object (map) I have for other settings as well, and lstOfSysexUponActivating the array I’m pushing the sysexes that can’t be sent when created.

A sysex command example:

if(controllerVariables.initialized==true){
       
      midiOutput.sendMidi(activeDevice,finalSysex)
 
} else {

      controllerVariables.lstOfSysexUponActivating.push(finalSysex)
    
 }

And upon the mOnActivate event:

deviceDriver.mOnActivate=function(activeDevice){
    
    controllerVariables.initialized=true 

    if (controllerVariables.lstOfSysexUponActivating.length>0){
    
           controllerVariables.lstOfSysexUponActivating.forEach(function(sysex){
    
                 midiOutput.sendMidi(activeDevice,sysex)
    
            })
    
           controllerVariables.lstOfSysexUponActivating=[]
    
    }
    
}
3 Likes

Seconding this! In my MCU scripts, I have to store the initial transport locator position and separately send it to the transport display on activation because sending the corresponding MIDI messages doesn’t work before. Having the guarantee that a script is mOnActivated before any other events occur would be soo convenient :relieved:

@Jochen_Trappe? :face_with_peeking_eye:

1 Like

Hello my friend, as I wrote earlier the only thing that makes me a bit confused is the fact that in another script which obviously loads faster, I don’t have this issue. Maybe, just maybe, it can also be a matter of optimisation. BUT, I’m sure that what we ask for can be done, and if more manufacturers get into scripting their controllers, and since it’s sure they will notice such little issues, it will be updated, so I guess and hope :slight_smile:

1 Like