Specify a range for triggering scripts with MIDI Controllers
At the moment when using CCs to trigger scripts (or to use as inputs to scripts) your choices are individual CCs on a channel or all of them.
It'd be useful to specify a range of CCs instead of creating multiple individual triggers.
So something like "CC#s 22 - 36".
- JJudson Crane @Judson_Crane
just reactivated my account after a few months away and disappointed to find the first thing I wanted to do doesn't seem possible. I'd like to specify a certain cc VALUE for the trigger... ie cc 110 at a value of 1 for one trigger, and a value of 2 for another trigger... is this not possible? Thank you-
Chris Shaw @Chris_Shaw2024-01-04 17:10:53.781Z2024-01-04 17:25:10.179Z
Hey @Judson_Crane,
The best way to do this would be to create individual scripts or macros that you'd like to be triggered by specific CC values (don't assign any triggers to these scripts/macros), then use a separate script with a midi input / CC assigned as a trigger to trigger those individual scripts.
Something like this should do it:/* Ex: event.trigger.midiBytes = [177, 1 , 38] the three numbers are MIDI Channel, CC#, and CC Value */ //de-structure values from midi byte values array let [channel, ccNumber, ccValue] = event.trigger.midiBytes // Command / Script / Macro table const commands = { 10: { commandName:"Toggle Transport Window", commandID:"user:ckp49i4j60000a2100yfwywgf:cku7r4tjf00070t10edyt27kp#ckshbw2fk001nfp10lxc9v2n4", }, 60: { commandName:"Toggle Big Counter Window", commandID:"user:ckp49i4j60000a2100yfwywgf:cku7r4tjf00070t10edyt27kp#ckshbw2fk001afp104ur18p32", }, } // Trigger command if (commands[ccValue]) { let commandToRun = commands[ccValue].commandID sf.soundflow.runCommand({ // SF Script / Macro ID commandId: commandToRun }) }
Trigger the above script with the CC control you'd like to use like this:
When the script is triggered via MIDI the MIDI bytes are passed via
event.trigger.midiBytes
.
This script takes extracts the ccValue from the MIDI input and uses it to look up the command to be triggered via thecommands
object.if a ccValue matches the key to a command then the command/macro/script will be triggered.
Just add entries to the
command
object for any command you'd like to use.
(thecommandName
property isn't used in the script. I added it just for labeling purposes).You can get the command id by selecting the script/macro in the SF editor and selecting "Command > Command ID" from the SF Editor menu.
Chris Shaw @Chris_Shaw2024-01-04 17:56:16.290Z
If editing the
command
object seems daunting you could also do this:/* event.trigger.midiBytes = [177, 1 , 38] the three numbers are MIDI Channel, CC#, and CC Value */ //destructure values from midi byte values let [channel, ccNumber, ccValue] = event.trigger.midiBytes // Trigger commands if (ccValue == 10) { sf.soundflow.runCommand({ // SF Script / Macro ID commandId: "user:ckp49i4j60000a2100yfwywgf:cku7r4tjf00070t10edyt27kp#ckshbw2fk001nfp10lxc9v2n4" // toggle transport window }) } if (ccValue == 60) { sf.soundflow.runCommand({ // SF Script / Macro ID commandId: "user:ckp49i4j60000a2100yfwywgf:cku7r4tjf00070t10edyt27kp#ckshbw2fk001afp104ur18p32" // toggle BIg Counter window }) } if (ccValue == 90){ log ("hey, the CC value is 60") } if (ccValue == 127){ log ("CC value is as high as it gets: 127") } if (ccValue == 0){ log ("CC value is as low as it gets: 0") }
- JIn reply toChris_Shaw⬆:Judson Crane @Judson_Crane
ah good stuff, thank you!! Would be good to get cc value added to the trigger eventually, but this seems like a good work around for now. Thanks!!