chataigne
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| chataigne [2023/02/04 03:30] – [module.json] ssm2017 | chataigne [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":" | + | "myprop1":" |
| - | "type":" | + | "myprop2":" |
| - | "path":" | + | "myMethod": |
| - | + | this.myprop1 = params[0]; | |
| - | " | + | } |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | + | ||
| - | " | + | |
| - | " | + | |
| - | + | ||
| - | " | + | |
| - | " | + | |
| - | { | + | |
| - | " | + | |
| - | { | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | } | + | |
| - | }, | + | |
| - | " | + | |
| - | { | + | |
| - | " | + | |
| - | }, | + | |
| - | " | + | |
| - | [ | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | ], | + | |
| - | " | + | |
| - | [ | + | |
| - | " | + | |
| - | ], | + | |
| - | " | + | |
| - | { | + | |
| - | " | + | |
| - | { | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | { | + | |
| - | " | + | |
| - | { | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | }, | + | |
| - | " | + | |
| - | { | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | }, | + | |
| - | " | + | |
| - | { | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | " | + | |
| - | } | + | |
| - | } | + | |
| - | } | + | |
| - | } | + | |
| - | } | + | |
| } | } | ||
| + | var my_instance = new myObject(); | ||
| + | script.log(my_instance.myprop1); | ||
| + | my_instance.mymethod([" | ||
| + | script.log(my_instance.myprop1); | ||
| </ | </ | ||
| - | ==== module | + | ===== Values in script ===== |
| + | When adding a value parameter in a module, only the parameter is saved between sessions/ | ||
| <sxh js> | <sxh js> | ||
| - | /** | + | var mycontainer = local.values.addContainer(" |
| - | * Vanilla JUCE JS doesn' | + | var myint1 = mycontainer.addIntParameter(" |
| - | * So we need to make our own to get around the floating point math errors causing glitches | + | myint1.setAttribute(" |
| - | * @author : DJSTech + ssm2017 | + | </sxh> |
| - | * @link : https:// | + | ===== Custom variables ===== |
| - | * @param {int} precision | + | <sxh js> |
| - | * @param {float} value | + | function |
| - | * @returns {float} | + | var my_group |
| - | */ | + | |
| - | function | + | // build a new group |
| - | var num = "" | + | my_group = root.customVariables.addItem(shortname); |
| - | | + | my_group.setName(name); |
| + | } | ||
| + | return my_group; | ||
| } | } | ||
| /** | /** | ||
| - | | + | |
| - | * @param {*} coarse (coarse value (byte 8)) | + | * @param {int} page_id |
| - | * @param {*} fine (fine value (byte 7)) | + | * @param {int} exec_id |
| - | * @returns | + | * @param {int} value |
| + | * @param {string} type | ||
| + | * @param {string} item_nice_name | ||
| */ | */ | ||
| - | function | + | function |
| - | | + | // build names |
| - | //return (((fine / 128) + coarse) / 1.28); | + | var shortname = " |
| - | } | + | var name = "Exec "+ page_id+ " |
| + | // get the group | ||
| + | var my_group = getCustomVariablesGroup(name, shortname); | ||
| + | | ||
| + | var item_name = type; | ||
| + | var item_type = " | ||
| + | var int_max = 100; | ||
| - | /** | + | |
| - | * Set the fader level if the param exists or create the param if not exists. | + | |
| - | * @param {int} exec_page | + | |
| - | * @param {int} exec_id (the fader id in the page (byte 5)) | + | |
| - | * @param {float} fader_level (the level of the fader (see: hex2FaderLevel function)) | + | |
| - | */ | + | |
| - | function setFaderParamLevel(exec_page, | + | |
| - | var param_name = "faderPage"+ exec_page+ | + | |
| - | //var param = script.params.getChild(param_name); | + | |
| - | //var param = local.parameters.getChild(param_name); | + | |
| - | var param = local.values.getChild(param_name); | + | |
| - | if (typeof param === "void") { | + | |
| - | // | + | |
| - | // | + | |
| - | | + | |
| } | } | ||
| - | | + | |
| - | | + | var my_value = {}; |
| - | | + | |
| - | } | + | var my_value_nice_name = "Exec "+ page_id+ " |
| - | /** | + | var my_value_item = my_group.variables.getItemWithName(my_value_name); |
| - | * Display the sysex data with translation in the log | + | |
| - | * @param {array} data (the sysex message as array of bytes) | + | // create if not exist |
| - | */ | + | my_value_item = my_group.variables.addItem(item_type+ |
| - | function logSysex(data) { | + | |
| - | script.log("-------- sysex message start ---------"); | + | |
| - | script.log("0 universal_sysex > "+ data[0]); | + | |
| - | script.log("1 device_id > "+ data[1]); | + | if (["CueMsb", |
| - | script.log("2 msc > "+ data[2]); | + | int_max = 999; |
| - | script.log("3 command_format > "+ data[3]); | + | } |
| - | script.log("4 command > "+ data[4]); | + | if (["Hour", " |
| - | // if this is a goto message (go) | + | int_max = 60; |
| - | if (data[4] == 1) { | + | } |
| - | | + | if (![" |
| + | | ||
| + | } | ||
| } | } | ||
| - | | + | |
| - | if (data[4] == 2) { | + | |
| - | | + | |
| } | } | ||
| - | | + | if ([" |
| - | if (data[4] == 3) { | + | |
| - | | + | my_value.set(false); |
| } | } | ||
| - | | + | |
| - | if (data[4] == 4) { | + | |
| - | | + | |
| } | } | ||
| - | | + | |
| - | if (data[4] == 6) { | + | |
| - | script.log("5 exec > "+ data[5]); | + | |
| - | script.log(" | + | |
| - | script.log(" | + | |
| - | script.log(" | + | |
| - | } | + | |
| - | // if this is a macro trigger message (fire) | + | |
| - | if (data[4] == 7) { | + | |
| - | script.log(" | + | |
| - | } | + | |
| - | // if this is a off message (go_off) | + | |
| - | if (data[4] == 10 || data[4] == 11) { | + | |
| - | script.log(" | + | |
| - | } | + | |
| - | script.log(" | + | |
| - | } | + | |
| - | + | ||
| - | /** | + | |
| - | * Parse received data and fill parameters | + | |
| - | * @param {array} data (sysex data received knowing that the first (f0) and the last one (f7) are truncated) | + | |
| - | */ | + | |
| - | function parseSysex(data) { | + | |
| - | // check if data is a fader move | + | |
| - | if (data[4] == 6) { | + | |
| - | var fader_level = hex2FaderLevel(data[8], | + | |
| - | setFaderParamLevel(data[6], | + | |
| - | } | + | |
| - | } | + | |
| - | + | ||
| - | /** | + | |
| - | * Get the page and exec id from parameter name | + | |
| - | * @param {string} param_name | + | |
| - | * @returns {array} 0=page / 1=fader | + | |
| - | */ | + | |
| - | function getFaderIdFromParamName(param_name) { | + | |
| - | var strings = param_name.replace(" | + | |
| - | return [parseInt(strings[0]), | + | |
| - | } | + | |
| - | + | ||
| - | /** | + | |
| - | * Get coarse and fine values to be sent to sysex | + | |
| - | * @param {float} fader_value | + | |
| - | * @returns {array} 0=coarse / 1=fine | + | |
| - | */ | + | |
| - | function parseFaderValueToCoarseFine(fader_value) { | + | |
| - | var temp_coarse = fader_value * 1.28; | + | |
| - | var coarse = parseInt(Math.floor(temp_coarse)); | + | |
| - | var coarse_decimals = parseFloat(fixedIt(2, | + | |
| - | var temp_fine = coarse_decimals * 128; | + | |
| - | var fine = parseInt(Math.floor(temp_fine)); | + | |
| - | return [coarse, fine]; | + | |
| - | } | + | |
| - | + | ||
| - | /** | + | |
| - | * Build the sysex output and send it to move the selected fader | + | |
| - | * @param {int} execId | + | |
| - | * @param {int} pageId | + | |
| - | * @param {float} fader_value | + | |
| - | */ | + | |
| - | function sendFaderSysex(execId, | + | |
| - | // workaround for an error when loading the module without parameter defined ? no, need to find something | + | |
| - | script.log(" | + | |
| - | if (typeof fader_value === array) return; | + | |
| - | // send sysex | + | |
| - | var sysex = [127, | + | |
| - | sysex[5] = execId; | + | |
| - | sysex[6] = pageId; | + | |
| - | var coarse_fine = parseFaderValueToCoarseFine(fader_value); | + | |
| - | sysex[7] = coarse_fine[1]; | + | |
| - | sysex[8] = coarse_fine[0]; | + | |
| - | local.sendSysex(sysex[0], | + | |
| - | } | + | |
| - | + | ||
| - | /** | + | |
| - | * Chataigne event triggered when receiving sysex data | + | |
| - | * @param {array} data (sysex data received) | + | |
| - | */ | + | |
| - | function sysExEvent(data) { | + | |
| - | if (local.parameters.moduleParameters.logSysex.get())logSysex(data); | + | |
| - | parseSysex(data); | + | |
| - | } | + | |
| - | + | ||
| - | /** | + | |
| - | * Chataigne event triggered when a script parameter value has changed | + | |
| - | * @param {object} param | + | |
| - | */ | + | |
| - | function moduleParameterChanged(param) { | + | |
| - | var index = getFaderIdFromParamName(param.name); | + | |
| - | sendFaderSysex(index[1], | + | |
| } | } | ||
| </ | </ | ||
chataigne.1675477845.txt.gz · Last modified: by ssm2017
