New Question.
Say I have a controller with a single knob, and an LED that can be Amber, Red, or Green.
I want to use that knob to control a given setting. for this example we can choose selected track Pre Gain.
The knob is configured to be in pickup mode.
When the state of the knob is more than the state of the selected Tracks Pre Gain, I want the LED to be Red, when it is less, Amber, and when the same, Green. That way the user can see whether they would need to turn the knob left or right to puck up, or if the change would be immediate.
My hardware is capable of changing the colour of the LED if I pass it a specific note with a given velocity. I can send this message to the controller and the light changes.
How would I write this One-Knob script?
How do I save the current value of the knob when there is no device facing event or callback?
All callbacks seem to come from the host.
Is there any way to get the value of the knob so that I can compare it to the newValue?
The Page might have changed.
The value might have been changed with the mouse, (or automation.)
The Track might have change.
The Knob might have been moved.
this.knob.mSurfaceValue.mOnProcessValueChange = function (context, newValue, oldValue)
{
if (?????????????????????????????????????)
{
this.midiOutput.sendMidi(context, this.Color['Red'])
}
else if (?????????????????????????????????????)
{
this.midiOutput.sendMidi(context, this.Color['Amber'])
}
else
{
this.midiOutput.sendMidi(context, this.Color['Green'])
}
}
The name mSurfaceValue sounds like it is referring to the knobās position, but it is actually referring to the value within the host.
What is the oldValue? It isnāt the value of the knob itāself as I thought it might be.
It seems to be the old value that the currently assigned parameter had in the host before it changed. Why do I need this? Why would I ever need that information?
A callback like
this.knob.mDeviceValue.mOnProcessValueChange = function(context, value)
{
this.setSavedKnobValue(value)
}
Would allow the conditional above to be used.
But the āSurfaceā (which seems to refer to the device. at least it does in the readme) should be storing this value shouldnāt it? So maybe just adding the parameter like this:
this.knob.mSurfaceValue.mOnProcessValueChange = function (context, newValue, oldValue, lastSentValue) ...