Flush Remote Control Parameter

Post Reply New Topic
RELATED
PRODUCTS

Post

Dear funky coders,

I am writing a (java)script that has access to many pages of remote control parameters. For each page of parameters I execute a script like this:
remoteControls1.selectedPageIndex().set(0);
for (var i = 0; i < 8; i++) {
var parameter = remoteControls1.getParameter(i);
parameter.markInterested();
}
That marks each parameter interested.

When it comes to flushing the parameters to the device for updating, I use this script:
// the indices of the parameters that we want to send as MIDI CC messages
const PARAMETER_INDICES = [0, 1, 2, 3, 4, 5, 6, 7];

// the MIDI CC numbers that correspond to the parameters on the hardware device
const MIDI_CC_NUMBERS = [1, 2, 3, 4, 5, 6, 7, 8];

// get the values of the parameters and multiply them by 120
var values = PARAMETER_INDICES.map(function(index) {
remoteControls1.selectedPageIndex().set(0);
return remoteControls1.getParameter (index).get() * 120;
});

// round the values to the nearest integer
values = values.map(function(value) {
return Math.round(value);
});

// send a MIDI CC message for each parameter
for (var i = 0; i < PARAMETER_INDICES.length; i++) {
host.getMidiOutPort(0).sendMidi(176, MIDI_CC_NUMBERS, values);
}


Everything works, however, when a parameter is changed it updates each and every parameter marked interested in the whole script (~300 in my case), instead of just updating the parameter that has been changed. This can get a bit much and laggy. Moss mentioned this problem in his excellent scripting tutorials and briefly mentioned a bit of code as a solution, however I don't understand enough about coding to dissect and re-apply it for my use case here.

If anyone could help me out on this, it would be much appreciated :) I plan to make the script available as a blueprint and with some OpenStageControl GUI surfaces once I'm done, as I don't see any scripts so far that are capable of handling multiple parameter control pages at once.

Post

You need to compare it against the last value you sent out. So you'll want an array of all your parameter values. So every time time you send out the midi data just store the parameter value to this array. And then do the comparison every flush.

Also since you are mapping multiple pages you will want an observer on selected page index that always resets it back to the right index as it can change un-intentionally with user interaction. And sometimes you won't have all the pages available so you'll need to do some more observation on pageCount(). And do some conglomeration of those two things.
----------------------------------------------------------------------
http://instagram.com/kirkwoodwest/
http://soundcloud.com/kirkwoodwest

Post Reply

Return to “Controller Scripting”