Max

Random numbers without repetitions

The random object outputs a pseudo-randomly chosen integer. The range of possible numbers is determined by the number received in the right inlet (or specified as a typed-in argument). Each time random receives a bang, it will output one of n possible numbers, ranging from 0 to n-1. Because each number has an equal probability of occurring each time, there’s a possibility that repetitions will occur. If you wish to prevent repetitions there are two approaches.

Filter out too-frequent repetitions

A common way of detecting the onset of a significant event in a continuous stream of data is to look for the data to exceed a certain threshold. For example, detecting when the amplitude exceeds a certain level in an audio signal can indicate that a sonic event has occurred. One common problem with threshold detection is that data might fluctuate around the threshold, going above and below it many times, and thus giving a false reading of multiple triggering events.

The tempo object

In the tempo object, the first argument specifies the initial quarter-note tempo in quarter-notes per minute. You can also specify the tempo with a number in the second inlet, or with a tempo message in the first inlet. The second and third arguments (and the third and fourth inlets) allow you to specify the numerator and denominator (multiplier and divisor) of the rhythmic value that the object will produce, relative to a whole note.

Math in the slider object

The slider object has some attributes that have a significant effect on its output: floatoutput, size, min[imum] and mult[iplier]. By default slider uses only integer values, with a size of 128 (i.e., ranging from 0 to 127). For an integer slider, the range will be size different integers from 0 to size-1, whereas for a float slider the input range will be the full range from 0. to size., inclusive.

Timed counting in Max

The upper example shows how to count from 1 to 10 at a specific rate (e.g., one count every 500 ms) and stop when you reach 10. The metro object sends out a bang message when it is turned on (when it receives a nonzero number in its left inlet), and continues to send out bang every x milliseconds (specified by the typed-in argument or by a number received in its right inlet). You can type in minimum and maximum values as arguments in the counter object.