A newer version of Max is available. Click here to access the latest version of this document.

matrix~

Signal routing and mixing matrix

Description

matrix~ is an array of signal connectors and mixers (adders). It can have any number of inlets and outlets. Signals entering at each inlet can be routed to one or more of the outlets, with a variable amount of gain. If an outlet is connected to more than one inlet, its output signal is the sum of the signals from the inlets.

The matrix~ object has two modes of operation: "binary" and non-binary. In binary mode, connections act like simple switches, and always have unity gain. This mode is faster, but audible clicks will occur if you're listening to the outputs of this object when connections are made and broken. In non-binary mode, connections are gain stages, i.e. they can scale the signal by some amount other than zero and one. They also provide an adjustable ramping time over which the gain values are changed. This allows signals to be switched without creating audible clicks.

Arguments

Name Type Opt Description
number-of-inlets int Obligatory. The first argument specifies the number of inlets.
number-of-outlets int Obligatory. The second argument specifies the number of outlets.
nonbinary-connection-flag (initial-connection-gain) float opt If a float value is provided as a third argument, matrix~ operates in its non-binary mode. The argument sets the gain value that will be used when connections are created.

Messages

list inlet-to-outlet indices [list]
In left inlet: A list of three ints may be used to connect inlets and outlets when the matrix~ object is in binary mode. The first int specifies the inlet, the second int specifies the outlet, and a third int is used to specify connection or disconnection. If the third int is nonzero value, the inlet of the first int will be connected to the outlet specified by the second int. A zero value for the third int in the list disconnects the inlet-outlet pair.

If the matrix~ object is operating in non-binary mode, A list of two ints followed by a float sets the gain of the connection between inlet i and outlet o to the value specified by the float.

Note: To specify the gain of individual connections, you must use three-element list messages rather than the connect message. Connections formed with the connect message always have a gain specified by the third argument initially given to the matrix~ object. However, subsequent list messages can alter the gain of connections formed with the connect message. The addition of an optional fourth element to the list message can be used to specify a ramp time, in milliseconds, for the individual connection (e.g., 1 2 .8 500 would connect the first inlet to the second outlet and specify a gain of .8 and a ramp time of .5 seconds).
clear In left inlet: The word clear removes all connections.
connect inlet-to-outlet indices [list]
In left inlet: The word connect, followed by one or more ints, will connect any inlet specified by the first int to the outlet or outlets specified by the remaining ints in the list. Inlets and outlets are numbered from left to right, starting at zero. For example, the message connect 0 0 1 would connect the first inlet from the left to the leftmost outlet and the second outlet from the left.
disconnect inlet-to-outlet indices [list]
In left inlet: The word disconnect, followed by one or more ints, will disconnect any inlet specified by the first int to the outlet or outlets specified by the remaining ints in the list.
dump In left inlet: The word dump causes the current state of all matrix~ object connections to be sent out the rightmost outlet of the object in the form of a list for each connection. The list consists of two numbers which specify the inlet and outlet, followed by a float which specifies the gain for the connection. Note that in non-binary mode the current gains are not necessarily the same as the target gains of all matrix~ object connections, since a connection's gain can ramp to its new target over time.
dumptarget In left inlet: The word dumptarget causes the target state of all matrix~ object connections to be sent out the rightmost outlet of the object in the form of a list for each connection. The list consists of two numbers which specify the inlet and outlet, followed by a float which specifies the target gain for the connection. Note that in non-binary mode the target gains are not necessarily the same as the current gains, which can be accessed with the dump message.
print In left inlet: The word print causes the current state of all matrix~ object connections to be printed in the Max window in the form of a list for each connection. The list consists of two numbers which specify the inlet and outlet, followed by a float which specifies the gain for the connection.
ramp delta-time (milliseconds) [int]
In left inlet: The word ramp, followed by a number, sets the time in milliseconds use to change gain values when the matrix~ object is in non-binary mode. The default millisecond value is 10.

Information for box attributes common to all objects

Output

signal: The output signals for each outlet are the sum of their connected inputs, scaled by the gain values of the connections.

Examples

Multichannel audio routing

See Also

Name Description
gate~ Route a signal to one of several outlets
matrixctrl Matrix switch control
receive~ Signals can be received from any loaded patcher, without patch cords
router matrixctrl-compatible Max message router
selector~ Assign one of several inputs to an outlet
send~ Transmit signals without patch cords