Bindings Class
Provides access to Cantabile's binding points.
Access this object via the Cantabile#bindings property.
class Bindings extends EndPoint {
getAvailableBindingPoints(): Promise<BindingPointEntry[]>;
getBindingPointInfo(bindingPoint: BindingPoint, source: boolean): Promise<BindingPointInfo>;
invoke(bindingPoint: BindingPoint, value: Object): Promise<void>;
query(bindingPoint: BindingPoint): Promise<Object>;
watch(bindingPoint: BindingPoint, callback?: BindingWatcherCallback): BindingWatcher;
prepare(bindingPoint: BindingPoint): PreparedBindingPoint;
}
#Methods
#getAvailableBindingPoints()
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
getAvailableBindingPoints(): Promise<BindingPointEntry[]>;
Example
console.log(await C.bindings.getAvailableBindingPoints());
#getBindingPointInfo()
Retrieves additional information about a specific binding point
getBindingPointInfo(bindingPoint: BindingPoint, source: boolean): Promise<BindingPointInfo>;
-
bindingPointthe binding point to be queried -
sourcewhether to return information about the source or target version of the binding point
Example
console.log(await C.bindings.getBindingPointInfo("setList", "loadSongByProgram", false, {}, {}));
#invoke()
Invokes a target binding point
If Cantabile is running on your local machine a full list of available binding points is available here
invoke(bindingPoint: BindingPoint, value: Object): Promise<void>;
-
bindingPointThe binding point to invoke -
valueThe value to pass to the binding point
Example
// Set the master output level gain
C.bindings.invoke({
bindableId: "masterLevels",
bindingPointId: "outputGain"
}, 0.5);
Example
// Suspend the 2nd plugin in the song
C.bindings.invoke({
bindableId: "indexedPlugin",
bindableParams: {
rackIndex: 0, // 0 = song, 1 = first rack, 2 = second etc...
pluginIndex: 1, // 1 = second plugin (zero based)
}
bindingPointId: "suspend"
}, true);
Example
// Sending a MIDI Controller Event
C.bindings.invoke({
bindableId: "midiPorts",
bindingPointId: "out.Main Keyboard",
bindingPointParams: {
kind: "Controller",
controller: 10,
channel: 0
}
}, 65);
Example
// Sending MIDI Data directly
C.bindings.invoke({
bindiableId: "midiPorts",
bindingPointId: "out.Main Keyboard"
}, [ 0xb0, 23, 99 ]);
Example
// Sending MIDI Sysex Data directly
C.bindings.invoke({
bindiableId: "midiPorts",
bindingPointId: "out.Main Keyboard"
}, [ 0xF7, 0x00, 0x00, 0x00, 0xF0 ]);
#prepare()
Prepares a target binding point for multiple invocations
prepare(bindingPoint: BindingPoint): PreparedBindingPoint;
bindingPointThe binding point to invoke
#query()
Queries a source binding point for it's current value.
query(bindingPoint: BindingPoint): Promise<Object>;
bindingPointThe binding point to query
Example
console.log("Current Output Gain:", await C.bindings.query({
bindableId: "masterLevels",
bindingPointId: "outputGain"
}));
#watch()
Starts watching a source binding point for changes (or invocations)
watch(bindingPoint: BindingPoint, callback?: BindingWatcherCallback): BindingWatcher;
-
bindingPointThe binding point to watch -
callbackOptional callback function to be called when the source binding triggers
Example
// Using a callback function:
C.bindings.watch({
bindableId: "masterLevels",
bindingPointId: "outputGain",
}, (value) => console.log("Master output gain changed to:", value));
Example
// Using the BindingWatcher class and events:
let watcher = C.bindings.watch({
bindableId: "masterLevels",
bindingPointId: "outputGain",
});
watcher.on('invoked', function(value) {
console.log("Master output gain changed to:", value);
});
/// later, stop listening
watcher.unwatch();
Example
// Watching for a MIDI event:
C.bindings.watch({
bindableId: "midiPorts",
bindingPointId: "in.Onscreen Keyboard",
bindingPointParams: {
channel: 0,
kind: "ProgramChange",
controller: -1,
}, (value) => console.log("Program Change: ", value));
Example
// Watching for a keystroke:
C.bindings.watch({
bindableId: "pckeyboard",
bindingPointId: "keyPress",
bindingPointParams: {
key: "Ctrl+Alt+M"
},
}, () => console.log("Key press!"));