Midi

Module containing all MIDI constants and functionality available in the WebAudioAPI library.

Members

static, constant MidiCommand :Object.<string, number>

Object representing a mapping between a General MIDI command and its protocol value.

static, constant MidiInstrument :Object.<string, number>

Object representing a mapping between a General MIDI instrument and its patch number.

Methods

static getMidiChannel(midiData) → {number}

Returns the MIDI channel target for the command specified in midiData.

Parameters:
Name Type Description
midiData Array.<number>

Data array containing raw MIDI event data

Returns:
number -

MIDI channel target specified in midiData

static getMidiCommand(midiData) → {number}

Returns a value representing the MIDI command in the specified midiData.

Parameters:
Name Type Description
midiData Array.<number>

Data array containing raw MIDI event data

Returns:
number -

MIDI command specified in the corresponding midiData

See:

static getMidiCommandString(midiData) → {string}

Returns a string representing the MIDI command in the specified midiData.

The returned string can be used to index into the MidiCommand map object.

Parameters:
Name Type Description
midiData Array.<number>

Data array containing raw MIDI event data

Returns:
string -

String representing the MIDI command in the specified midiData

See:

static getMidiInstrumentChange(midiData) → {number}

Returns the target MIDI instrument patch value for the MIDI channel indicated in the specified midiData parameter.

Parameters:
Name Type Description
midiData Array.<number>

Data array containing raw MIDI event data

Returns:
number -

Target MIDI instrument patch value for the specified MIDI channel

See:

static getMidiInstrumentChangeString(midiData) → {string}

Returns the target MIDI instrument for the MIDI channel indicated in the specified midiData parameter.

The returned string can be used to index into the MidiInstrument map object.

Parameters:
Name Type Description
midiData Array.<number>

Data array containing raw MIDI event data

Returns:
string -

Target MIDI instrument name for the specified MIDI channel

See:

static getMidiNote(midiData) → {number}

Returns the MIDI note corresponding to the NoteOn or NoteOff command in the specified midiData parameter.

Parameters:
Name Type Description
midiData Array.<number>

Data array containing raw MIDI event data

Returns:
number -

MIDI note corresponding to the relevant midiData command

static getMidiPitchBend(midiData, maxPitchBendNumSemitones) → {number}

Returns a scaler value by which the fundamental frequency of the unbent MIDI note should be multiplied in order to output to the correct frequency.

Parameters:
Name Type Description
midiData Array.<number>

Data array containing raw MIDI event data

maxPitchBendNumSemitones number

Absolute maximum number of semitones to which a note can be bent

Returns:
number -

Frequency scaler by which the unbent fundamental frequency should be multiplied

static getMidiProgramChange(midiData) → {number}

Returns the target program number for the MIDI channel specified in midiData.

Parameters:
Name Type Description
midiData Array.<number>

Data array containing raw MIDI event data

Returns:
number -

Target program number for the specified MIDI channel

static getMidiVelocity(midiData) → {number}

Returns the note velocity corresponding to the NoteOn or NoteOff command in the specified midiData parameter. This velocity will be in the range from [0.0, 1.0].

Parameters:
Name Type Description
midiData Array.<number>

Data array containing raw MIDI event data

Returns:
number -

Note velocity for a MIDI note in the range [0.0, 1.0]