Ok, so I’m most certainly missing something because this seems a bit too easy, but at least from my experiments so far I seem to have this working now.
All I really did was disable the hardware feedback by removing .setOutputPort
, and instead create a function that ‘manually’ sends midi on value changes (but first rounds the value with Math.round
, thanks @Shor).
Again I feel I must be missing something which will cause problems with this, because it’s such an easy solution, but for now it seems to work perfectly: no rubberbanding (except around the 0db mark, but this seems to be a feature?!), values in Cubase and on the Stream Deck stay perfectly in sync, and switching between tracks also correctly updates my values on the Stream Deck.
var midiremote_api = require('midiremote_api_v1');
var deviceDriver = midiremote_api.makeDeviceDriver('Elgato', 'Stream Deck Plus', 'Lucas');
var midiInput = deviceDriver.mPorts.makeMidiInput();
var midiOutput = deviceDriver.mPorts.makeMidiOutput();
deviceDriver
.makeDetectionUnit()
.detectPortPair(midiInput, midiOutput)
.expectInputNameEquals('StreamDeckPlusOut')
.expectOutputNameEquals('StreamDeckPlusIn');
var page = deviceDriver.mMapping.makePage('Default');
var hostSelectedTrackChannel = page.mHostAccess.mTrackSelection.mMixerChannel;
function createKnob(midi_channel, midi_cc, x, y, w, h, hostValue) {
var knob = deviceDriver.mSurface.makeKnob(x, y, w, h);
knob
.mSurfaceValue
.mMidiBinding
.setInputPort(midiInput)
.bindToControlChange(midi_channel, midi_cc);
page.makeValueBinding(knob.mSurfaceValue, hostValue);
knob.mSurfaceValue.mOnProcessValueChange = function (context, newValue) {
midiOutput.sendMidi(context, [176 + midi_channel, midi_cc, Math.round(newValue * 127.0)]);
};
}
createKnob(0, 1, 0, 0, 1, 1, hostSelectedTrackChannel.mValue.mVolume);
createKnob(0, 2, 1, 0, 1, 1, hostSelectedTrackChannel.mSends.getByIndex(0).mLevel);
createKnob(0, 3, 2, 0, 1, 1, hostSelectedTrackChannel.mPreFilter.mGain);