(maxmsp) Selecting and Counting

Some additional explanations that will help with Assignment 2.

You will constantly need to test data in some way, looking for a particular value to trigger execution of some action, or looking for certain values to move separately from other values. While MaxMSP has a full set of Boolean operators (operators that test conditions like greater than, less than, etc.), you will find that you often perform tests and route messages using select, split, and route.

The select object

The select object is like a specialized if-then-else function. It looks for specific messages (one or more, specified in arguments). If the incoming message matches what select is looking for, it outputs a bang via the appropriate outlet. Non-matching information passes unchanged out the right-most outlet.

Select is useful for determining when a counter has reached its maximum. The example patcher countingRhythmic.maxpat illustrates this in a way that you could use for a part of Assignment 2. Each time the counter reaches its maximum the counter object outputs a 1 out its second-to-right outlet. Select looks for this  1 and bangs one of two random distributions to produce a new rhythmic maximum count. The bang also plays a note in this patcher. Look at the patcher comment closely to understand the two different random distributions. One is weighted, meaning it is more likely to produce certain values than other values.

The patcher selectsplitroute.maxpat shows select in a more basic way, and also illustrates how split and route can be used for sorting messages with some important differences.


The split object looks for values within a specified range (inclusive of minimum and maximum values). Values within the range pass out the left outlet; values out of range pass out the right outlet. The important difference from select is that split outputs the incoming message intact via one of its outputs. You can then continue to process the message. Split can be used to specify a range of MIDI keys that will be control keys, separate from the rest of the keyboard (as illustrated in the patcher).


The route object takes an incoming list and uses the first item in the list to sort the output of the remaining list items. The example patcher packs note number and velocity into a list, sorts by note number, and the output result is velocity alone for matching note numbers. You could then use the velocity information to determine other control parameters.


Leave a Reply