This article resulted from some tinkering in my Z80 environment in the late 1970s, using a homebrew synthesizer for output (see photo below). I did not have any grounding in music theory, so the method described here was merely a starting point based on the recent publication of Fractal mathematics by Voss & Mandelbrot.
Music Composition: A New Technique
by Steven K. Roberts
(written April 23, 1978)
Mathematics is music for the mind;
Music is mathematics for the soul.
The delightful ease with which a microprocessor may be interfaced with sound-generating hardware seems to tempt nearly every personal computer owner with the idea of producing music. Ever since the early days of the 8008 and the infamous AM radio interface, techniques and software tricks for playing tunes with the various micros have peppered the pages of our chosen magazines. There are now a variety of products on the market that in some way contribute to the implementation of a computer music system.
Throughout all the fuss, I have seen surprisingly little on the subject of composition with the computer, perhaps because any tunes of more than trivial significance seem to require rather elaborate software. There are idiomatic structures to worry about, keys and accidentals, rhythmic patterns … not to mention the aesthetic problems of avoiding banality and obvious repetition. Perhaps the compositional techniques that lie beyond the realm of the self-evident (random numbers) have remained in the computer music laboratories and scholarly journals. Whatever the case, a minor breakthrough of sorts has just manifested itself in the work of Richard E. Voss and Benoit Mandelbrot, recently reported in the April, 1978 issue of Scientific American. A simple technique now exists which allows the computer generation of pleasing sequences of tones with some surprising properties.
Without delving too deeply into the mathematics involved, the work of Voss and Mandelbrot can be best understood by starting with a simple sequence of random numbers. In order to develop the application to computer music, let’s look at a BASIC program to generate them (Program A). This program repeatedly generates a random (actually pseudorandom) number in the range 0-59, or five octaves, and outputs it after some conversion to port 17 of the system. Lines 30, 40 and 50 are installation-dependent, serving in the system for which this was written to convert the raw binary number (A) into a format the custom-designed note selection logic can understand. (It requires a byte whose low four bits are a note code and whose next three bits define an octave.) Lines 70 and 80 simply delay the loop long enough for the individual notes to be discernible.
Needless to say, the output from the program in Program A is boring. It has no internal structure governing the passage of one note to the next (its autocorrelation function is zero) and it totally fails to satisfy whatever intellectual and emotional criteria we apply when we attempt to decide whether or not something is “music.” One of the most important of these criteria is the balance between the anticipated and the unanticipated, a key interrelationship that caused Beethoven to observe: “Everything in music must be at once surprising and expected.” Within this context, we can easily generate the two extremes—the totally surprising with Program A and the totally expected with the concept in Program B.
The BASIC program in Program B is the next step in sequence abstraction, being a method of generating random intervals from a previous state rather than random notes. Each pass through the loop displaces the current note value by some amount less than eight half-steps in either direction. The relatively wide intervalic range of eight is an attempt to introduce some surprise into the melody, and results in an effect somewhat more pleasing than before but still with little, if any, aesthetic appeal. The sequence wanders up and down the scale and is randomly relocated upon encountering either extreme. The major conceptual difference of this from the first form is that its value at any point is very much a function of its recent past (depending on the intervalic range) and it is thus highly autocorrelated.
These forms of computer tune generation have served as the jumping-off point for a number of serious attempts at composition in recent years, giving birth to, among other things, the concept of “stochastic” music. Basically, this approach to composition is based upon a series of statistically-derived transition and rejection rules, which govern the probability of a passage from one note or sequence to the next. Within this broad category, examples of a musical idiom (such as Chopin Waltzes) have been analyzed, and their characteristics summarized in a collection of rules which are then used to constrain a sequence of random numbers. The result is something which, over a limited time span, is suggestive of the style of the original, but still suffers from banality when experienced to any significant extent. Stochastic music is a brave but generally unsuccessful attempt at mediation (statistically speaking) between the two extremes described so far.
It is here that the recent work of Voss and Mandelbrot enters the picture. Voss introduced the concept of “one-over-f” noise, wherein the values comprising a sequence are functions not only of their recent past, but of their entire past. Mandelbrot named the fluctuations fractals and made a number of startling discoveries about their appearance in nature: not only do such relationships characterize variations in annual flood levels of the Nile, the geometry of seacoasts and mountain ranges, and the clustering of stars, but it also appears that our nervous systems reduce the massive parallel input from the outside world to information that behaves statistically like 1/f noise.
Applied to music composition, fractal patterns produce results that are astonishingly familiar. If such relationships characterize much abstract art, nature’s whimsy, and even the behavior of our nervous systems, then, embodied in musical form, may they not offer greater potential reward than the white noise of random numbers or the rigid rules of stochastic composition?
Voss thought so. He has investigated fractal music with promising results, and has suggested a conceptual technique for its computer implementation. With that as a basis, I developed the BASIC program shown in Program C. It may be considered a starting point for deep exploration of the possibilities inherent in these sequences.
The intent of this program is the continuous generation of an algorithmically structured sequence of tones with a random basis and a 1/f frequency distribution. This apparent self-contradiction is resolved by the following logic:
Assume that any note’s value is the sum (S) of eight intermediate values in the range 0-7, resident in Array A. This allows a musical range of 56 possible notes. Begin the sequence with the eight elements of Array A randomly assigned, and with a counter (X) set to zero. To determine the next note in the sequence, increment X and note which bits changed (either way). The elements of the Array, indexed by the bit numbers that changed during the increment, are then given new random values in the range 0-7. These are then summed, as before, to yield the new note. It may be seen that the pattern of changing bits as X passes through its 256 count range will cause structuring of the sequence in a fashion that allows the higher-order values to be progressively more stable, preventing wild excursions of the melody. A moment’s thought on the curve generated by the “changing bits” concept will give some insight into the loose schematic structure of the resulting tune.
In Program C this algorithm has been implemented. The changing bits are determined by performing an Exclusive-OR between the old value of X and the new, then successively subtracting the binarily weighted values in Array B from the result, reassigning the corresponding elements of A until underflow occurs on a subtraction. The note value (S), as explained above, is then derived by summing those elements, whereupon it is subjected to a validity test (to maintain the integrity of the chosen key signature), converted to octave/note format, and output to the hardware. The DATA statement in line 420 selects the number of notes within one octave of the key, and the DATA statement following specifies the notes in the key (numbered 0-11). The one shown is D major. If line 420 is 11 and line 430 is 0,1,2 10,11 the result will be chromatic “riffs” unconstrained by any limitation.
Where to from here? Depending upon the stylistic parameters of your chosen musical forms, any of a number of enhancements can be added. For example, a rhythmic structure can be established, either rigid or based upon another 1/f sequence, and transition rules applied in the manner of stochastic music. A “theme and variations” form could be easily established, with the program generating ever more elaborate embellishments upon its initial fractal theme. And, with ever easier methods of real-time sound generation and the titillating prospect of home multiprocessing, can orchestration be more than a few half-steps away?
Scientific American, April. 1978. “Mathematical Games” by Martin Gardner
Music by Computers, edited by Heinz von Foerster and James W. Beauchamp. Wiley and Sons.
Another music-related piece from the same epoch: Polyphony Made Easy