User Tools

This is an old revision of the document!


Chataigne

GrandMa2 fader automation

module.json

	{
	"name":"GrandMa2Msc",
	"type":"MIDI",
	"path":"Hardware",

	"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"
	]
}

sequence mapping filter

Create a custom variable group named “Execs” first.

function fixedIt(precision, value, num) {
  var num = "" + (Math.round(value * Math.pow(10, precision)));
  //return num.substring(0, num.length - precision) + "." + num.substring(num.length - precision, num.length);
  return "0."+num.substring(num.length - precision, num.length);
}

function faderToHex(fader_value) {
  var temp_coarse = fader_value * 1.28;
  var coarse = parseInt(Math.floor(temp_coarse));
  var coarse_hex = Integer.toHexString(coarse);
  if (coarse < 16) coarse_hex = "0"+ coarse_hex;

  //var coarse_decimals = (temp_coarse %1).toFixed(2);
  var coarse_decimals = parseFloat(fixedIt(2,temp_coarse %2));
  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
  }
}

function filter(inputValue, min, max) {
  var hex_values = faderToHex(Math.abs(inputValue[0]));

  var parameter_name = script.getParent().getParent().getParent().getParent().getParent().name;

  //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);
  var param = root.customVariables.execs.variables.getChild(parameter_name+ "_coarse");
  param.set(hex_values.coarse);

  root.customVariables.execs.variables.addStringParameter(parameter_name+ "_fine","Hex fine value of mapping "+parameter_name,hex_values.coarse);
  var param = root.customVariables.execs.variables.getChild(parameter_name+ "_fine");
  param.set(hex_values.fine);

  return inputValue;
}

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