Is there a way to read the Selected Track's type (Audio, Instrument, etc.) in MIDI Remote?

Hi, I’d like to map a push encoder to do one thing when pressed while an Instrument track is selected (namely, open the VST instrument) and another when an Audio track is selected (“Edit Plugin” which will open my guitar amp sim like NeuralDSP if the track uses it). As far as I can see I can get the title of the selected track or it’s color, but not it’s type. Is there a way to get this information?

I figure I could rename my Instrument tracks to end with “INSTRUMENT” and my Audio tracks to end with “AUDIO” and then use onTitleChange to get the selected track’s title and search if it contains one string or the other. Alternatively I could color map them but I’d like a solution that doesn’t require that. Thanks for your time.

Hi, if I recall correctly the

page.mHostAccess.mTrackSelection.mMixerChannel.mInstrumentPluginSlot.mOnTitleChange=function(activeDevice,activeMapping,arg2){
    console.log("type="+arg2)
}

will return “Slot” for instruments/midi tracks and empty for audio ones.

1 Like

Wow a great solution, thank you m.c! I’ll try it out.

Hi again, I had the time to implement your idea and it worked great. I appreciate your time and input.
However I have run into the issue that a ValueBinding between my CustomValueVariable and the Host Values does not behave as expected. My custom variable behaves exactly like a push encoder - as I press the encoder its value is 1 and when I release it its value goes to 0. I used “setTypeToggle()” on the value binding and it doesn’t behave as a toggle. Rather when I push the encoder the VST interface opens and when I release the encoder it closes. It simply follows the values 1 for open and 0 for closed. It behaves the same way when I use “setTypeDefault()”. What is worse, when I make a ValueBinding between the mPushValue as a surface element and these Host Values and set its type to Toggle, it works correctly.
What am I missing?

Here is the relevant piece of code:

surfaceElements.aiKnob.mPushValue.mOnProcessValueChange = function (context, value){
		if (MiniLab_3_Var.SELECTED_TRACK_TYPE == 'Instrument') {
			surfaceElements.varPushValueInstrumentTrack.setProcessValue(context, value)
		}
		else if (MiniLab_3_Var.SELECTED_TRACK_TYPE == 'Audio') {
			surfaceElements.varPushValueAudioTrack.setProcessValue(context, value)
		}	
}
page.makeValueBinding(surfaceElements.varPushValueInstrumentTrack, page.mHostAccess.mTrackSelection.mMixerChannel.mValue.mInstrumentOpen).setTypeToggle()
page.makeValueBinding(surfaceElements.varPushValueAudioTrack, page.mHostAccess.mTrackSelection.mMixerChannel.mInsertAndStripEffects.makeInsertEffectViewer('').mEdit).setTypeToggle()

I think that customVars cannot be assigned to toggle, so we really have to create pseudo-toggles:

surfaceElements.aiKnob.mPushValue.mOnProcessValueChange = function (context, value){

		if(value==1)}{
           if (MiniLab_3_Var.SELECTED_TRACK_TYPE == 'Instrument') {
              surfaceElements.varPushValueInstrumentTrack.setProcessValue(context, 1-surfaceElements.varPushValueInstrumentTrack.getProcessValue(context))
		   } else if (MiniLab_3_Var.SELECTED_TRACK_TYPE == 'Audio') {
			     surfaceElements.varPushValueAudioTrack.setProcessValue(context,1-surfaceElements.varPushValueAudioTrack.getProcessValue(context))
		   }	
        }
}

page.makeValueBinding(surfaceElements.varPushValueInstrumentTrack, page.mHostAccess.mTrackSelection.mMixerChannel.mValue.mInstrumentOpen)
page.makeValueBinding(surfaceElements.varPushValueAudioTrack, page.mHostAccess.mTrackSelection.mMixerChannel.mInsertAndStripEffects.makeInsertEffectViewer('').mEdit)

1 Like

It works perfectly, thank you for this elegant solution!

1 Like