|
@@ -1,173 +0,0 @@
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- This templates shows what you can do in this is module script
|
|
|
- All the code outside functions will be executed each time this script is loaded, meaning at file load, when hitting the "reload" button or when saving this file
|
|
|
-*/
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-var myFloatParam = script.addFloatParameter("My Float Param","Description of my float param",.1,0,1);
|
|
|
-var LSB;
|
|
|
-var MSB;
|
|
|
-
|
|
|
-
|
|
|
-var myTrigger = script.addTrigger("My Trigger", "Trigger description");
|
|
|
-var myBoolParam = script.addBoolParameter("My Bool Param","Description of my bool param",false);
|
|
|
-var myFloatParam = script.addFloatParameter("My Float Param","Description of my float param",.1,0,1);
|
|
|
-var myIntParam = script.addIntParameter("My Int Param","Description of my int param",2,0,10);
|
|
|
-var myStringParam = script.addStringParameter("My String Param","Description of my string param", "cool");
|
|
|
-var myColorParam = script.addColorParameter("My Color Param","Description of my color param",0xff0000ff);
|
|
|
-var myP2DParam = script.addPoint2DParameter("My P2D Param","Description of my p2d param");
|
|
|
-var myP3DParam = script.addPoint3DParameter("My P3D Param","Description of my p3d param");
|
|
|
-var myTargetParam = script.addTargetParameter("My Target Param","Description of my target param");
|
|
|
-var myEnumParam = script.addEnumParameter("My Enum Param","Description of my enum param",
|
|
|
- "Option 1", 1,
|
|
|
- "Option 2", 5,
|
|
|
- "Option 3", "banana"
|
|
|
- );
|
|
|
-*/
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- The init() function will allow you to init everything you want after the script has been checked and loaded
|
|
|
- WARNING it also means that if you change values of your parameters by hand and set their values inside the init() function, they will be reset to this value each time the script is reloaded !
|
|
|
-*/
|
|
|
-function init()
|
|
|
-{
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
- This function will be called each time a parameter of your script has changed
|
|
|
-*/
|
|
|
-function scriptParameterChanged(param)
|
|
|
-{
|
|
|
-
|
|
|
- script.log("Parameter changed : "+param.name);
|
|
|
- if(param.is(myTrigger)) script.log("Trigger !");
|
|
|
- else if(param.is(myEnumParam)) script.log("Label = "+param.get()+", data = "+param.getData());
|
|
|
- else script.log("Value is "+param.get());
|
|
|
- if (param.name == "myFloatParam"){
|
|
|
- script.log("sending back");
|
|
|
- var ccValue = param.get()*16383;
|
|
|
- MSB = Math.floor(ccValue/128);
|
|
|
- MSB=Math.round(MSB);
|
|
|
- LSB = Math.floor(ccValue % 128);
|
|
|
- MSB=Math.round(MSB);
|
|
|
- LSB=Math.round(LSB);
|
|
|
- script.log(MSB+ " "+ LSB);
|
|
|
- local.sendCC(channel, 0, MSB);
|
|
|
- local.sendCC(channel, 32, LSB);
|
|
|
-
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
- 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)
|
|
|
-{
|
|
|
- if(param.isParameter())
|
|
|
- {
|
|
|
- script.log("Module parameter changed : "+param.name+" > "+param.get());
|
|
|
- }else
|
|
|
- {
|
|
|
- script.log("Module parameter triggered : "+value.name);
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
- 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)
|
|
|
-{
|
|
|
- if(value.isParameter())
|
|
|
- {
|
|
|
- script.log("Module value changed : "+value.name+" > "+value.get());
|
|
|
- }else
|
|
|
- {
|
|
|
- script.log("Module value triggered : "+value.name);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-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)
|
|
|
-{
|
|
|
- script.log("ControlChange received "+channel+", "+number+", "+value);
|
|
|
-
|
|
|
- local.sendCC(channel, number, value);
|
|
|
- if(number==0){
|
|
|
- MSB = value;
|
|
|
- myFloatParam.set((128*MSB+LSB)/16384.0);
|
|
|
- }
|
|
|
- if(number==32){
|
|
|
- LSB = value;
|
|
|
- myFloatParam.set((128*MSB+LSB)/16384.0);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-function sysExEvent(data)
|
|
|
-{
|
|
|
- script.log("Sysex Message received, "+data.length+" bytes :");
|
|
|
- for(var i=0; i < data.length; i++)
|
|
|
- {
|
|
|
- script.log(" > "+data[i]);
|
|
|
- }
|
|
|
-}
|