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

selector~

Assign one of several inputs to an outlet

Description

selector~ is a version of the Max switch object for signals. It takes an argument for number of inputs (one is the default) and lets you turn incoming signals on and off by sending an int to its left inlet. If there is more than one input, selector~ shuts off all inputs except the one you select, where 1 selects the input to the right of the leftmost inlet, 2 selects the next one to the right, etc. Note: "shutting off" all input signals means that selector~ will output a zero signal. This is slightly different from the behavior of the Max switch object.

Arguments

Name Type Opt Description
number-of-inputs and initially-open-inlet int opt The first argument specifies the number of input signals. The default is 1. The second argument specifies which signal inlet is initially open for its input to be passed through to the outlet. The default is 0, where all signals are shut off and a zero signal is sent out. If a signal is connected to the left inlet, the second argument is ignored.

Messages

int open-inlet [int]
In left inlet: If a signal is not connected to the left inlet, an int or float determines which input signal in the other inlets will be passed through to the outlet. If the value is 0 or negative, all inputs are shut off and a zero signal is sent out. If it is 1 but less than 2, the signal coming in the first inlet to the right of the leftmost inlet is passed to the outlet. If the number is 2 but less than 3, the signal coming into the next inlet to the right is used, and so on.
signal In left inlet: If a signal is connected to the left inlet, selector~ operates in a mode that uses signal values to determine which of its input signals is to be passed to its outlet. If the signal coming in the left inlet is 0 or negative, the output is shut off and a zero signal is sent out. If it is 1 but less than 2, the signal coming in the first inlet to the right of the leftmost inlet is passed to the outlet. If the signal is 2 but less than 3, the signal coming into the next inlet to the right is used, and so on.

In other inlets: Any signal, to be passed through to the selector~ object's outlet depending on the value of the most recently received int or float in the left inlet, or the signal coming into the left inlet. The first signal inlet to the right of the leftmost inlet is considered input 1, the next to the right input 2, and so on.
If the signal network connected to one or more of the selector~ signal inlets contains a begin~ object, and a signal is not connected to the left inlet of the selector~, all processing between the begin~ outlet and the selector~ inlet is turned off when the input signal is not being passed to the selector~ outlet.

Information for box attributes common to all objects

Output

signal: The output is the signal coming in the "open" inlet, as specified by a number or signal in the left inlet. The output is a zero signal if all signal inlets are shut off.

Examples

Allow only one of several signals to pass optionally turn off unneeded signal objects

See Also

Name Description
begin~ Define a switchable part of a signal network
gate~ Route a signal to one of several outlets
switch Output messages from a specific inlet
MSP Tutorial 5: Turning Signals On and Off MSP Tutorial 5: Turning Signals On and Off