User Tools

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
chataigne [2023/02/03 03:24] – created ssm2017chataigne [2023/02/17 17:54] (current) – [Values in script] ssm2017
Line 1: Line 1:
 ====== Chataigne ====== ====== Chataigne ======
-===== GrandMa2 fader automation ===== +===== object ======
-==== midi module script ====+
 <sxh js> <sxh js>
-function init() {} +var myObject { 
- +  "myprop1":"value", 
-var params_container script.addContainer("Parameters"); +  "myprop2":"second", 
-var log_data = params_container.addBoolParameter("LogData""Choose if you want to see a translation of the sysex", false); +  "myMethod"function(params) { 
-var faders_container = script.addContainer("Faders"); +    this.myprop1 params[0]; 
- +  }
-function sysExEvent(data) { +
- parseSysex(data); +
-+
- +
-function logData(data) { +
- script.log("-------- sysex message start ---------"); +
- script.log("universal_sysex > "+ data[0]); +
- script.log("device_id > "+ data[1]); +
- script.log("msc > "+ data[2]); +
- script.log("command_format > "+ data[3]); +
- script.log("command > "+ data[4]); +
- script.log("fader > "+ data[5]); +
- script.log("fader_page > "+ data[6]); +
- script.log("fine_value > "+ data[7]); +
- script.log("coarse_value > "+ data[8]); +
- script.log("-------- sysex message end ---------"); +
-+
- +
-function hexToFader(coarse, fine) { +
-  return Math.floor(((fine / 128) + coarse) / 1.28); +
-+
- +
-function parseSysex(data) { +
- if (data[4] == 6) { +
- if (log_data.get())logData(data); +
-  +
- var fader_level = hexToFader(data[8], data[7]); +
- +
- var parameter_name = "FaderValue"+data[5]; +
- faders_container.addFloatParameter(parameter_name,"Value of the fader Exec "+data[5],fader_level,0,100); +
- var param = faders_container.getChild(parameter_name); +
- param.set(fader_level); +
- +
- /*if (typeof param === "void") { +
- script.log("Creating the fader parameter."); +
- faders_container.addFloatParameter(parameter_name,"Value of the fader Exec "+data[5],fader_level,0,100)+
- +
- else { +
- param.set(fader_level); +
- }*/ +
- }+
 } }
 +var my_instance = new myObject();
 +script.log(my_instance.myprop1);
 +my_instance.mymethod(["test","one","two"]);
 +script.log(my_instance.myprop1);
 </sxh> </sxh>
-==== sequence mapping filter ==== +===== Values in script ===== 
-Create custom variable group named "Execsfirst.+When adding value parameter in a module, only the parameter is saved between sessions/projects. If you want to keep the value content, use setAttribute("saveValueOnly",false)
 <sxh js> <sxh js>
-function fixedIt(precision, value, num{ +var mycontainer = local.values.addContainer("toto"); 
-  var num = "" + (Math.round(value * Math.pow(10precision))); +var myint1 mycontainer.addIntParameter("myint", "",1,1,65536); 
-  //return num.substring(0num.length - precision+ "." + num.substring(num.length - precision, num.length); +myint1.setAttribute("saveValueOnly",false); 
-  return "0."+num.substring(num.length - precision, num.length);+</sxh> 
 +===== Custom variables ===== 
 +<sxh js> 
 +function getCustomVariablesGroup(nameshortname
 +  var my_group = root.customVariables.getItemWithName(shortname); 
 +  if (my_group.name != shortname) { 
 +    // build a new group 
 +    my_group = root.customVariables.addItem(shortname); 
 +    my_group.setName(name)
 +  } 
 +  return my_group;
 } }
  
-function faderToHex(fader_value) { +/** 
-  var temp_coarse fader_value * 1.28+ * Set or create then set the custom variable value 
-  var coarse parseInt(Math.floor(temp_coarse))+ * @param {int} page_id  
-  var coarse_hex Integer.toHexString(coarse); + * @param {int} exec_id  
-  if (coarse < 16) coarse_hex = "0"+ coarse_hex;+ * @param {int} value  
 + * @param {string} type  
 + * @param {string} item_nice_name  
 + */ 
 +function setCustomVariablesValue(page_id, exec_id, value, type, item_nice_name) { 
 +  // build names 
 +  var shortname "exec"+ page_id+ "_"+ exec_id
 +  var name "Exec "+ page_id+ "_"+ exec_id; 
 +  // get the group 
 +  var my_group getCustomVariablesGroup(name, shortname); 
 +  // define the item type 
 +  var item_name = type; 
 +  var item_type = "Int"
 +  var int_max = 100;
  
-  //var coarse_decimals = (temp_coarse %1).toFixed(2); +  if (["Go""Stop", "Resume", "Off"].contains(type)) { 
-  var coarse_decimals = parseFloat(fixedIt(2,temp_coarse %2)); +    item_type = "Bool";
-  var temp_fine = coarse_decimals * 128; +
-  var fine = parseInt(Math.floor(temp_fine)); +
-  var fine_hex = Integer.toHexString(fine); +
-  if (fine < 16) fine_hex = "0"+ fine_hex; +
- +
-  return { +
-    'coarse': ""+coarse, +
-    'fine': ""+fine+
   }   }
-}+  // build some names 
 +  var my_value = {}
 +  var my_value_name = "exec"+ page_id+ "_"+exec_id+ item_name; 
 +  var my_value_nice_name = "Exec "+ page_id+ "_"+ exec_id+ " "+ item_nice_name;
  
-function filter(inputValue, min, max{ +  var my_value_item = my_group.variables.getItemWithName(my_value_name); 
-  var hex_values faderToHex(Math.abs(inputValue[0]));+  if (my_value_item.name !my_value_name) { 
 +    // create if not exist 
 +    my_value_item = my_group.variables.addItem(item_type+ " Parameter"); 
 +    my_value = my_value_item.getChild(my_value_item.name)
 +    my_value.setName(my_value_nice_name);
  
-  var parameter_name = script.getParent().getParent().getParent().getParent().getParent().name+    if (["CueMsb", "CueLsb"].contains(type)) 
- +      int_max = 999
-  //root.customVariables.execs.variables.addStringParameter(parameter_name+ "_coarse","Hex coarse value of mapping "+parameter_name,hex_values.coarse); +    } 
-  root.customVariables.execs.variables.addStringParameter(parameter_name+ "_coarse","Hex coarse value of mapping "+parameter_name,hex_values.coarse); +    if (["Hour", "Minute", "second"].contains(type)) { 
-  var param = root.customVariables.execs.variables.getChild(parameter_name+ "_coarse"); +      int_max = 60
-  param.set(hex_values.coarse); +    } 
- +    if (!["Go", "Stop", "Resume", "Off"].contains(type)) { 
-  root.customVariables.execs.variables.addStringParameter(parameter_name+ "_fine","Hex fine value of mapping "+parameter_name,hex_values.coarse); +      my_value.setRange(0,int_max); 
-  var param = root.customVariables.execs.variables.getChild(parameter_name+ "_fine"); +    } 
-  param.set(hex_values.fine); +  
- +  else { 
-  return inputValue;+    my_value = my_value_item.getChild(my_value_item.name); 
 +  } 
 +  if (["Go", "Stop", "Resume", "Off"].contains(type)) { 
 +    my_value.set(true); 
 +    my_value.set(false); 
 +  
 +  else { 
 +    my_value.set(value); 
 +  } 
 +  my_group.variables.reorderItems();
 } }
 </sxh> </sxh>

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also, you acknowledge that you have read and understand our Privacy Policy. If you do not agree, please leave the website.

More information