Namespace: CONNECTION_EVENTS

CONNECTION_EVENTS

Connection event constants for device connection/disconnection events. Use these constants when listening for MIDI device state changes.
Properties:
Name Type Default Description
DEVICE_CHANGE string "device-change" Emitted when any MIDI device state changes (connect/disconnect)
IN_DEV_CONNECTED string "in-dev-connected" Emitted when an input device is connected
IN_DEV_DISCONNECTED string "in-dev-disconnected" Emitted when an input device is disconnected
OUT_DEV_CONNECTED string "out-dev-connected" Emitted when an output device is connected
OUT_DEV_DISCONNECTED string "out-dev-disconnected" Emitted when an output device is disconnected
Source:

Examples

connection.on(CONNECTION_EVENTS.DEVICE_CHANGE, ({ port, state, type, device }) => {
  console.log(`${device.name} ${state}`);
});

connection.on(CONNECTION_EVENTS.OUT_DEV_CONNECTED, ({ device }) => {
  console.log(`Output connected: ${device.name}`);
});
// Using the short alias (CONN)
connection.on(CONN.DEVICE_CHANGE, ({ device, state }) => {
  console.log(`${device.name} ${state}`);
});