forked from justinlatimer/node-midi
-
Notifications
You must be signed in to change notification settings - Fork 7
/
midi.d.ts
91 lines (81 loc) · 3.22 KB
/
midi.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/// <reference types="node" />
import { Stream } from 'stream';
import { EventEmitter } from 'events';
/**
* An array of numbers corresponding to the MIDI bytes: [status, data1, data2].
* See https://www.cs.cf.ac.uk/Dave/Multimedia/node158.html for more info.
*/
export type MidiMessage = number[];
export type MidiCallback = (deltaTime: number, message: MidiMessage) => void;
export class Input extends EventEmitter {
constructor()
/** Close the midi port */
closePort(): void;
/** Close and dispose of the midi port */
destroy(): void;
/** Count the available input ports */
getPortCount(): number;
/** Get the name of a specified input port */
getPortName(port: number): string;
isPortOpen(): boolean
/**
* Sysex, timing, and active sensing messages are ignored by default. To
* enable these message types, pass false for the appropriate type in the
* function below. Order: (Sysex, Timing, Active Sensing) For example if
* you want to receive only MIDI Clock beats you should use
* input.ignoreTypes(true, false, true)
*/
ignoreTypes(sysex: boolean, timing: boolean, activeSensing: boolean): void;
/** Open the specified input port */
openPort(port: number): void;
/** Open the specified input port */
openPortByName(name: string): void;
/**
* Instead of opening a connection to an existing MIDI device, on Mac OS X
* and Linux with ALSA you can create a virtual device that other software
* may connect to. This can be done simply by calling
* openVirtualPort(portName) instead of openPort(portNumber).
*/
openVirtualPort(port: string): void;
on(event: 'message', callback: MidiCallback): this;
/**
* Set the size of the internal buffer used to cache incoming MIDI messages.
* The default size is 2048 bytes. The count parameter specifies the number
* of messages the buffer can hold. If count is not specified, it defaults
* to 4.
*/
setBufferSize(size: number, count?: number): void;
}
export class Output {
constructor()
/** Close the midi port */
closePort(): void;
/** Close and dispose of the midi port */
destroy(): void;
/** Count the available output ports */
getPortCount(): number;
/** Get the name of a specified output port */
getPortName(port: number): string;
isPortOpen(): boolean
/** Open the specified output port */
openPort(port: number): void;
/** Open the specified output port */
openPortByName(name: string): void;
/**
* Instead of opening a connection to an existing MIDI device, on Mac OS X
* and Linux with ALSA you can create a virtual device that other software
* may connect to. This can be done simply by calling
* openVirtualPort(portName) instead of openPort(portNumber).
*/
openVirtualPort(port: string): void;
/** Send a MIDI message */
send(message: MidiMessage): void;
/** Send a MIDI message */
sendMessage(message: MidiMessage): void;
}
/** @deprecated */
export const input: typeof Input;
/** @deprecated */
export const output: typeof Output;
export function createReadStream(input?: Input): Stream;
export function createWriteStream(output?: Output): Stream;