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

switch

Output messages from a specific inlet

Description

switch allows for the output of only a selected input.

Arguments

Name Type Opt Description
number-of-inlets int opt Specifies the number of inlets, in addition to the leftmost inlet. If there is no argument, there are two additional inlets.
initial-state int opt An optional second argument can be used to specify which inlet is initially open. The default is 0 (i.e., none).

Messages

bang In left inlet: Sends out the number of the open inlet, or 0 if all inlets are closed.
int selected-inlet [int]
In left inlet: The number specifies an open inlet for receiving subsequent messages to be sent out the outlet. All inlets other than the designated open one are closed. If the number is 0, all inlets are closed.
float selected-inlet [float]
In left inlet: Converted to int.

Information for box attributes common to all objects

Output

anything: If the number in the left inlet is less than 0, its absolute value is used to determine which inlet to open. (-1 opens inlet 1, -2 opens inlet 2, etc.) If the absolute value of the number is greater than the number of existing inlets, messages are received in the rightmost inlet.

Examples

'Listen' to only one inlet at a time or ignore all inlets

See Also

Name Description
forward Send remote messages to a variety of objects
funnel Tag data with a number that identifies its inlet
gate Pass the input out a specific outlet
ggate Pass the input out one of two outlets
gswitch Receive the input in one of two inlets
receive Receive messages without patch cords
router matrixctrl-compatible Max message router
send Send messages without patch cords
Max Basic Tutorial 21: Controlling Data Flow Max Basic Tutorial 21: Controlling Data Flow