Within callbacks it is very unhealthy (semantically wrong) to create hostaccess objects (MR_HostObject). “GetByIndex” is an example of creating a MR_HostObject, that must be done outside the callbacks. We have to implement a kind of “alarm”-system for those cases I’m afraid. Of cause that’s our fault and not yours.
Shift buttons are best adapted by using a SubPageArea + two SubPages. It is again a bit counter-intuitive, but works. That way when press+hold the shift button, the SubPage “Shift” is activated and by using “mapToValueRange(1, 0)” you can react on releasing the shift button, it inverts the internal process value.
var knob = deviceDriver.mSurface.makeKnob(0, 0, 2, 1)
var shiftButton = deviceDriver.mSurface.makeButton(2, 0, 2, 1)
var subPageAreaFunctionMode = page.makeSubPageArea('Function Mode')
var subPageFuncModMain = subPageAreaFunctionMode.makeSubPage('Main')
var subPageFuncModShift = subPageAreaFunctionMode.makeSubPage('Shift')
var selectedtrackChannel = page.mHostAccess.mTrackSelection.mMixerChannel
// if NOT SHIFTED control the selected track volume
page.makeValueBinding(knob.mSurfaceValue, selectedtrackChannel.mValue.mVolume)
.setSubPage(subPageFuncModMain)
// if SHIFT IS ACTIVE control the selected track pan
page.makeValueBinding(knob.mSurfaceValue, selectedtrackChannel.mValue.mPan)
.setSubPage(subPageFuncModShift)
// if NOT SHIFTED and shift button is pressed down, activate sub page 'Shift'
page.makeActionBinding(shiftButton.mSurfaceValue, subPageFuncModShift.mAction.mActivate)
.setSubPage(subPageFuncModMain)
// if SHIFT IS ACTIVE and shift button is released, activate sub page 'Main'
page.makeActionBinding(shiftButton.mSurfaceValue, subPageFuncModMain.mAction.mActivate)
.mapToValueRange(1, 0) // handle value inverted to react on releasing the button
.setSubPage(subPageFuncModShift)
That is correct. However you can make the callbacks be per-page. I have done this in TypeScript because I get confused with all the procedural abstraction. I just can’t abide. But you can work it out I suppose.
I seriously don’t know how people keep things strait without OO abstraction. It creates really messy and hard to understand code, and when you come back to it after a week it’s even more difficult than the first time around.
I’m really hoping for Either TypeScript or even ES6 in the future.