shimi
Version:
A JS framework for building complex MIDI applications
120 lines (119 loc) • 7.34 kB
TypeScript
import * as messages from './MidiMessages';
import ShimiEvent, { ShimiEventData } from './ShimiEvent';
/**
* The MidiInEventData class extends ShimiEventData. It contains a reference to the source IMidiIn that created the event data, as well as information about a MIDI message that has been received.
*
* @category Midi IO
*/
export declare class MidiInEventData<TMessage> extends ShimiEventData<IMidiIn> {
/** The MIDI message that has been received. */
get message(): TMessage;
private _message;
constructor(source: IMidiIn, message: TMessage);
}
/**
* The MidiInEvent class extends ShimiEvent, providing an object which can be subscribed to.
*
* It distributes events which point back to the source IMidiIn, along with a MidiInEventData object that contains the event information.
*
* @category Midi IO
*/
export declare class MidiInEvent<TMessage> extends ShimiEvent<MidiInEventData<TMessage>, IMidiIn> {
}
/**
* The MidiIn class is an implementation of IMidiIn, which receives MIDI messages from a connected MIDI port and distributes in a more easily consumable format.
*
* @category Midi IO
*/
export default class MidiIn implements IMidiIn {
/** Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable. */
get typeName(): string;
/**
* The MIDI port which data gets received from, see the MidiAccess class.
*
* Setting this property automatically unsubscribes from any previously connected MIDI port, and also automatically subscribes to the newly set MIDI port.
*/
get port(): any;
set port(value: any);
private _port;
/** The noteOff property can be subscribed to, to receive all Note Off messages that pass through the MidiIn object. */
get noteOff(): MidiInEvent<messages.NoteOffMessage>;
private _noteOff;
/** The noteOn property can be subscribed to, to receive all Note On messages that pass through the MidiIn object. */
get noteOn(): MidiInEvent<messages.NoteOnMessage>;
private _noteOn;
/** The notePressure property can be subscribed to, to receive all Note Pressure messages that pass through the MidiIn object. */
get notePressure(): MidiInEvent<messages.NotePressureMessage>;
private _notePressure;
/** The controlChange property can be subscribed to, to receive all Control Change messages that pass through the MidiIn object. */
get controlChange(): MidiInEvent<messages.ControlChangeMessage>;
private _controlChange;
/** The programChange property can be subscribed to, to receive all Program Change messages that pass through the MidiIn object. */
get programChange(): MidiInEvent<messages.ProgramChangeMessage>;
private _programChange;
/** The channelPressure property can be subscribed to, to receive all Channel Pressure messages that pass through the MidiIn object. */
get channelPressure(): MidiInEvent<messages.ChannelPressureMessage>;
private _channelPressure;
/** The pitchBend property can be subscribed to, to receive all Pitch Bend messages that pass through the MidiIn object. */
get pitchBend(): MidiInEvent<messages.PitchBendMessage>;
private _pitchBend;
/** The tick property can be subscribed to, to receive all timing clock messages that pass through the MidiIn object. */
get tick(): MidiInEvent<messages.TickMessage>;
private _tick;
/** The songPosition property can be subscribed to, to receive all Song Position messages that pass through the MidiIn object. */
get songPosition(): MidiInEvent<messages.SongPositionMessage>;
private _songPosition;
/** The start property can be subscribed to, to receive all Start messages that pass through the MidiIn object. */
get start(): MidiInEvent<messages.StartMessage>;
private _start;
/** The continue property can be subscribed to, to receive all Continue messages that pass through the MidiIn object. */
get continue(): MidiInEvent<messages.ContinueMessage>;
private _continue;
/** The stop property can be subscribed to, to receive all Stop messages that pass through the MidiIn object. */
get stop(): MidiInEvent<messages.StopMessage>;
private _stop;
/**
* @param port The MIDI port which data gets received from, see the MidiAccess class.
*/
constructor(port?: any);
private _previousStatus;
private _receiveMessage;
receiveData(data: number[]): void;
}
/**
* IMidiIn defines an interface for any MIDI object which other shimi objects can receive MIDI data from.
*
* @category Midi IO
*/
export interface IMidiIn {
/**
* The receiveData method allows for raw MIDI message data to be passed in, which will then be analysed, and trigger an event for whichever MIDI event type it corresponds to.
*
* @param data The data parameter should be a MIDI-compliant byte-array, see here for more information [Summary of MIDI 1.0 Messages](https://www.midi.org/specifications-old/item/table-1-summary-of-midi-message).
*/
receiveData(data: number[]): void;
/** The noteOff property can be subscribed to, to receive all Note Off messages that pass through the MidiIn object. */
get noteOff(): MidiInEvent<messages.NoteOffMessage>;
/** The noteOn property can be subscribed to, to receive all Note On messages that pass through the MidiIn object. */
get noteOn(): MidiInEvent<messages.NoteOnMessage>;
/** The notePressure property can be subscribed to, to receive all Note Pressure messages that pass through the MidiIn object. */
get notePressure(): MidiInEvent<messages.NotePressureMessage>;
/** The controlChange property can be subscribed to, to receive all Control Change messages that pass through the MidiIn object. */
get controlChange(): MidiInEvent<messages.ControlChangeMessage>;
/** The programChange property can be subscribed to, to receive all Program Change messages that pass through the MidiIn object. */
get programChange(): MidiInEvent<messages.ProgramChangeMessage>;
/** The channelPressure property can be subscribed to, to receive all Channel Pressure messages that pass through the MidiIn object. */
get channelPressure(): MidiInEvent<messages.ChannelPressureMessage>;
/** The pitchBend property can be subscribed to, to receive all Pitch Bend messages that pass through the MidiIn object. */
get pitchBend(): MidiInEvent<messages.PitchBendMessage>;
/** The tick property can be subscribed to, to receive all Timing Clock messages that pass through the MidiIn object. */
get tick(): MidiInEvent<messages.TickMessage>;
/** The songPosition property can be subscribed to, to receive all Song Position messages that pass through the MidiIn object. */
get songPosition(): MidiInEvent<messages.SongPositionMessage>;
/** The start property can be subscribed to, to receive all Start messages that pass through the MidiIn object. */
get start(): MidiInEvent<messages.StartMessage>;
/** The continue property can be subscribed to, to receive all Continue messages that pass through the MidiIn object. */
get continue(): MidiInEvent<messages.ContinueMessage>;
/** The stop property can be subscribed to, to receive all Stop messages that pass through the MidiIn object. */
get stop(): MidiInEvent<messages.StopMessage>;
}