Show:
Extends EndPoint

Provides access to controllers managed by Cantabile's on-screen keyboard device

Access this object via the onscreenKeyboard property.

Methods

close ()

Inherited from EndPoint: EndPoint.js:55

Closes the end point and stops listening for events.

This method no longer needs to be explicitly called as end points are now automatically closed when the last event listener is removed.

injectMidi
(
  • data
)

Inject MIDI from the on-screen keyboard device

Parameters:

  • data Object

    An array of bytes or a MidiControllerEvent

Example:

Using a callback function:

// Send a note on event
C.onscreenKeyboard.inject([0x90, 64, 64]);

Using the MidiControllerEvent

// Send Midi CC 23 = 127
let watcher = C.onscreenKeyboard.inject({
     channel: 0,
     kind: "controller",
     controller: 23,
     value: 127,
});
open ()

Inherited from EndPoint: EndPoint.js:35

Opens this end point and starts listening for events.

This method no longer needs to be explicitly called as end points are now automatically opened when the first event listener is attached.

Use this method to keep the end point open even when no event listeners are attached.

queryController
(
  • channel
  • kind
  • controller
)
Promise | String

Queries the on-screen keyboard for the current value of a controller

Parameters:

  • channel Number

    The MIDI channel number of the controller

  • kind String

    The MIDI controller kind

  • controller Number

    The number of the controller

Returns:

Promise | String:

A promise to provide the controller value

Example:

   // Get the value of cc 64 on channel 1
let C = new CantabileApi();
console.log(await C.onscreenKeyboard.queryController(1, "controller", 64));
let C = new CantabileApi();
C.onscreenKeyboard.queryController(1, "controller", 64).then(r => console.log(r)));
untilOpen () Promise

Inherited from EndPoint: EndPoint.js:137

Returns a promise that will be resolved when this end point is opened

Returns:

Promise

Example:

let C = new CantabileApi();
   C.application.open();
await C.application.untilOpen();
watch
(
  • channel
  • kind
  • controller
  • callback
)
ControllerWatcher

Starts watching a controller for changes

Parameters:

  • channel Number

    The MIDI channel number of the controller

  • kind String

    The MIDI controller kind

  • controller Number

    The number of the controller

  • [callback] Function optional

    Optional callback function to be called when the controller value changes.

    The callback function has the form function(value, source) where value is the controller value and source is the ControllerWatcher instance.

Example:

Using a callback function:

let C = new CantabileApi();

// Watch a controller using a callback function
C.onscreenKeyboard.watchController(1, "controller", 64, function(value) {
    console.log(value);
})

   // The "onscreenKeyboard" end point must be opened before callbacks will happen
C.onscreenKeyboard.open();

Using the ControllerWatcher class and events:

let C = new CantabileApi();
let watcher = C.onscreenKeyboard.watchController(1, "controller", 64);
watcher.on('changed', function(value) {
    console.log(value);
});

// The "onscreenKeyboard" end point must be opened before callbacks will happen
C.onscreenKeyboard.open();

/// later, stop listening
watcher.unwatch();