matrix~
MSP Reference
Open Help

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.

Examples

Multichannel audio routing

Discussion

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

inlets [int]

The first argument specifies the number of inlets.

outlets [int]

The second argument specifies the number of outlets.

connection-gain [float]

Optional

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.

Attributes

ramp [atom_long]

Ramp Time (ms)

Common Box Attributes

annotation [symbol]

Sets the text that will be displayed in the Clue window when the user moves the mouse over the object.

background [int] (default: 0)

Adds or removes the object from the patcher's background layer. background 1 adds the object to the background layer, background 0 removes it. Objects in the background layer are shown behind all objects in the default foreground layer.

color [4 floats]

Sets the color for the object box outline.

fontface [int]

Sets the type style used by the object. The options are:

plain
bold
italic
bold italic

Possible values:

0 = 'regular'
1 = 'bold'
2 = 'italic'
3 = 'bold italic'

fontname [symbol]

Sets the object's font.

fontsize [float]

Sets the object's font size (in points).

Possible values:

'8'
'9'
'10'
'11'
'12'
'13'
'14'
'16'
'18'
'20'
'24'
'30'
'36'
'48'
'64'
'72'

hidden [int] (default: 0)

Toggles whether an object is hidden when the patcher is locked.

hint [symbol]

Sets the text that will be displayed in as a pop-up hint when the user moves the mouse over the object in a locked patcher.

ignoreclick [int] (default: 0)

Toggles whether an object ignores mouse clicks in a locked patcher.

patching_rect [4 floats] (default: 0. 0. 100. 0.)

Sets the position and size of the object in the patcher window.

position [2 floats]

g/s(set)

Sets the object's x and y position in both patching and presentation modes (if the object belongs to its patcher's presentation), leaving its size unchanged.

presentation [int] (default: 0)

Sets whether an object belongs to the patcher's presentation.

presentation_rect [4 floats] (default: 0. 0. 0. 0.)

Sets the x and y position and width and height of the object in the patcher's presentation, leaving its patching position unchanged.

rect [4 floats]

g/s(set)

Sets the x and y position and width and height of the object in both patching and presentation modes (if the object belongs to its patcher's presentation).

size [2 floats]

g/s(set)

Sets the object's width and height in both patching and presentation modes (if the object belongs to its patcher's presentation), leaving its position unchanged.

textcolor [float]

Sets the color for the object's text in RGBA format.

textjustification [int]

Text Justification

Possible values:

0 = 'left'
1 = 'center'
2 = 'right'

varname [symbol]

Sets the patcher's scripting name, which can be used to address the object by name in pattr, scripting messages to thispatcher, and the js object.

Messages

list

Arguments

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

Arguments

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

Arguments

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 Console 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.

Output

list

Out right outlet: A set of lists describing the current or target state of all matrix~ object connections will be sent out the right outlet in response to a dump or dumptarget message.

signal

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

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 Route messages to multiple locations
selector~ Assign one of several inputs to an outlet
send~ Send signals without patch cords