OnscreenKeyboard Class

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

Access this object via the Cantabile#onscreenKeyboard property.

class OnscreenKeyboard extends EndPoint {
    queryController(channel: number, kind: MidiControllerKind, controller: number): Promise<number>;
    watch(channel: number, kind: MidiControllerKind, controller: number, callback?: ControllerWatcherCallback): ControllerWatcher;
    injectMidi(data: object): void;
}

#Methods

#injectMidi()

Inject MIDI from the on-screen keyboard device

injectMidi(data: object): void;
  • data An array of bytes or a MidiControllerEvent

Example

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

Example

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

#queryController()

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

queryController(channel: number, kind: MidiControllerKind, controller: number): Promise<number>;
  • channel The MIDI channel number of the controller

  • kind The MIDI controller kind

  • controller The number of the controller

Example

// Get the value of cc 64 on channel 1
console.log(await C.onscreenKeyboard.queryController(1, "controller", 64));

Example

C.onscreenKeyboard.queryController(1, "controller", 64).then(r => console.log(r)));

#watch()

Starts watching a controller for changes

watch(channel: number, kind: MidiControllerKind, controller: number, callback?: ControllerWatcherCallback): ControllerWatcher;
  • channel The MIDI channel number of the controller

  • kind The MIDI controller kind

  • controller The number of the controller

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

Example

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

Example

// Using the ControllerWatcher class and events:
let watcher = C.onscreenKeyboard.watchController(1, "controller", 64);
watcher.on('changed', function(value) {
    console.log(value);
});

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