The line object sends out a periodic series of numbers that progress to some new value over a certain amount of time. The input to line is a destination value (where it should eventually arrive), a transition time (how long it should take to get there), and a time interval between outputs (how often it should send out intermediate values along the way). The left part of this patch shows the use of line to generate integers that are used as pitches.
This program shows the formula for linear mapping of one range to another, and implements the formula using basic Max math objects. One can use the objects zmap and scale to do this task more simply, but this example demonstrates the formula explicitly.
This patch demonstrates the two simplest objects for generating random numbers. Every time it receives a bang in its left inlet, the random object generates a random integer in the range from 0 to one less than its argument. (For example, if you tell it to generate one of 12 random numbers, it will choose a number from 0 through 11 inclusive.) Note that this includes the possibility that successive random choices may appear to generate what seem to be patterns, especially if it's choosing from among a small range of possibilities.
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.