Sunday, September 14, 2008

Limiting the range of random choices

The previous examples showed random selection from a body of possible choices. In the first example of randomness the selection was from among events that had a certain distinctive character (chords, paintings, drum sounds), such that the events were fairly engaging in their own right and the order in which they occurred was not terribly crucial. In the next example, showing the relationship of randomness and noise, the individual events were neutral and and relatively characterless (individual samples in an audio signal, or pitches in a steady stream of notes), so the result was maximally patternless and colorless because all possibilities could occur with equal likelihood. In the case of random audio samples we get white noise (confirming the description as "colorless"), and in the case of random pitches we get complete atonality.

Even with such random decision making, however, we can still exert some control to shape the random selections in various ways. One way is simply to limit ourselves to a subset of the full range of possibilities. The subset will in some way be distinct from the full set, and that will allow us to characterize it by the way(s) in which it differs from the full set. For example, instead of choosing randomly from among all the keys of the piano--MIDI notes 21 to 108 as in the previous example-- we could decide to choose from a smaller number of notes. If the subset we choose is significantly different from the full set, we'll recognize the difference. (In effect, we'll recognize the absence of certain possibilties.) For example, if we choose only from among the pitches 59 to 70, we could characterize those pitches as "middle range" because we would observe that the choices contained no very low or very high notes. Choices made in this way would be noticeably different from choices made in the range 21 to 32 (extremely low), or 97 to 108 (extremely high), or 95 to 96 (very high and extremely small range), or 21 to 66 (low but very wide range), and so on. In this way we can get variety and distinction between different subsets of possible choices, even though the decision making method within the specified range would still be completely random.

This example program demonstrates that idea. One can achieve variety of randomness by limiting the range of choices.

The note-playing portion of the program is at the bottom. The random object near the bottom of the program chooses from within a certain range, usually much smaller than the total possible range of 88 keys, so it has a limited number of possible notes to choose. The choices from within that range are then offset to a particular position on the keyboard by adding a certain amount to each note. (The idea of offsetting a range has been discussed in earlier chapters.) So, for example if the right argument of the random object is 6 (numbers from 0 to 5) and the right argument of the + object (the offset of the random range) is 84, then the possible pitches are 84 to 89 only. The note-playing metro object is set to a time interval of 62.5 milliseconds, which is the period corresponding to 16 notes per second. The pitch choices are also displayed in a multislider object set to display in Point Scroll style.

One useful way to think about a range of numbers is by its minimum and maximum (84 and 89 in the above example). Another useful way to think of it is by its size (calculated as the difference between the maximum and the minimum) and its offset (its minimum). The rangeslider object in the middle of this patch allows the user to specify a minimum and a maximum value, either by clicking and dragging with the mouse or by sending numbers in the inlets. This rangeslider has been set to have a built-in offset of 21 (specified as its Minimum Value in the Inspector); that means that 21 is the lowest value one can select with the mouse, and any number that comes in its inlets will get 21 added to it. The rangeslider's size is 88 (specified as its Number of Steps in the Inspector), so its total range corresponds to the pitches of a piano keyboard. Thus, the user -- or another part of the program -- can choose a range minimum and maximum between 21 and 108 in the rangeslider, and those numbers get sent out the outlets of rangeslider. The minimum is used as an offset value for the + object, and the argument for the random object is calculated by subtracting the minimum from the maximum (and adding 1 to it since random chooses numbers from 0 to one less than its argument).

The upper part of the program uses a slower metro to automatically trigger new randomly-chosen minimum and maximum values for the rangeslider every 5 seconds. The random 88 object chooses one of the 88 possible keys to use as an offset from the bottom of the piano. (The rangeslider will add 21 to that to calculate its minimum value.) Once the offset has been chosen, that determines the limit to how large the range can be without extending beyond the top range of the piano, so the maximum is calculated by taking 88 minus the offset, choosing a random number less than that, and adding it back to the offset. (Once again, the rangeslider will add 21 to that to calculate its maximum value.)

This is a demonstration of two very different time intervals being used (5000 ms and 62.5 ms) to specify periodicity at two different formal levels of the music. The fast metro determines the note rate, and the slow metro determines the rate of change of the random range. Because of the mathematical relationship of the two rates, the range changes every 80 notes. You can think of the slower metronome as determining a control structure for the faster one; it provides information that controls parameters that limit the note choices in specific ways. We don't hear the results of the slow (control) metro directly, but we do hear the result of its actions by the limits that it sets for the note choices. Rhythmic interest in temporal formal structure often requires different levels of periodicity like this. This example has two levels of periodicity, but there's no reason there couldn't be more. The different levels can be synchronized or unrelated, but they will generally be separate parts of the program that communicate with each other. Using one part of the program as a control structure to influence another part is a very effective way to define different formal levels of decision making or change.

No comments: