MIDI Remote: single encoder for prev/next track

I’m trying to get a single encoder (sending midi cc values 63/65) to select next/prev track.

Here is my attempt:

.bindToControlChange (0, 22)
.setValueRange(63, 63)
.bindToControlChange (0, 22)
.setValueRange (65, 65)

page.makeActionBinding(knob1.mSurfaceValue, page.mHostAccess.mTrackSelection.mAction.mPrevTrack)
page.makeActionBinding(knob2.mSurfaceValue, page.mHostAccess.mTrackSelection.mAction.mNextTrack)

There are two “virtual” knobs so I can assign their actions separately according to the two different midi cc values Cubase receives.
If what I’m trying to do is possible, are there any examples I can refer to?

You can look at my script here where I mapped a rotary encoder to Jog Left/Right.
You would have to tweak it to suit your needs but perhaps it can serve as a starting point.

that’s a great starting point for me, thank you!

thanks again for this, I managed to make the necessary changes to do what I need.
quick clarification, though. why is the condition “value” > or < than 0.5 rather than something within the midi cc value range? ie value > 64 or value < 64?

@owenc The comparison is inside the .mOnProcessValueChange callback function which is triggered by Cubase.
Internally, Cubase converts all values to unit intervals, a floating point value between 0 and 1, which is what the parameter value is.

// 2. SURFACE LAYOUT - create control elements and midi bindings

// create control element representing your hardware's surface
var knob1 = deviceDriver.mSurface.makeKnob(0, 0, 1, 1)
// bind midi ports to surface elements
    .bindToControlChange (0, 102) // channel 1, cc 102 
var nTrack = deviceDriver.mSurface.makeCustomValueVariable('Ntrack')
var pTrack = deviceDriver.mSurface.makeCustomValueVariable('Ptrack')

// 3. HOST MAPPING - create mapping pages and host bindings

// create at least one mapping page
var page = deviceDriver.mMapping.makePage('Default');

page.makeActionBinding(pTrack, page.mHostAccess.mTrackSelection.mAction.mPrevTrack);
page.makeActionBinding(nTrack, page.mHostAccess.mTrackSelection.mAction.mNextTrack);

knob1.mSurfaceValue.mOnProcessValueChange = function(activeDevice, value) {
	if(value > 0.51) // 65/127
    nTrack.setProcessValue(activeDevice, 1.0)
    if (value < 0.497)// 63/127
    pTrack.setProcessValue(activeDevice, 1.0)