new OutputChannel( output, number )

Description

The OutputChannel class represents a single output channel (1-16) from an output device. This object is derived from the host's MIDI subsystem and cannot be instantiated directly.

All 16 OutputChannel objects can be found inside the output's channels property.

The OutputChannel class extends the EventEmitter class from the djipevents module. This means it also includes methods such as addListener(), removeListener(), hasListener() and several others.

Parameters
Name Type Description
output Output

The output this channel belongs to

number number

The channel's number (1-16)

Details

3.0.0

Classes


new OutputChannel( output, number )

Members


number :number

Description

The channel's number (1-16)

Details
number

output :Output

Description

The Output this channel belongs to

Details

Methods


decrementRegisteredParameter( parameter [, options ] ) → {OutputChannel}

Description

Decrements the specified MIDI registered parameter by 1. Here is the full list of parameter names that can be used with this function:

  • Pitchbend Range (0x00, 0x00): "pitchbendrange"
  • Channel Fine Tuning (0x00, 0x01): "channelfinetuning"
  • Channel Coarse Tuning (0x00, 0x02): "channelcoarsetuning"
  • Tuning Program (0x00, 0x03): "tuningprogram"
  • Tuning Bank (0x00, 0x04): "tuningbank"
  • Modulation Range (0x00, 0x05): "modulationrange"
  • Azimuth Angle (0x3D, 0x00): "azimuthangle"
  • Elevation Angle (0x3D, 0x01): "elevationangle"
  • Gain (0x3D, 0x02): "gain"
  • Distance Ratio (0x3D, 0x03): "distanceratio"
  • Maximum Distance (0x3D, 0x04): "maximumdistance"
  • Maximum Distance Gain (0x3D, 0x05): "maximumdistancegain"
  • Reference Distance Ratio (0x3D, 0x06): "referencedistanceratio"
  • Pan Spread Angle (0x3D, 0x07): "panspreadangle"
  • Roll Angle (0x3D, 0x08): "rollangle"
Parameters
Name Type Attributes Default Description
parameter String | Array.<number>

A string identifying the parameter's name (see above) or a two-position array specifying the two control bytes (0x65, 0x64) that identify the registered parameter.

options Object <optional>
{}
Name Type Attributes Description
time number | string <optional>

If time is a string prefixed with "+" and followed by a number, the message will be delayed by that many milliseconds. If the value is a number, the operation will be scheduled for that time. The current time can be retrieved with WebMidi.time. If options.time is omitted, or in the past, the operation will be carried out as soon as possible.

Returns

Returns the OutputChannel object so methods can be chained.

Throws

TypeError The specified registered parameter is invalid.

Details

incrementRegisteredParameter( parameter [, options ] ) → {OutputChannel}

Description

Increments the specified MIDI registered parameter by 1. Here is the full list of parameter names that can be used with this function:

  • Pitchbend Range (0x00, 0x00): "pitchbendrange"
  • Channel Fine Tuning (0x00, 0x01): "channelfinetuning"
  • Channel Coarse Tuning (0x00, 0x02): "channelcoarsetuning"
  • Tuning Program (0x00, 0x03): "tuningprogram"
  • Tuning Bank (0x00, 0x04): "tuningbank"
  • Modulation Range (0x00, 0x05): "modulationrange"
  • Azimuth Angle (0x3D, 0x00): "azimuthangle"
  • Elevation Angle (0x3D, 0x01): "elevationangle"
  • Gain (0x3D, 0x02): "gain"
  • Distance Ratio (0x3D, 0x03): "distanceratio"
  • Maximum Distance (0x3D, 0x04): "maximumdistance"
  • Maximum Distance Gain (0x3D, 0x05): "maximumdistancegain"
  • Reference Distance Ratio (0x3D, 0x06): "referencedistanceratio"
  • Pan Spread Angle (0x3D, 0x07): "panspreadangle"
  • Roll Angle (0x3D, 0x08): "rollangle"
Parameters
Name Type Attributes Default Description
parameter String | Array.<number>

A string identifying the parameter's name (see above) or a two-position array specifying the two control bytes (0x65, 0x64) that identify the registered parameter.

options Object <optional>
{}
Name Type Attributes Description
time number | string <optional>

If time is a string prefixed with "+" and followed by a number, the message will be delayed by that many milliseconds. If the value is a number, the operation will be scheduled for that time. The current time can be retrieved with WebMidi.time. If options.time is omitted, or in the past, the operation will be carried out as soon as possible.

Returns

Returns the OutputChannel object so methods can be chained.

Throws

TypeError The specified registered parameter is invalid.

Details

playNote( note [, options ] ) → {OutputChannel}

Description

Plays a note or an array of notes on the channel. The first parameter is the note to play. It can be a single value or an array of the following valid values:

  • A MIDI note number (integer between 0 and 127)
  • A note name, followed by the octave (e.g. "C3", "G#4", "F-1", "Db7")
  • A Note object

The playNote() method sends a note on MIDI message for all specified notes on all specified channels. If a duration is set in the options parameter or in the Note object's duration property, it will also schedule a note off message to end the note after said duration. If no duration is set, the note will simply play until a matching note off message is sent with stopNote() or sendNoteOff().

The execution of the note on command can be delayed by using the time property of the options parameter.

When using Note objects, the durations and velocities defined in the Note objects have precedence over the ones specified via the method's options parameter.

Note: As per the MIDI standard, a note on message with an attack velocity of 0 is functionally equivalent to a note off message.

Parameters
Name Type Attributes Default Description
note number | string | Note | Array.<number> | Array.<string> | Array.<Note>

The note(s) to play. The notes can be specified by using a MIDI note number (0-127), a note name (e.g. C3, G#4, F-1, Db7), a Note object or an array of the previous types. When using a note name, octave range must be between -1 and 9. The lowest note is C-1 (MIDI note number 0) and the highest note is G9 (MIDI note number 127).

options Object <optional>
{}
Name Type Attributes Default Description
duration number <optional>

A positive number larger than 0 representing the number of milliseconds to wait before sending a note off message. If invalid or left undefined, only a note on message will be sent.

attack number <optional>
0.5

The velocity at which to play the note (between 0 and 1). If the rawAttack option is also defined, it will have priority. An invalid velocity value will silently trigger the default of 0.5.

rawAttack number <optional>
0.5

The attack velocity at which to play the note (between 0 and 127). This has priority over the attack property. An invalid velocity value will silently trigger the default of 0.5.

release number <optional>
0.5

The velocity at which to release the note (between 0 and 1). If the rawRelease option is also defined, it will have priority. An invalid velocity value will silently trigger the default of 0.5. This is only used with the note off event triggered when options.duration is set.

rawRelease number <optional>
0.5

The velocity at which to release the note (between 0 and 127). This has priority over the release property. An invalid velocity value will silently trigger the default of 0.5. This is only used with the note off event triggered when options.duration is set.

time number | string <optional>

If time is a string prefixed with "+" and followed by a number, the message will be delayed by that many milliseconds. If the value is a number, the operation will be scheduled for that time. The current time can be retrieved with WebMidi.time. If options.time is omitted, or in the past, the operation will be carried out as soon as possible.

Returns

Returns the OutputChannel object so methods can be chained.

Details

resetAllControllers( [ options ] ) → {OutputChannel}

Description

Sends a reset all controllers channel mode message. This resets all controllers, such as the pitch bend, to their default value.

Parameters
Name Type Attributes Default Description
options Object <optional>
{}
Name Type Attributes Description
time number | string <optional>

If time is a string prefixed with "+" and followed by a number, the message will be delayed by that many milliseconds. If the value is a number, the operation will be scheduled for that time. The current time can be retrieved with WebMidi.time. If options.time is omitted, or in the past, the operation will be carried out as soon as possible.

Returns

Returns the OutputChannel object so methods can be chained.

Details

send( status [, data [, options ] ] ) → {OutputChannel}

Description

Sends a MIDI message at the scheduled timestamp. It is usually not necessary to use this method directly as you can use one of the simpler helper methods such as playNote(), stopNote(), sendControlChange(), etc.

Details on the format of MIDI messages are available in the summary of MIDI messages from the MIDI Manufacturers Association.

Parameters
Name Type Attributes Default Description
status Number

The MIDI status byte of the message (128-255). This is a combination of the command and the channel.

data Array.<number> <optional>

An array of unsigned integers for the message. The number of data bytes varies depending on the status byte. It is perfectly legal to send no data for some message types (use undefined or an empty array in this case). Each byte must be between 0 and 255.

options Object <optional>
{}
Name Type Attributes Description
time number | string <optional>

If time is a string prefixed with "+" and followed by a number, the message will be delayed by that many milliseconds. If the value is a number, the operation will be scheduled for that time. The current time can be retrieved with WebMidi.time. If options.time is omitted, or in the past, the operation will be carried out as soon as possible.

Returns

Returns the OutputChannel object so methods can be chained.

Throws

Failed to execute 'send' on 'MIDIOutput': The value at index 0 is greater than 0xFF.

Failed to execute 'send' on 'MIDIOutput': The value at index 2 is greater than 0xFF.

Failed to execute 'send' on 'MIDIOutput': Running status is not allowed at index 0.

Failed to execute 'send' on 'MIDIOutput': Message is incomplete.

Failed to execute 'send' on 'MIDIOutput': Reserved status is not allowed at index 0.

Failed to execute 'send' on 'MIDIOutput': System exclusive message is not allowed at index 0.

Failed to execute 'send' on 'MIDIOutput': Unexpected end of system exclusive message at index 0.

Failed to execute 'send' on 'MIDIOutput': Unexpected status byte at index 1.

Failed to execute 'send' on 'MIDIOutput': Unexpected status byte at index 2.

Details

sendChannelMode( command, value [, options ] ) → {OutputChannel}

Description

Sends a MIDI channel mode message. The channel mode message to send can be specified numerically or by using one of the following common names:

  • "allsoundoff" (#120)
  • "resetallcontrollers" (#121)
  • "localcontrol" (#122)
  • "allnotesoff" (#123)
  • "omnimodeoff" (#124)
  • "omnimodeon" (#125)
  • "monomodeon" (#126)
  • "polymodeon" (#127)

It should be noted that, per the MIDI specification, only localcontrol and monomodeon may require a value that's not zero. For that reason, the value parameter is optional and defaults to 0.

To make it easier, all channel mode messages have a matching helper method:

Parameters
Name Type Attributes Default Description
command number | string

The numerical identifier of the channel mode message (integer between 120-127) or its name as a string.

value number

The value to send (integer between 0-127).

options Object <optional>
{}
Name Type Attributes Description
time number | string <optional>

If time is a string prefixed with "+" and followed by a number, the message will be delayed by that many milliseconds. If the value is a number, the operation will be scheduled for that time. The current time can be retrieved with WebMidi.time. If options.time is omitted, or in the past, the operation will be carried out as soon as possible.

Returns

Returns the OutputChannel object so methods can be chained.

Details

sendControlChange( controller, value [, options ] ) → {OutputChannel}

Description

Sends a MIDI control change message to the channel at the scheduled time. The control change message to send can be specified numerically or by using one of the following common names:

  • bankselectcoarse (#0)
  • modulationwheelcoarse (#1)
  • breathcontrollercoarse (#2)
  • footcontrollercoarse (#4)
  • portamentotimecoarse (#5)
  • dataentrycoarse (#6)
  • volumecoarse (#7)
  • balancecoarse (#8)
  • pancoarse (#10)
  • expressioncoarse (#11)
  • effectcontrol1coarse (#12)
  • effectcontrol2coarse (#13)
  • generalpurposeslider1 (#16)
  • generalpurposeslider2 (#17)
  • generalpurposeslider3 (#18)
  • generalpurposeslider4 (#19)
  • bankselectfine (#32)
  • modulationwheelfine (#33)
  • breathcontrollerfine (#34)
  • footcontrollerfine (#36)
  • portamentotimefine (#37)
  • dataentryfine (#38)
  • volumefine (#39)
  • balancefine (#40)
  • panfine (#42)
  • expressionfine (#43)
  • effectcontrol1fine (#44)
  • effectcontrol2fine (#45)
  • holdpedal (#64)
  • portamento (#65)
  • sustenutopedal (#66)
  • softpedal (#67)
  • legatopedal (#68)
  • hold2pedal (#69)
  • soundvariation (#70)
  • resonance (#71)
  • soundreleasetime (#72)
  • soundattacktime (#73)
  • brightness (#74)
  • soundcontrol6 (#75)
  • soundcontrol7 (#76)
  • soundcontrol8 (#77)
  • soundcontrol9 (#78)
  • soundcontrol10 (#79)
  • generalpurposebutton1 (#80)
  • generalpurposebutton2 (#81)
  • generalpurposebutton3 (#82)
  • generalpurposebutton4 (#83)
  • reverblevel (#91)
  • tremololevel (#92)
  • choruslevel (#93)
  • celestelevel (#94)
  • phaserlevel (#95)
  • databuttonincrement (#96)
  • databuttondecrement (#97)
  • nonregisteredparametercoarse (#98)
  • nonregisteredparameterfine (#99)
  • registeredparametercoarse (#100)
  • registeredparameterfine (#101)

Note: as you can see above, not all control change message have a matching common name. This does not mean you cannot use the others. It simply means you will need to use their number instead of their name.

To view a detailed list of all available control change messages, please consult "Table 3 - Control Change Messages" from the MIDI Messages specification.

Parameters
Name Type Attributes Default Description
controller number | string

The MIDI controller name or number (0-119).

value number

The value to send (0-127).

options Object <optional>
{}
Name Type Attributes Description
time number | string <optional>

If time is a string prefixed with "+" and followed by a number, the message will be delayed by that many milliseconds. If the value is a number, the operation will be scheduled for that time. The current time can be retrieved with WebMidi.time. If options.time is omitted, or in the past, the operation will be carried out as soon as possible.

Returns

Returns the OutputChannel object so methods can be chained.

Throws

Controller numbers must be between 0 and 119.

Invalid controller name.

Details

sendNoteOff( note [, options ] ) → {OutputChannel}

Description

Sends a note off message for the specified notes on the channel. The first parameter is the note. It can be a single value or an array of the following valid values:

  • A MIDI note number (integer between 0 and 127)
  • A note name, followed by the octave (e.g. "C3", "G#4", "F-1", "Db7")
  • A Note object

The execution of the note off command can be delayed by using the time property of the options parameter.

When using Note objects, the release velocity defined in the Note objects has precedence over the one specified via the method's options parameter.

Parameters
Name Type Attributes Default Description
note number | string | Note | Array.<number> | Array.<string> | Array.<Note>

The note(s) to stop. The notes can be specified by using a MIDI note number (0-127), a note name (e.g. C3, G#4, F-1, Db7), a Note object or an array of the previous types. When using a note name, octave range must be between -1 and 9. The lowest note is C-1 (MIDI note number 0) and the highest note is G9 (MIDI note number 127).

options Object <optional>
{}
Name Type Attributes Default Description
time number | string <optional>

If time is a string prefixed with "+" and followed by a number, the message will be delayed by that many milliseconds. If the value is a number, the operation will be scheduled for that time. The current time can be retrieved with WebMidi.time. If options.time is omitted, or in the past, the operation will be carried out as soon as possible.

release number <optional>
0.5

The velocity at which to release the note (between 0 and 1). If the rawRelease option is also defined, rawRelease will have priority. An invalid velocity value will silently trigger the default of 0.5.

rawRelease number <optional>
64

The velocity at which to release the note (between 0 and 127). If the release option is also defined, rawRelease will have priority. An invalid velocity value will silently trigger the default of 64.

Returns

Returns the OutputChannel object so methods can be chained.

Details

sendNoteOn( note [, options ] ) → {OutputChannel}

Description

Sends a note on message for the specified notes on the channel. The first parameter is the note. It can be a single value or an array of the following valid values:

  • A MIDI note number (integer between 0 and 127)
  • A note name, followed by the octave (e.g. "C3", "G#4", "F-1", "Db7")
  • A Note object

The execution of the note on command can be delayed by using the time property of the options parameter.

When using Note objects, the attack velocity defined in the Note objects has precedence over the one specified via the method's options parameter. Also, the duration is ignored. If you want to also send a note off message, use the playNote() method instead.

Note: As per the MIDI standard, a note on message with an attack velocity of 0 is functionally equivalent to a note off message.

Parameters
Name Type Attributes Default Description
note number | string | Note | Array.<number> | Array.<string> | Array.<Note>

The note(s) to play. The notes can be specified by using a MIDI note number (0-127), a note name (e.g. C3, G#4, F-1, Db7), a Note object or an array of the previous types. When using a note name, octave range must be between -1 and 9. The lowest note is C-1 (MIDI note number 0) and the highest note is G9 (MIDI note number 127).

options Object <optional>
{}
Name Type Attributes Default Description
time number | string <optional>

If time is a string prefixed with "+" and followed by a number, the message will be delayed by that many milliseconds. If the value is a number, the operation will be scheduled for that time. The current time can be retrieved with WebMidi.time. If options.time is omitted, or in the past, the operation will be carried out as soon as possible.

attack number <optional>
0.5

The velocity at which to play the note (between 0 and 1). If the rawAttack option is also defined, rawAttack will have priority. An invalid velocity value will silently trigger the default of 0.5.

rawAttack number <optional>
64

The velocity at which to release the note (between 0 and 127). If the attack option is also defined, rawAttack will have priority. An invalid velocity value will silently trigger the default of 64.

Returns

Returns the OutputChannel object so methods can be chained.

Details

setChannelAftertouch( [ pressure [, options ] ] ) → {OutputChannel}

Description

Sends a MIDI channel aftertouch message. For key-specific aftertouch, you should instead use setKeyAftertouch().

Parameters
Name Type Attributes Default Description
pressure number <optional>

The pressure level (between 0 and 1). If the rawValue option is set to true, the pressure can be defined by using an integer between 0 and 127.

options Object <optional>
{}
Name Type Attributes Default Description
rawValue boolean <optional>
false

A boolean indicating whether the value should be considered a float between 0 and 1.0 (default) or a raw integer between 0 and 127.

time number | string <optional>

If time is a string prefixed with "+" and followed by a number, the message will be delayed by that many milliseconds. If the value is a number, the operation will be scheduled for that time. The current time can be retrieved with WebMidi.time. If options.time is omitted, or in the past, the operation will be carried out as soon as possible.

Returns

Returns the OutputChannel object so methods can be chained.

Throws

RangeError Invalid channel aftertouch value.

Details

setKeyAftertouch( note [, pressure [, options ] ] ) → {OutputChannel}

Description

Sends a MIDI key aftertouch message at the scheduled time. This is a key-specific aftertouch. For a channel-wide aftertouch message, use setChannelAftertouch().

The note can be a single value or an array of the following valid values:

  • A MIDI note number (integer between 0 and 127)
  • A note name, followed by the octave (e.g. "C3", "G#4", "F-1", "Db7")
  • A Note object
Parameters
Name Type Attributes Default Description
note number | string | Note | Array.<number> | Array.<string> | Array.<Note>

The note(s) for which you are sending an aftertouch value. The notes can be specified by using a MIDI note number (0-127), a note name (e.g. C3, G#4, F-1, Db7), a Note object or an array of the previous types. When using a note name, octave range must be between -1 and 9. The lowest note is C-1 (MIDI note number 0) and the highest note is G9 (MIDI note number 127).

pressure number <optional>
0.5

The pressure level (between 0 and 1). An invalid pressure value will silently trigger the default behaviour. If the rawValue option is set to true, the pressure is defined by using an integer between 0 and 127.

options Object <optional>
{}
Name Type Attributes Default Description
useRawValue boolean <optional>
false

A boolean indicating whether the value should be considered a float between 0 and 1.0 (default) or a raw integer between 0 and 127.

time number | string <optional>

If time is a string prefixed with "+" and followed by a number, the message will be delayed by that many milliseconds. If the value is a number, the operation will be scheduled for that time. The current time can be retrieved with WebMidi.time. If options.time is omitted, or in the past, the operation will be carried out as soon as possible.

Returns

Returns the OutputChannel object so methods can be chained.

Throws

RangeError Invalid key aftertouch value.

Details

setLocalControl( [ state [, options ] ] ) → {OutputChannel}

Description

Turns local control on or off. Local control is usually enabled by default. If you disable it, the instrument will no longer trigger its own sounds. It will only send the MIDI messages to its out port.

Parameters
Name Type Attributes Default Description
state boolean <optional>
false

Whether to activate local control (true) or disable it (false).

options Object <optional>
{}
Name Type Attributes Description
time number | string <optional>

If time is a string prefixed with "+" and followed by a number, the message will be delayed by that many milliseconds. If the value is a number, the operation will be scheduled for that time. The current time can be retrieved with WebMidi.time. If options.time is omitted, or in the past, the operation will be carried out as soon as possible.

Returns

Returns the OutputChannel object so methods can be chained.

Details

setMasterTuning( [ value [, options ] ] ) → {OutputChannel}

Description

Sends a master tuning message. The value is decimal and must be larger than -65 semitones and smaller than 64 semitones.

Because of the way the MIDI specification works, the decimal portion of the value will be encoded with a resolution of 14bit. The integer portion must be between -64 and 63 inclusively. This function actually generates two MIDI messages: a Master Coarse Tuning and a Master Fine Tuning RPN messages.

Parameters
Name Type Attributes Default Description
value number <optional>
0.0

The desired decimal adjustment value in semitones (-65 < x < 64)

options Object <optional>
{}
Name Type Attributes Description
time number | string <optional>

If time is a string prefixed with "+" and followed by a number, the message will be delayed by that many milliseconds. If the value is a number, the operation will be scheduled for that time. The current time can be retrieved with WebMidi.time. If options.time is omitted, or in the past, the operation will be carried out as soon as possible.

Returns

Returns the OutputChannel object so methods can be chained.

Throws

The value must be a decimal number between larger than -65 and smaller than 64.

Details

setModulationRange( semitones [, cents [, options ] ] ) → {OutputChannel}

Description

Sends a modulation depth range message to adjust the depth of the modulation wheel's range. The range can be specified with the semitones parameter, the cents parameter or by specifying both parameters at the same time.

Parameters
Name Type Attributes Default Description
semitones number

The desired adjustment value in semitones (integer between 0 and 127).

cents number <optional>
0

The desired adjustment value in cents (integer between 0 and 127).

options Object <optional>
{}
Name Type Attributes Description
time number | string <optional>

If time is a string prefixed with "+" and followed by a number, the message will be delayed by that many milliseconds. If the value is a number, the operation will be scheduled for that time. The current time can be retrieved with WebMidi.time. If options.time is omitted, or in the past, the operation will be carried out as soon as possible.

Returns

Returns the OutputChannel object so methods can be chained.

Details

setNonRegisteredParameter( parameter [, data [, options ] ] ) → {OutputChannel}

Description

Sets a non-registered parameter (NRPN) to the specified value. The NRPN is selected by passing in a two-position array specifying the values of the two control bytes. The value is specified by passing in a single integer (most cases) or an array of two integers.

NRPNs are not standardized in any way. Each manufacturer is free to implement them any way they see fit. For example, according to the Roland GS specification, you can control the vibrato rate using NRPN (1, 8). Therefore, to set the vibrato rate value to 123 you would use:

WebMidi.outputs[0].channels[0].setNonRegisteredParameter([1, 8], 123);
			

In some rarer cases, you need to send two values with your NRPN messages. In such cases, you would use a 2-position array. For example, for its ClockBPM parameter (2, 63), Novation uses a 14-bit value that combines an MSB and an LSB (7-bit values). So, for example, if the value to send was 10, you could use:

WebMidi.outputs[0].channels[0].setNonRegisteredParameter([2, 63], [0, 10]);
			

For further implementation details, refer to the manufacturer's documentation.

Parameters
Name Type Attributes Default Description
parameter Array.<number>

A two-position array specifying the two control bytes (0x63, 0x62) that identify the non-registered parameter.

data number | Array.<number> <optional>
[]

An integer or an array of integers with a length of 1 or 2 specifying the desired data.

options Object <optional>
{}
Name Type Attributes Description
time number | string <optional>

If time is a string prefixed with "+" and followed by a number, the message will be delayed by that many milliseconds. If the value is a number, the operation will be scheduled for that time. The current time can be retrieved with WebMidi.time. If options.time is omitted, or in the past, the operation will be carried out as soon as possible.

Returns

Returns the OutputChannel object so methods can be chained.

Throws

The control value must be between 0 and 127.

The msb value must be between 0 and 127

Details

setOmniMode( [ state [, options ] ] ) → {OutputChannel}

Description

Sets OMNI mode to "on" or "off". MIDI's OMNI mode causes the instrument to respond to messages from all channels.

It should be noted that support for OMNI mode is not as common as it used to be.

Parameters
Name Type Attributes Default Description
state boolean <optional>
true

Whether to activate OMNI mode (true) or not (false).

options Object <optional>
{}
Name Type Attributes Description
time number | string <optional>

If time is a string prefixed with "+" and followed by a number, the message will be delayed by that many milliseconds. If the value is a number, the operation will be scheduled for that time. The current time can be retrieved with WebMidi.time. If options.time is omitted, or in the past, the operation will be carried out as soon as possible.

Returns

Returns the OutputChannel object so methods can be chained.

Throws

Invalid channel mode message name.

Channel mode controller numbers must be between 120 and 127.

Value must be an integer between 0 and 127.

Details

setPitchBend( [ value [, options ] ] ) → {OutputChannel}

Description

Sends a MIDI pitch bend message at the scheduled time.

Parameters
Name Type Attributes Default Description
value number | Array.<number> <optional>

The intensity of the bend (between -1.0 and 1.0). A value of zero means no bend. The resulting bend is relative to the pitch bend range that has been defined. The range can be set with setPitchBendRange() . So, for example, if the pitch bend range has been set to 12 semitones, using a bend value of -1 will bend the note 1 octave below its nominal value.

If the rawValue option is set to true, the intensity of the bend can be defined by either using a single integer between 0 and 127 (MSB) or an array of two integers between 0 and 127 representing, respectively, the MSB (most significant byte) and the LSB (least significant byte). The MSB is expressed in semitones with 64 meaning no bend. A value lower than 64 bends downwards while a value higher than 64 bends upwards. The LSB is expressed in cents (1/100 of a semitone). An LSB of 64 also means no bend.

options Object <optional>
{}
Name Type Attributes Default Description
rawValue boolean <optional>
false

A boolean indicating whether the value should be considered as a float between -1.0 and 1.0 (default) or as raw integer between 0 and 127 (or an array of 2 integers if using both MSB and LSB).

time number | string <optional>

If time is a string prefixed with "+" and followed by a number, the message will be delayed by that many milliseconds. If the value is a number, the operation will be scheduled for that time. The current time can be retrieved with WebMidi.time. If options.time is omitted, or in the past, the operation will be carried out as soon as possible.

Returns

Returns the OutputChannel object so methods can be chained.

Details

setPitchBendRange( semitones [, cents [, options ] ] ) → {OutputChannel}

Description

Sends a pitch bend range message to the specified channel(s) at the scheduled time so that they adjust the range used by their pitch bend lever. The range is specified by using the semitones and cents parameters. For example, setting the semitones parameter to 12 means that the pitch bend range will be 12 semitones above and below the nominal pitch.

Parameters
Name Type Attributes Default Description
semitones number

The desired adjustment value in semitones (between 0 and 127). While nothing imposes that in the specification, it is very common for manufacturers to limit the range to 2 octaves (-12 semitones to 12 semitones).

cents number <optional>
0

The desired adjustment value in cents (integer between 0-127).

options Object <optional>
{}
Name Type Attributes Description
time number | string <optional>

If time is a string prefixed with "+" and followed by a number, the message will be delayed by that many milliseconds. If the value is a number, the operation will be scheduled for that time. The current time can be retrieved with WebMidi.time. If options.time is omitted, or in the past, the operation will be carried out as soon as possible.

Returns

Returns the OutputChannel object so methods can be chained.

Throws

The msb value must be between 0 and 127.

The lsb value must be between 0 and 127.

Details

setPolyphonicMode( [ mode [, options ] ] ) → {OutputChannel}

Description

Sets the polyphonic mode. In "poly" mode (usually the default), multiple notes can be played and heard at the same time. In "mono" mode, only one note will be heard at once even if multiple notes are being played.

Parameters
Name Type Attributes Default Description
mode string <optional>
poly

The mode to use: "mono" or "poly".

options Object <optional>
{}
Name Type Attributes Description
time number | string <optional>

If time is a string prefixed with "+" and followed by a number, the message will be delayed by that many milliseconds. If the value is a number, the operation will be scheduled for that time. The current time can be retrieved with WebMidi.time. If options.time is omitted, or in the past, the operation will be carried out as soon as possible.

Returns

Returns the OutputChannel object so methods can be chained.

Details

setProgram( [ program [, options ] ] ) → {OutputChannel}

Description

Sends a MIDI program change message at the scheduled time.

Note: since version 3.0, the program number is an integer between 1 and 128. In versions 1.0 and 2.0, the number was between 0 and 127. This change aligns WebMidi.js with most devices that use a numbering scheme starting at 1.

Parameters
Name Type Attributes Default Description
program number <optional>
1

The MIDI patch (program) number (1-128)

options Object <optional>
{}
Name Type Attributes Description
time number | string <optional>

If time is a string prefixed with "+" and followed by a number, the message will be delayed by that many milliseconds. If the value is a number, the operation will be scheduled for that time. The current time can be retrieved with WebMidi.time. If options.time is omitted, or in the past, the operation will be carried out as soon as possible.

Returns

Returns the OutputChannel object so methods can be chained.

Throws

Failed to execute 'send' on 'MIDIOutput': The value at index 1 is greater than 0xFF.

Details

setRegisteredParameter( parameter [, data [, options ] ] ) → {OutputChannel}

Description

Sets the specified MIDI registered parameter to the desired value. The value is defined with up to two bytes of data (msb, lsb) that each can go from 0 to 127.

MIDI [registered parameters] (https://www.midi.org/specifications-old/item/table-3-control-change-messages-data-bytes-2) extend the original list of control change messages. The MIDI 1.0 specification lists only a limited number of them. Here are the original registered parameters with the identifier that can be used as the first parameter of this function:

  • Pitchbend Range (0x00, 0x00): "pitchbendrange"
  • Channel Fine Tuning (0x00, 0x01): "channelfinetuning"
  • Channel Coarse Tuning (0x00, 0x02): "channelcoarsetuning"
  • Tuning Program (0x00, 0x03): "tuningprogram"
  • Tuning Bank (0x00, 0x04): "tuningbank"
  • Modulation Range (0x00, 0x05): "modulationrange"

Note that the Tuning Program and Tuning Bank parameters are part of the MIDI Tuning Standard, which is not widely implemented.

Another set of extra parameters have been later added for 3D sound controllers. They are:

  • Azimuth Angle (0x3D, 0x00): "azimuthangle"
  • Elevation Angle (0x3D, 0x01): "elevationangle"
  • Gain (0x3D, 0x02): "gain"
  • Distance Ratio (0x3D, 0x03): "distanceratio"
  • Maximum Distance (0x3D, 0x04): "maximumdistance"
  • Maximum Distance Gain (0x3D, 0x05): "maximumdistancegain"
  • Reference Distance Ratio (0x3D, 0x06): "referencedistanceratio"
  • Pan Spread Angle (0x3D, 0x07): "panspreadangle"
  • Roll Angle (0x3D, 0x08): "rollangle"
Parameters
Name Type Attributes Default Description
parameter string | Array.<number>

A string identifying the parameter's name (see above) or a two-position array specifying the two control bytes (e.g. [0x65, 0x64]) that identify the registered parameter.

data number | Array.<number> <optional>
[]

An single integer or an array of integers with a maximum length of 2 specifying the desired data.

options Object <optional>
{}
Name Type Attributes Description
time number | string <optional>

If time is a string prefixed with "+" and followed by a number, the message will be delayed by that many milliseconds. If the value is a number, the operation will be scheduled for that time. The current time can be retrieved with WebMidi.time. If options.time is omitted, or in the past, the operation will be carried out as soon as possible.

Returns

Returns the OutputChannel object so methods can be chained.

Details

setTuningBank( value [, options ] ) → {OutputChannel}

Description

Sets the MIDI tuning bank to use. Note that the Tuning Bank parameter is part of the MIDI Tuning Standard, which is not widely implemented.

Note: since version 3.0, the bank number is an integer between 1 and 128. In versions 1.0 and 2.0, the number was between 0 and 127. This change aligns WebMidi.js with most devices that use a numbering scheme starting at 1.

Parameters
Name Type Attributes Default Description
value number

The desired tuning bank (1-128).

options Object <optional>
{}
Name Type Attributes Description
time number | string <optional>

If time is a string prefixed with "+" and followed by a number, the message will be delayed by that many milliseconds. If the value is a number, the operation will be scheduled for that time. The current time can be retrieved with WebMidi.time. If options.time is omitted, or in the past, the operation will be carried out as soon as possible.

Returns

Returns the OutputChannel object so methods can be chained.

Throws

The bank value must be between 1 and 128.

Details

setTuningProgram( value [, options ] ) → {OutputChannel}

Description

Sets the MIDI tuning program to use. Note that the Tuning Program parameter is part of the MIDI Tuning Standard, which is not widely implemented.

Note: since version 3.0, the program number is an integer between 1 and 128. In versions 1.0 and 2.0, the number was between 0 and 127. This change aligns WebMidi.js with most devices that use a numbering scheme starting at 1.

Parameters
Name Type Attributes Default Description
value number

The desired tuning program (1-128).

options Object <optional>
{}
Name Type Attributes Description
time number | string <optional>

If time is a string prefixed with "+" and followed by a number, the message will be delayed by that many milliseconds. If the value is a number, the operation will be scheduled for that time. The current time can be retrieved with WebMidi.time. If options.time is omitted, or in the past, the operation will be carried out as soon as possible.

Returns

Returns the OutputChannel object so methods can be chained.

Throws

The program value must be between 1 and 128.

Details

stopNote( note, options ) → {Output}

Description

This is an alias to the sendNoteOff() method.

Parameters
Name Type Description
note
options
Returns

turnNotesOff( [ options ] ) → {OutputChannel}

Description

Sends an all notes off channel mode message. This will turn all currently playing notes off. However, this does not prevent new notes from being played.

Parameters
Name Type Attributes Default Description
options Object <optional>
{}
Name Type Attributes Description
time number | string <optional>

If time is a string prefixed with "+" and followed by a number, the message will be delayed by that many milliseconds. If the value is a number, the operation will be scheduled for that time. The current time can be retrieved with WebMidi.time. If options.time is omitted, or in the past, the operation will be carried out as soon as possible.

Returns

Returns the OutputChannel object so methods can be chained.

Details

turnSoundOff( [ options ] ) → {OutputChannel}

Description

Sends an all sound off channel mode message. This will silence all sounds playing on that channel but will not prevent new sounds from being triggered.

Parameters
Name Type Attributes Default Description
options Object <optional>
{}
Name Type Attributes Description
time number | string <optional>

If time is a string prefixed with "+" and followed by a number, the message will be delayed by that many milliseconds. If the value is a number, the operation will be scheduled for that time. The current time can be retrieved with WebMidi.time. If options.time is omitted, or in the past, the operation will be carried out as soon as possible.

Returns

Returns the OutputChannel object so methods can be chained.

Details