Skip to main content

Forwarder

The Forwarder class allows the forwarding of MIDI messages to predetermined outputs. When you call its forward() method, it will send the specified Message object to all the outputs listed in its destinations property.

If specific channels or message types have been defined in the channels or types properties, only messages matching the channels/types will be forwarded.

While it can be manually instantiated, you are more likely to come across a Forwarder object as the return value of the Input.addForwarder() method.

Since: 3.0.0

Constructorโ€‹

Creates a Forwarder object.

Parameters

new Forwarder([destinations], [options])

ParameterTypeDefaultDescription
[destinations]Output
Array.<Output>
[]An Output object, or an array of such objects, to forward the message to.
[options]object
{}
[options.types]string
Array.<string>
(all messages)A MIDI message type or an array of such types ("noteon", "controlchange", etc.), that the specified message must match in order to be forwarded. If this option is not specified, all types of messages will be forwarded. Valid messages are the ones found in either MIDI_SYSTEM_MESSAGES or MIDI_CHANNEL_MESSAGES.
[options.channels]number
Array.<number>
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]A MIDI channel number or an array of channel numbers that the message must match in order to be forwarded. By default all MIDI channels are included (1 to 16).

Propertiesโ€‹

.channelsโ€‹

Type: Array.<number>

An array of MIDI channel numbers that the message must match in order to be forwarded. By default, this array includes all MIDI channels (1 to 16).

.destinationsโ€‹

Type: Array.<Output>

An array of Output objects to forward the message to.

.suspendedโ€‹

Type: boolean

Indicates whether message forwarding is currently suspended or not in this forwarder.

.typesโ€‹

Type: Array.<string>

An array of message types ("noteon", "controlchange", etc.) that must be matched in order for messages to be forwarded. By default, this array includes all Enumerations.MIDI_SYSTEM_MESSAGES and Enumerations.MIDI_CHANNEL_MESSAGES.


Methodsโ€‹

.forward(...)โ€‹

Sends the specified message to the forwarder's destination(s) if it matches the specified type(s) and channel(s).

Parameters

Signature: forward(message)

ParameterType(s)DefaultDescription
messageMessage
The Message object to forward.