|
@@ -0,0 +1,217 @@
|
|
|
+
|
|
|
+BCF2000 management script with 14bit precision
|
|
|
+midi inputs are stored as MSB ans LSB and update a float parameter
|
|
|
+on float parameter update, midi values are sent back to BCF (to ensure synchronisation of values)
|
|
|
+*/
|
|
|
+
|
|
|
+
|
|
|
+var pan_midi_ch = script.addIntParameter("pan midi channel", "", 0);
|
|
|
+var pan_midi={channel:pan_midi_ch.get(), MSB:0, LSB:0, target:root.customVariables.unitValues.variables.pan.pan, value: script.addFloatParameter("pan", "current pan value", 0., 0, 1) };
|
|
|
+
|
|
|
+
|
|
|
+var tilt_midi_ch = script.addIntParameter("tilt midi channel", "", 1);
|
|
|
+var tilt_midi={channel:tilt_midi_ch.get(), MSB:0, LSB:0, target:root.customVariables.unitValues.variables.tilt.tilt, value: script.addFloatParameter("tilt", "current tilt value", 0., 0, 1)};
|
|
|
+
|
|
|
+var zoom_midi_ch = script.addIntParameter("zoom midi channel", "", 2);
|
|
|
+var zoom_midi={channel:zoom_midi_ch.get(), MSB:0, LSB:0, target:root.customVariables.unitValues.variables.zoom.zoom, value:script.addFloatParameter("zoom", "current zoom value", 0., 0, 1) };
|
|
|
+
|
|
|
+var focus_midi_ch = script.addIntParameter("focus midi channel", "", 3);
|
|
|
+var focus_midi={channel:focus_midi_ch.get(), MSB:0, LSB:0, target:root.customVariables.unitValues.variables.focus.focus, value: script.addFloatParameter("focus", "current focus value", 0., 0, 1)};
|
|
|
+
|
|
|
+var dimmer_midi_ch = script.addIntParameter("dimmer midi channel", "", 4);
|
|
|
+var dimmer_midi={channel:dimmer_midi_ch.get(), MSB:0, LSB:0, target:root.customVariables.unitValues.variables.dimmer.dimmer, value: script.addFloatParameter("dimmer", "current dimmer value", 0., 0, 1)};
|
|
|
+
|
|
|
+function init()
|
|
|
+{
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+function bits2float(MSB, LSB){
|
|
|
+ Value = param.get()*16383;
|
|
|
+ MSB = Math.floor(ccValue/128);
|
|
|
+
|
|
|
+ LSB = Math.floor(ccValue % 128);
|
|
|
+
|
|
|
+
|
|
|
+ script.log(MSB+ " "+ LSB);
|
|
|
+}
|
|
|
+
|
|
|
+function updateCC(cc, value){
|
|
|
+ if(cc==pan_midi.channel){pan_midi.MSB = value; return pan_midi;}
|
|
|
+ if(cc==pan_midi.channel+32){pan_midi.LSB = value; return pan_midi;}
|
|
|
+ if(cc==tilt_midi.channel){tilt_midi.MSB = value; return tilt_midi;}
|
|
|
+ if(cc==tilt_midi.channel+32){tilt_midi.LSB = value; return tilt_midi;}
|
|
|
+ if(cc==zoom_midi.channel){zoom_midi.MSB = value; return zoom_midi;}
|
|
|
+ if(cc==zoom_midi.channel+32){zoom_midi.LSB = value; return zoom_midi;}
|
|
|
+ if(cc==focus_midi.channel){focus_midi.MSB = value; return focus_midi;}
|
|
|
+ if(cc==focus_midi.channel+32){focus_midi.LSB = value; return focus_midi;}
|
|
|
+ if(cc==dimmer_midi.channel){dimmer_midi.MSB = value; return dimmer_midi;}
|
|
|
+ if(cc==dimmer_midi.channel+32){dimmer_midi.LSB = value; return dimmer_midi;}
|
|
|
+ else return 0;
|
|
|
+}
|
|
|
+
|
|
|
+function updateFloat(channel){
|
|
|
+ channel.value.set((channel.MSB*128+channel.LSB)/16383.);
|
|
|
+}
|
|
|
+
|
|
|
+function feedbackMidi(channel){
|
|
|
+ channel.MSB = Math.round(Math.floor(channel.value.get()*16383. /128));
|
|
|
+ channel.LSB = Math.round(Math.floor(channel.value.get()*16383. %128));
|
|
|
+ script.log(channel.MSB + " " + channel.LSB);
|
|
|
+ local.sendCC(1, channel.channel, channel.MSB);
|
|
|
+ local.sendCC(1, channel.channel+32, channel.LSB);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+function scriptParameterChanged(param)
|
|
|
+{
|
|
|
+ if (param.is(pan_midi.value) ){feedbackMidi(pan_midi);}
|
|
|
+ if (param.is(tilt_midi.value) ){feedbackMidi(tilt_midi);}
|
|
|
+ if (param.is(zoom_midi.value) ){feedbackMidi(zoom_midi);}
|
|
|
+ if (param.is(focus_midi.value) ){feedbackMidi(focus_midi);}
|
|
|
+ if (param.is(dimmer_midi.value) ){feedbackMidi(dimmer_midi);}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+ This function, if you declare it, will launch a timer at 50hz, calling this method on each tick
|
|
|
+*/
|
|
|
+
|
|
|
+function update(deltaTime)
|
|
|
+{
|
|
|
+ script.log("Update : "+util.getTime()+", delta = "+deltaTime);
|
|
|
+}
|
|
|
+*/
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ The "local" variable refers to the object containing the scripts. In this case, the local variable refers to the module.
|
|
|
+ It means that you can access any control inside this module by accessing it through its address.
|
|
|
+ For instance, if the module has a float value named "Density", you can access it via local.values.density
|
|
|
+ Then you can retrieve its value using local.values.density.get() and change its value using local.values.density.set()
|
|
|
+*/
|
|
|
+
|
|
|
+
|
|
|
+ This function will be called each time a parameter of this module has changed, meaning a parameter or trigger inside the "Parameters" panel of this module
|
|
|
+ This function only exists because the script is in a module
|
|
|
+*/
|
|
|
+function moduleParameterChanged(param)
|
|
|
+{
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+ This function will be called each time a value of this module has changed, meaning a parameter or trigger inside the "Values" panel of this module
|
|
|
+ This function only exists because the script is in a module
|
|
|
+*/
|
|
|
+function moduleValueChanged(value)
|
|
|
+{
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+MIDI Modules have specific methods that can be used to send MIDI events such as noteOn, noteOff, controlChange and sysEx messages from Script.
|
|
|
+If you want to send a MIDI event from this script, you can do the following :
|
|
|
+
|
|
|
+local.sendNoteOn(1, 12, 127);
|
|
|
+local.sendNoteOff(1, 12);
|
|
|
+local.sendCC(3, 20, 65);
|
|
|
+local.sendSysEx(15,20,115,10);
|
|
|
+local.sendSysEx(15,20,115,10);
|
|
|
+*/
|
|
|
+
|
|
|
+
|
|
|
+You can intercept MIDI Events with the functions below
|
|
|
+*/
|
|
|
+
|
|
|
+function noteOnEvent(channel, pitch, velocity)
|
|
|
+{
|
|
|
+ script.log("Note on received "+channel+", "+pitch+", "+velocity);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+function noteOffEvent(channel, pitch, velocity)
|
|
|
+{
|
|
|
+ script.log("Note off received "+channel+", "+pitch+", "+velocity);
|
|
|
+}
|
|
|
+
|
|
|
+function ccEvent(channel, number, value)
|
|
|
+{
|
|
|
+
|
|
|
+ var ccChannel = updateCC(number, value);
|
|
|
+ if (ccChannel){updateFloat(ccChannel);}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+function sysExEvent(data)
|
|
|
+{
|
|
|
+ script.log("Sysex Message received, "+data.length+" bytes :");
|
|
|
+ for(var i=0; i < data.length; i++)
|
|
|
+ {
|
|
|
+ script.log(" > "+data[i]);
|
|
|
+ }
|
|
|
+}
|