So I’m getting in over my head with the JS API for MIDI Remote.
Ultimately I want to get my X-touch One working in the way that I want, which I think I’ll be able to with the API. However, at the moment I’m experimenting with simpler controllers, and am having issues getting LEDs on buttons to work in the way I would expect. I’m by no means a JS developer, I’m just trying to learn as I go, so please take this into account!
I’ve created a functional script for my APC mini (which has a grid of buttons which send out Note On/Note Off, and illuminate as you would expect when used with the ‘consumer’ MIDI Remote - they light up when the button is pressed, and then go out when it’s released).
I want to control the LEDs, and at the moment I have the following script (this is part of a for loop, but you get the idea):
var button = deviceDriver.mSurface.makeButton(buttonIndex * 2, 8 - channelIndex, 2, 1)
var note_number = (channelIndex * 8 ) + buttonIndex
button.mSurfaceValue.mMidiBinding
.setInputPort(midiInput).setOutputPort(midiOutput)
.bindToNote (0, note_number)
button.mSurfaceValue.mOnProcessValueChange = function(activeDevice, value) {
if (value)
turnOnLED(activeDevice, note_number)
else
turnOffLED(activeDevice, note_number)
}
This doesn’t work. However, if I change it so it’s always a fixed note number:
button.mSurfaceValue.mOnProcessValueChange = function(activeDevice, value) {
if (value)
turnOnLED(activeDevice, 1)
else
turnOffLED(activeDevice, 1)
}
This does work, but only on the same LED for all the buttons (i.e. the press status of any of the 64 buttons is reflected on button 1).
I’ve found the documentation pretty impenetrable (it seems merely to list methods and attributes, rather than actually document properly), and have just been doing trial and error and looking at a couple of scripts that users on here have posted. I think it would be helpful to encourage posting of JS files as well as .midiremote as then people can learn from what others have done.
Any help on this would be appreciated - I didn’t expect this part of it to be this difficult!