|
@@ -1,15 +1,28 @@
|
|
|
+
|
|
|
+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 };
|
|
|
+
|
|
|
+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};
|
|
|
|
|
|
var delCue_Trigger = script.addTrigger("clear cues", "clear all cues in the timeline");
|
|
|
var clearTL_Trigger = script.addTrigger("clear timeline", "clear all cues and keys in the timeline");
|
|
|
+var createKeyGroup_Trigger = script.addTrigger("create group","create key group @ current time");
|
|
|
+var createKeyGroupInOut_Trigger = script.addTrigger("create InOut group","create key group @ current time and key group ten seconds later, with constant values inbetween");
|
|
|
|
|
|
var myFile = script.addFileParameter("textFile", "this is a text file");
|
|
|
var myTrigger = script.addTrigger("My Trigger", "Trigger description");
|
|
|
|
|
|
var tl_keyframes = {cues : {}, keys : {}} ;
|
|
|
-var tl_refresh_rate = 0.5;
|
|
|
+
|
|
|
+var tl_groups = {groups: 0
|
|
|
+
|
|
|
+ outCue : {pan : "key", tilt : "key", zoom : "key", dim : "key", focus : "key"}
|
|
|
+ }*/
|
|
|
+ } ;
|
|
|
|
|
|
var file_keyframes = {groups : 0} ;
|
|
|
-
|
|
|
+var myFloatParam = script.addFloatParameter("My Float Param","Description of my float param",.1,0,1);
|
|
|
|
|
|
|
|
|
|
|
@@ -32,10 +45,35 @@ var myEnumParam = script.addEnumParameter("My Enum Param","Description of my enu
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+function checkAxe(CC){
|
|
|
+ if(CC==pan_midi.channel || CC==pan_midi.channel+32){
|
|
|
+ return pan_midi;
|
|
|
+ }
|
|
|
+ else return 0;
|
|
|
+}
|
|
|
+
|
|
|
+function updateAxe(axe, CC, value){
|
|
|
+ if(CC==axe.channel){
|
|
|
+ axe.MSB = value;
|
|
|
+
|
|
|
+ }
|
|
|
+ if(CC==axe.channel+32){
|
|
|
+ axe.LSB = value;
|
|
|
+
|
|
|
+ }
|
|
|
+ axe.target=(128*axe.MSB+axe.LSB)/16383.0;
|
|
|
+ script.log(axe.target);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+function refresh_tl_keys_list(){
|
|
|
+
|
|
|
|
|
|
-
|
|
|
|
|
|
-function refresh_tl_keys(){
|
|
|
|
|
|
if(root.sequences.keys.cues.items.length){
|
|
|
for (var i = 0 ; i < root.sequences.keys.cues.items.length ; i++){
|
|
@@ -67,6 +105,36 @@ function refresh_tl_keys(){
|
|
|
}
|
|
|
|
|
|
|
|
|
+}
|
|
|
+
|
|
|
+function apply_tl_groups() {
|
|
|
+ if(tl_groups.groups){
|
|
|
+ for(var i=0 ; i<tl_groups.groups ; i++){
|
|
|
+
|
|
|
+ var tempGroup = tl_groups['group'+i];
|
|
|
+ var hasOut= typeof tempGroup.cueOut.pan!='undefined' ;
|
|
|
+ var layers = root.sequences.keys.layers.items ;
|
|
|
+ var inTime = root.sequences.keys.cues[tempGroup.cueIn.cue].time.get();
|
|
|
+ var outTime;
|
|
|
+ if(hasOut){ outTime = root.sequences.keys.cues[tempGroup.cueOut.cue].time.get();}
|
|
|
+ if(layers.length){
|
|
|
+ for(var j = 0 ; j<layers.length ; j++){
|
|
|
+ var tempLayer=layers[j].name;
|
|
|
+ var inKey = tempGroup.cueIn[tempLayer];
|
|
|
+ root.sequences.keys.layers[tempLayer].automation[inKey].position.set(inTime);
|
|
|
+ if (hasOut) {
|
|
|
+ var outKey = tempGroup.cueOut[tempLayer];
|
|
|
+ root.sequences.keys.layers[tempLayer].automation[outKey].position.set(outTime);
|
|
|
+
|
|
|
+ root.sequences.keys.layers[tempLayer].automation[outKey].value.set(root.sequences.keys.layers[tempLayer].automation[inKey].value.get());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
@@ -97,39 +165,71 @@ function clear_tl_keys(){
|
|
|
function clear_tl_full(){
|
|
|
clear_tl_cues();
|
|
|
clear_tl_keys();
|
|
|
+ tl_groups = {groups: 0};
|
|
|
+ myFile.writeFile(JSON.stringify(tl_groups), 1);
|
|
|
}
|
|
|
|
|
|
-function create_keyGroup(){
|
|
|
-
|
|
|
- var groupIndex = file_keyframes.groups;
|
|
|
- script.log(groupIndex);
|
|
|
+function create_keyGroup(mode){
|
|
|
|
|
|
+
|
|
|
var tempValues = {
|
|
|
position: root.sequences.keys.currentTime.get() ,
|
|
|
- pan : root.sequences.keys.layers.pan.mapping.outValue.get(),
|
|
|
- tilt : root.sequences.keys.layers.tilt.mapping.outValue.get(),
|
|
|
- zoom : root.sequences.keys.layers.zoom.mapping.outValue.get(),
|
|
|
- dim : root.sequences.keys.layers.dim.mapping.outValue.get(),
|
|
|
+ pan : root.customVariables.unitValues.variables.pan.pan.get(),
|
|
|
+ tilt : root.customVariables.unitValues.variables.tilt.tilt.get(),
|
|
|
+ zoom : root.customVariables.unitValues.variables.zoom.zoom.get(),
|
|
|
+ dim : root.customVariables.unitValues.variables.dimmer.dimmer.get(),
|
|
|
+ focus: root.customVariables.unitValues.variables.focus.focus.get(),
|
|
|
+ speed : root.customVariables.unitValues.variables.speed.speed.get(),
|
|
|
+
|
|
|
};
|
|
|
+
|
|
|
|
|
|
+
|
|
|
+ var groupIndex = tl_groups.groups;
|
|
|
+ script.log("creating group # : " + groupIndex);
|
|
|
|
|
|
+ tl_groups['group'+groupIndex] ={cueIn: {}};
|
|
|
var inCue = root.sequences.keys.cues.addItem();
|
|
|
inCue.time.set(tempValues.position);
|
|
|
- script.log(inCue.name);
|
|
|
- var outCue = root.sequences.keys.cues.addItem();
|
|
|
- outCue.time.set(tempValues.position+1.);
|
|
|
- script.log(outCue.name);
|
|
|
-
|
|
|
- var groupKeys = {in:{}, out:{}} ;
|
|
|
+ tl_groups['group'+groupIndex].cueIn.cue = inCue.name;
|
|
|
+
|
|
|
+ if(mode){
|
|
|
+ tl_groups['group'+groupIndex].cueOut = {} ;
|
|
|
+ var outCue = root.sequences.keys.cues.addItem();
|
|
|
+ outCue.time.set(tempValues.position+10.);
|
|
|
+ tl_groups['group'+groupIndex].cueOut.cue = outCue.name;
|
|
|
+ }
|
|
|
+
|
|
|
var layers = root.sequences.keys.layers.items ;
|
|
|
if(layers.length){
|
|
|
- for (var i = 0 ; i<layers.length ; i++){
|
|
|
- tempKey = layers[i].automation.addItem();
|
|
|
- tempKey.position.set(tempValues.position);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+ for(var i = 0 ; i<layers.length ; i++){
|
|
|
+ tempKeyIn = root.sequences.keys.layers.items[i].automation.addItem();
|
|
|
+ tempKeyIn.value.set(tempValues[root.sequences.keys.layers.items[i].name]);
|
|
|
+ tempKeyIn.position.set(inCue.time.get());
|
|
|
+ tl_groups['group'+groupIndex].cueIn[root.sequences.keys.layers.items[i].name]=tempKeyIn.name;
|
|
|
+
|
|
|
+ if(mode) {
|
|
|
+ tempKeyOut = root.sequences.keys.layers.items[i].automation.addItem();
|
|
|
+ tempKeyOut.value.set(tempValues[root.sequences.keys.layers.items[i].name]);
|
|
|
+ tempKeyOut.position.set(outCue.time.get());
|
|
|
+ tl_groups['group'+groupIndex].cueOut[root.sequences.keys.layers.items[i].name]=tempKeyOut.name;
|
|
|
+ }
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tl_groups.groups += 1;
|
|
|
+ myFile.writeFile(JSON.stringify(tl_groups), 1);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -142,6 +242,13 @@ function create_keyGroup(){
|
|
|
*/
|
|
|
function init()
|
|
|
{
|
|
|
+ script.log("Reading key group file");
|
|
|
+ tl_groups = JSON.parse(myFile.readFile());
|
|
|
+ script.log (tl_groups.groups);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -165,9 +272,10 @@ function scriptParameterChanged(param)
|
|
|
|
|
|
script.log("Parameter changed : "+param.name);
|
|
|
if(param.is(myTrigger)){
|
|
|
- script.log("Trigger !");
|
|
|
- create_keyGroup();
|
|
|
-
|
|
|
+ script.log(root.sequences.keys.layers.items[0].automation.items.length);
|
|
|
+ for (var j = 0 ; j<root.sequences.keys.layers.items[0].automation.items.length ; j++){
|
|
|
+ script.log(root.sequences.keys.layers.items[0].automation.items[j].name);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
@@ -175,6 +283,12 @@ function scriptParameterChanged(param)
|
|
|
}
|
|
|
else if (param.is(delCue_Trigger)){clear_tl_cues();}
|
|
|
else if (param.is(clearTL_Trigger)){clear_tl_full();}
|
|
|
+ else if (param.is(createKeyGroup_Trigger)){create_keyGroup(0);}
|
|
|
+ else if (param.is(createKeyGroupInOut_Trigger)){create_keyGroup(1);}
|
|
|
+ else if (param.is(myFloatParam)){
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
else if(param.is(myEnumParam)) script.log("Label = "+param.get()+", data = "+param.getData());
|
|
|
|
|
|
|
|
@@ -184,14 +298,15 @@ function scriptParameterChanged(param)
|
|
|
This function, if you declare it, will launch a timer at 50hz, calling this method on each tick
|
|
|
*/
|
|
|
var tl_refresh_delta = 0.;
|
|
|
-
|
|
|
+var tl_refresh_rate = 0.5;
|
|
|
|
|
|
function update(deltaTime)
|
|
|
{
|
|
|
tl_refresh_delta += deltaTime ;
|
|
|
if (tl_refresh_delta > tl_refresh_rate){
|
|
|
tl_refresh_delta = 0. ;
|
|
|
-
|
|
|
+ refresh_tl_keys_list();
|
|
|
+ apply_tl_groups();
|
|
|
|
|
|
}
|
|
|
|
|
@@ -214,13 +329,13 @@ function update(deltaTime)
|
|
|
*/
|
|
|
function moduleParameterChanged(param)
|
|
|
{
|
|
|
- if(param.isParameter())
|
|
|
- {
|
|
|
- script.log("Module parameter changed : "+param.name+" > "+param.get());
|
|
|
- }else
|
|
|
- {
|
|
|
- script.log("Module parameter triggered : "+value.name);
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -229,36 +344,31 @@ function moduleParameterChanged(param)
|
|
|
*/
|
|
|
function moduleValueChanged(value)
|
|
|
{
|
|
|
- if(value.isParameter())
|
|
|
- {
|
|
|
- script.log("Module value changed : "+value.name+" > "+value.get());
|
|
|
- }else
|
|
|
- {
|
|
|
- script.log("Module value triggered : "+value.name);
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-OSC Modules have specific methods that can be used to send OSC message from Script.
|
|
|
-If you want to send an OSC Message from this script, you can do the following :
|
|
|
-
|
|
|
-local.send("/myAddress",1,.5f,"cool");
|
|
|
|
|
|
-*/
|
|
|
-
|
|
|
-You can intercept OSC message with the function oscEvent(address, args)
|
|
|
-*/
|
|
|
+
|
|
|
|
|
|
-function oscEvent(address, args)
|
|
|
+function ccEvent(channel, number, value)
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- script.log("OSC Message received "+address+", "+args.length+" arguments");
|
|
|
- for(var i=0; i < args.length; i++)
|
|
|
- {
|
|
|
- script.log(" > "+args[i]);
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+ local.sendCC(channel, number, value);
|
|
|
+ var currentAxe=checkAxe(number);
|
|
|
+ if (currentAxe){updateAxe(currentAxe, number, value);}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|