///
import { EventEmitter } from 'events';
declare type NoteEventType = 'keyDown' | 'keyUp';
declare type PedalEventType = 'pedalDown' | 'pedalUp';
declare type ConnectionEventType = 'connect' | 'disconnect';
interface DeviceData {
id: string;
manufacturer: string;
name: string;
}
interface MidiEvent {
device: DeviceData;
}
interface NoteEvent extends MidiEvent {
note: string;
midi: number;
velocity: number;
}
declare type ConditionalEmitter = EventType extends PedalEventType ? MidiEvent : EventType extends ConnectionEventType ? DeviceData : EventType extends NoteEventType ? NoteEvent : unknown;
declare type ConditionalListener = (e: ConditionalEmitter) => void;
export declare class MidiInput extends EventEmitter {
/**
* The device ID string. If set to 'all', will listen
* to all MIDI inputs. Otherwise will filter a specific midi device
*/
deviceId: string | 'all';
constructor(deviceId?: string | 'all');
/**
* Attach listeners to the device when it's connected
*/
private _addListeners;
private _inputToDevice;
/**
* Internal call to remove all event listeners associated with the device
*/
private _removeListeners;
emit(event: EventType, data: ConditionalEmitter): boolean;
on(event: EventType, listener: ConditionalListener): this;
once(event: EventType, listener: ConditionalListener): this;
off(event: EventType, listener: ConditionalListener): this;
private static connectedDevices;
private static _isEnabled;
/**
* Resolves when the MIDI Input is enabled and ready to use
*/
static enabled(): Promise;
/**
* Get a list of devices that are currently connected
*/
static getDevices(): Promise;
}
export {};