Bindings
Provides access to Cantabile's binding points.
Access this object via the bindings property.
Table of Contents
Methods
Retrieves a list of available binding points
If Cantabile is running on your local machine you can view this list directly at http://localhost:35007/api/bindings/availableBindingPoints
Returns:
A promise to return an array of BindingPointInfo
Example:
let C = new CantabileApi();
C.connect();
console.log(await C.bindings.availableBindingPoints());
close
()
invoke
-
name
-
value
-
indicies
-
parameter
Invokes a target binding point
If Cantabile is running on your local machine a full list of available binding points is available here
Parameters:
-
name
StringThe name of the binding point to invoke
-
[value]
Object optionalThe value to pass to the binding point
-
[indicies]
Number[] optionalThe integer indicies of the target binding point
-
[parameter]
Object optionalThe parameter value to invoke the target with
Returns:
A promise that resolves once the target binding point has been invoked
Example:
Set the master output level gain
C.bindings.invoke("global.masterLevels.outputGain", 0.5);
Suspend the 2nd plugin in the song
C.bindings.invoke("global.indexedPlugin.suspend", true, [
0, // Rack index (zero = song)
1 // Plugin index (zero based, 1 = the second plugin)
]);
Sending a MIDI Controller Event
C.bindings.invoke("midiInputPort.Main Keyboard", new {
kind: "FineController",
controller: 10,
value: 1000,
});
Sending MIDI Data directly
C.bindings.invoke("midiInputPort.Main Keyboard", [ 0xb0, 23, 99 ]);
Sending MIDI Sysex Data directly
C.bindings.invoke("midiInputPort.Main Keyboard", [ 0xF7, 0x00, 0x00, 0x00, 0xF0 ]);
Some binding points expect a "parameter" value. Parameter values are similar to the value
parameter
in that they specify a value to invoke on the target of the binding. The difference is related to the
way they're managed internally for user created bindings. The value
comes from the source of the binding
whereas a parameter
value is stored with the binding itself.
eg: Load the song with program number 12
C.bindings.invoke("global.setList.loadSpecificSongByProgramInstant", null, null, 12);
open
()
query
-
name
-
indicies
Queries a source binding point for it's current value.
If Cantabile is running on your local machine a full list of available binding points is available here
Parameters:
-
name
StringThe name of the binding point to query
-
[indicies]
Number[] optionalThe integer indicies of the binding point
Returns:
The current value of the binding source
Example:
console.log("Current Output Gain:", await C.bindings.query("global.masterLevels.outputGain"));
untilOpen
()
Promise
Returns:
Example:
let C = new CantabileApi();
C.application.open();
await C.application.untilOpen();
Starts watching a source binding point for changes (or invocations)
If Cantabile is running on your local machine a full list of available binding points is available here
Parameters:
-
name
StringThe name of the binding point to query
-
[indicies]
Number[] optionalThe integer indicies of the binding point
-
[condition]
Object optionalThe condition for triggering the binding
-
[callback]
Function optionalOptional callback function to be called when the source binding triggers
The callback function has the form function(resolved, source) where resolved is the resolved display string and source is the BindingWatcher instance.
Returns:
Example:
Using a callback function:
let C = new CantabileApi();
// Watch a source binding point using a callback function
C.bindings.watch("global.masterLevels.outputGain", null, null, function(value) {
console.log("Master output gain changed to:", value);
})
// The "bindings" end point must be opened before callbacks will happen
C.bindings.open();
Using the BindingWatcher class and events:
let C = new CantabileApi();
let watcher = C.bindings.watch("global.masterLevels.outputGain");
watcher.on('invoked', function(value) {
console.log("Master output gain changed to:", value);
});
// The "bindings" end point must be opened before callbacks will happen
C.bindings.open();
/// later, stop listening
watcher.unwatch();
Watching for a MIDI event:
C.bindings.watch("midiInputPort.Onscreen Keyboard", null, {
channel: 0,
kind: "ProgramChange",
controller: -1,
}, function(value) {
console.log("Program Change: ", value);
})
Watching for a keystroke:
C.bindings.watch("global.pckeyboard.keyPress", null, "Ctrl+Alt+M", function() {
console.log("Key press!");
})