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.
This example shows several different ways you can display changing text in the user interface of your Max patch. For demonstration purposes, we’re storing the text we want to display in a message box, but in actual practice, if you had a whole collection of different messages you want to display at different times, you could keep them all in a coll object.
In Max there are many ways to schedule an event to occur at a certain time in the future, using delay, pipe, or timepoint, for example. What if you want to schedule a whole collection of triggers or messages to occur at different specific points in time? Here are a few approaches.
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.
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.
The bag object stores an unordered collection of integers. You can put numbers into the bag or remove them, and you can query what’s in the bag using the bang message. You put a number into the bag by providing the number along with a 1 (or any non-zero number), and you remove it by specifying the number along with a 0.
The mean object provides the average (mean) value of a list of numbers. Or, as it gets individual numbers it continually sends out the running average.
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.
To store any series of integer numbers as an array, the table object is most convenient. You can look up the stored numbers by referring to their index location within the table. Thus, you can read through the numbers in the array, in order, using a counter object.
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.