User Tools

Site Tools


chataigne

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
chataigne [2023/02/04 02:24] – [midi module script] ssm2017chataigne [2023/02/17 17:54] (current) – [Values in script] ssm2017
Line 1: Line 1:
 ====== Chataigne ====== ====== Chataigne ======
-===== GrandMa2 fader automation ===== +===== object ======
-==== module.json ====+
 <sxh js> <sxh js>
- +var myObject = 
- "name":"GrandMa2Msc", +  "myprop1":"value", 
- "type":"MIDI", +  "myprop2":"second", 
- "path":"Hardware", +  "myMethod": function(params) 
- +    this.myprop1 = params[0]; 
- "version":"0.0.1", +  }
- "description":"Chataigne script to record and play grandma2 msc events", +
- "url":"https://github.com/ssm2017/chataigne_grandma2msc", +
- "downloadURL":"Chataigne script to record and play grandma2 msc events", +
- +
- "hasInput":true, +
- "hasOutput":true,  +
- +
- "hideDefaultCommands":true, +
- "parameters": +
- +
- "Module parameters": +
-+
- "type":"Container", +
- "collapsed":false, +
- "LogSysex":{"type":"Boolean", "description":"Choose if you want to see a translation of the sysex.\nThe script logs must be activated.", "default":false} +
-+
- }, +
- "defaults": +
-+
- "autoAdd":false +
- }, +
- "hideDefaultParameters": +
- [ +
- "autoAdd", +
- "autoFeedback", +
- "infos", +
- "tempo", +
- "MTC" +
- ], +
- "scripts": +
-+
- "grandma2msc.js" +
- ]+
 } }
 +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>
chataigne.1675473856.txt.gz · Last modified: by ssm2017