shimi
Version:
A JS framework for building complex MIDI applications
238 lines (237 loc) • 9.38 kB
TypeScript
/**
* IMidiMessage defines an interface which all MIDI message objects should implement in order to be widely useable with the MIDI inputs/outputs that consume them.
*
* @category Midi IO
*/
export interface IMidiMessage {
/** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */
get typeName(): string;
/**
* The toArray method converts a MIDI message object into it's byte-array form which can be sent through a MIDI port to a connected piece of MIDI technology.
*/
toArray(): number[];
/**
* The duplicate method returns an exact copy of the MIDI message object on which it was called.
*/
duplicate(): IMidiMessage;
}
/**
* @category Midi IO
*/
export declare abstract class MidiMessageBase {
protected validateIntInRange(value: number, min: number, max: number, name: string): number;
}
/**
* The NoteOffMessage class represents a Note Off MIDI message that can be sent to a MIDI output.
*
* @category Midi IO
*/
export declare class NoteOffMessage extends MidiMessageBase implements IMidiMessage {
/** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */
get typeName(): string;
/** Acceptable values range from 0 to 127. */
pitch: number;
/** Acceptable values range from 0 to 127. */
velocity: number;
/** Acceptable values range from 0 to 15. */
channel: number;
/**
* @param pitch Acceptable values range from 0 to 127. Alternatively the pitch can be supplied by name.
* @param velocity Acceptable values range from 0 to 127.
* @param channel Acceptable values range from 0 to 15.
*/
constructor(pitch: number | string, velocity: number, channel: number);
toArray(): number[];
duplicate(): NoteOffMessage;
}
/**
* The NoteOnMessage class represents a Note On MIDI message that can be sent to a MIDI output.
*
* @category Midi IO
*/
export declare class NoteOnMessage extends MidiMessageBase implements IMidiMessage {
/** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */
get typeName(): string;
/** Acceptable values range from 0 to 127. */
pitch: number;
/** Acceptable values range from 0 to 127. */
velocity: number;
/** Acceptable values range from 0 to 15. */
channel: number;
/**
* @param pitch Acceptable values range from 0 to 127. Alternatively the pitch can be supplied by name.
* @param velocity Acceptable values range from 0 to 127.
* @param channel Acceptable values range from 0 to 15.
*/
constructor(pitch: number | string, velocity: number, channel: number);
toArray(): number[];
duplicate(): NoteOnMessage;
}
/**
* The NotePressureMessage class represents a Note Pressure MIDI message that can be sent to a MIDI output.
*
* @category Midi IO
*/
export declare class NotePressureMessage extends MidiMessageBase implements IMidiMessage {
/** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */
get typeName(): string;
/** Acceptable values range from 0 to 127. */
pitch: number;
/** Acceptable values range from 0 to 127. */
velocity: number;
/** Acceptable values range from 0 to 15. */
channel: number;
/**
* @param pitch Acceptable values range from 0 to 127. Alternatively the pitch can be supplied by name.
* @param velocity Acceptable values range from 0 to 127.
* @param channel Acceptable values range from 0 to 15.
*/
constructor(pitch: number | string, velocity: number, channel: number);
toArray(): number[];
duplicate(): NotePressureMessage;
}
/**
* The ControlChangeMessage class represents a Control Change MIDI message that can be sent to a MIDI output.
*
* @category Midi IO
*/
export declare class ControlChangeMessage extends MidiMessageBase implements IMidiMessage {
/** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */
get typeName(): string;
/** Acceptable values range from 0 to 127. */
controller: number;
/** Acceptable values range from 0 to 127. */
value: number;
/** Acceptable values range from 0 to 15. */
channel: number;
/**
* @param controller Acceptable values range from 0 to 127.
* @param value Acceptable values range from 0 to 127.
* @param channel Acceptable values range from 0 to 15.
*/
constructor(controller: number, value: number, channel: number);
toArray(): number[];
duplicate(): ControlChangeMessage;
}
/**
* The ProgramChangeMessage class represents a Program Change MIDI message that can be sent to a MIDI output.
*
* @category Midi IO
*/
export declare class ProgramChangeMessage extends MidiMessageBase implements IMidiMessage {
/** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */
get typeName(): string;
/** Acceptable values range from 0 to 127. */
program: number;
/** Acceptable values range from 0 to 15. */
channel: number;
/**
* @param program Acceptable values range from 0 to 127.
* @param channel Acceptable values range from 0 to 15.
*/
constructor(program: number, channel: number);
toArray(): number[];
duplicate(): ProgramChangeMessage;
}
/**
* The ChannelPressureMessage class represents a Channel Pressure MIDI message that can be sent to a MIDI output.
*
* @category Midi IO
*/
export declare class ChannelPressureMessage extends MidiMessageBase implements IMidiMessage {
/** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */
get typeName(): string;
/** Acceptable values range from 0 to 127. */
value: number;
/** Acceptable values range from 0 to 15. */
channel: number;
/**
* @param value Acceptable values range from 0 to 127.
* @param channel Acceptable values range from 0 to 15.
*/
constructor(value: number, channel: number);
toArray(): number[];
duplicate(): ChannelPressureMessage;
}
/**
* The PitchBendMessage class represents a Pitch Bend MIDI message that can be sent to a MIDI output.
*
* @category Midi IO
*/
export declare class PitchBendMessage extends MidiMessageBase implements IMidiMessage {
/** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */
get typeName(): string;
/** Acceptable values range from -1 to +1, with 0 being no bend. */
percent: number;
/** Acceptable values range from 0 to 15. */
channel: number;
/**
* @param percent Acceptable values range from -1 to +1, with 0 being no bend.
* @param channel Acceptable values range from 0 to 15.
*/
constructor(percent: number, channel: number);
toArray(): number[];
duplicate(): PitchBendMessage;
/** Takes in the LSB & MSB values of the pitch bend MIDI message and returns a number in range [-1, +1] */
static calculatePercent(lsb: number, msb: number): number;
}
/**
* The TickMessage class represents a Timing Clock MIDI message that can be sent to a MIDI output.
*
* @category Midi IO
*/
export declare class TickMessage implements IMidiMessage {
/** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */
get typeName(): string;
constructor();
toArray(): number[];
duplicate(): TickMessage;
}
export declare class SongPositionMessage implements IMidiMessage {
/** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */
get typeName(): string;
/** The number of MIDI ticks that have occured since the start of the song, divided by 6. */
value: number;
/**
* @param value The number of MIDI ticks that have occured since the start of the song, divided by 6.
*/
constructor(value: number);
toArray(): number[];
duplicate(): SongPositionMessage;
}
/**
* The StartMessage instructs a listening MIDI device to start its current sequence playing from the start.
*
* @category Midi IO
*/
export declare class StartMessage implements IMidiMessage {
/** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */
get typeName(): string;
constructor();
toArray(): number[];
duplicate(): StartMessage;
}
/**
* The ContinueMessage instructs a listening MIDI device to continue playing its current sequence.
*
* @category Midi IO
*/
export declare class ContinueMessage implements IMidiMessage {
/** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */
get typeName(): string;
constructor();
toArray(): number[];
duplicate(): ContinueMessage;
}
/**
* The StopMessage instructs a listeneing MIDI device to stop playing its current sequence.
*
* @category Midi IO
*/
export declare class StopMessage implements IMidiMessage {
/** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */
get typeName(): string;
constructor();
toArray(): number[];
duplicate(): StopMessage;
}