Magazine Archive

Home -> Magazines -> Issues -> Articles in this issue -> View

Lab Notes: Pink Tunes

Article from Polyphony, July/August 1978


As we begin this month's journey into the bizarre I should warn you that I'm operating in a somewhat altered state of consciousness.

Oh, not from chemicals or nature's own, none of that. There's just some very nice color graphics going on the Apple II and the background music is a slightly oriental feeling 4 part harmony being composed by a P4700/J. It's really a most unique environment.

Wait. Composed by the synthesizer? Surely not, surely just something pre-recorded and played back.

Well, I suppose that I wouldn't attack someone who asserted that I composed the piece. I'd be flattered, but it wouldn't be entirely correct. I knew before the tune started what sort of texture (for lack of a better term) it would have. But I have no idea what exactly is coming next.

And that, in case you hadn't already guessed, is what we want to talk about this time. Computer programs that compose music.

Let's start at a very elementary level. Probably you've seen or connected synthesizer patches that look something like this:


It's a relatively common configuration in which, at regular intervals, the instantaneous value of the noise source is captured by the S/H and the resulting voltage used to set the pitch of the VCO. The ADSR and VCA give us some knobs to twiddle and control dynamics, but otherwise are just window dressing.

If you've done one of these, you know that the results are interesting, but certainly not a musical composition in the traditional sense. As a composing device, it's hard to know what the biggest fault is here, but certainly it must be the fact that there are no guarantees that the series of pitches produced are going to be equally tempered intervals (or any known tempering for that matter). In fact, you can almost guarantee that they won't be; the control voltages applied to the oscillator are completely random.

And therein lies the tale.

I don't believe that anyone is able at this point in human development to concisely explain what makes music "musical", but most folks that have thought about it seem to feel that "good" music (ugh, all the subjective terms) combines both order and disorder. Establish a pattern in the listener's mind... then surprise him; pleasantly, preferably.

Like the "noise music" example above, any compositional program that we come up with today is in some way going to rely on a STOCHASTIC (big word for random) process. If it didn't, we wouldn't be writing the program that wrote the music; we'd be writing the music.

Our task then, is to bring order from disorder (in a very real sense, nothing less than reversing entropy) — but not completely. It isn't easy, but in an elementary form not as difficult as it may sound either because we now have at our disposal that wonder of wonders (which many right-thinking people say is Maxwell's Demon personified): THE COMPUTER

By simply programming the computer to randomly select only pitches that are part of the equally tempered sequence, we've made a start, but in all honesty not much of one; still there is too much disorder. Low pitches followed as likely as not by very high ones, no identifiable key signature. It's still "noise music".

The quickest way to begin bringing the kind of order that we're looking for is to write a program that uses a random number not as the note, but as a "pointer" which is used to select one of a number of acceptable "candidate" notes from a previously entered table. We're using our intellect to select ahead of time only those notes which we know will harmonize with the rest of the notes which the computer is allowed to select. I've written a few of these kinds of programs. They're a little better than purely random notes, but not much. Still too much disorder.

There are a lot of tricks to bring; rigorous order, like making random substitutions of candidate notes into previously entered melody lines. This kind of thing produces terrific results, but it's not the computer doing most of the composition — you are.

Now comes the April issue of Scientific American and there, in Martin Gardner's consistently enlightening Mathematical Games column, is a piece on computer music. Well, not just computer music — as is usual, Mr. Gardner's mind ranges far and the column covers visual art and computer generated "landscapes" and fractal curves and the place of pink noise in "the meaning of it all". Very heavy. And buried in amongst it all is an algorithm conceived by Richard Voss (of IBM) for turning "white" random numbers "pink".

Don't let this "white" and "pink?' business throw you. You're used to white noise and the pink noise that results when you filter it. We can think of the Voss algorithm as a filter for random numbers.

The realization of the Voss algorithm which is used in PINK TUNES (the program listing at the end of this column) can be likened to rolling a set of 5, four sided dice whose faces bear the numbers 0-3. We get the random number that we'll use as the pointer to the list of candidate notes by adding together the numbers on the exposed face of each die (I know, a 4 sided die won't have an upper face, that's not the point).

If we consistently rolled all 5 dice, we would still produce too random a number; even through, as any crapshooter can tell you, the probability is that the total of the faces will be somewhere in the middle of the range of possible numbers — just as a pair of six sided die "like" to come up 7.

The trick is not to roll all 5 dice every time, but rather to come up with a scheme that most frequently rolls one or two and infrequently rolls all 5. Since the random number that is produced is always a total of the 5 dice, this produces a series of numbers that most frequently vary only slightly from one another while still permitting periodic large changes.

Voss's scheme (and ours) is to maintain a 5 bit "pinking counter" (our term) which is incremented each time we get ready to generate a new pink number. The new value of the pinking counter is compared to the old and only those "die" which correspond to bits in the counter which have changed are rolled.

The rest of the program is "overhead". As I mentioned in the beginning, PINK TUNES actually generates a 4 part harmony (provided that we supply it with harmonizing notes in the candidate list) and the program must keep track of how long each of the notes in the 4 parts is to play and allow for the updating of the candidate list and recognize a limited number of commands from the computer's keyboard.

The fully documented listing is the best place to go to see how it all works (it's in your best interests to understand it as fully as possible) and specific details and asides are covered in the boxes.

After entering the program and its data base (note part of the program is on page zero, part is on page one and the data base and working registers are on page zero), first save a copy on tape. If something goes crazy, you don't want to have to enter it all again.

Set up the synthesizer and start running the program starting at the hard start location of $0003. The data that you loaded is for the pentatonic scale composition that I mentioned in the opening paragraph and you should immediately hear the synthesizer producing the composition. It should go without saying that you will undoubtedly have to call the tuning function (control key #1) and tune the oscillators before it makes music.

You have the ability to change the candidate note list while the program is running simply by pressing keys on the keyboard, but bear in mind that the candidate list is 16 notes deep. As you enter a new note, the one that was entered "16 notes ago" disappears from the list. If any of the 16 notes are inharmonious, the program will periodically produce discordant sequences.

With PINK TUNES running, three of the computer's control keys have meaning:

Key 0 "scrambles" the random number generator to produce a new tune. This is really only useful if you are in the cyclic mode (see box).

Holding key 1 provides a tuning function by causing all 4 outputs to produce a triggered middle C.

Touching key #2 initiates a muted shut-down of the synthesizer and branch back to the monitor, allowing changes in the memory locations described in the boxes.

After making changes using the monitor, always start the program running again from the soft start location $000B.

The program runs very nicely, but is experimental and not intended as a finished product. Skillful polishing should reduce its length by at least 15-20% and it would be nice to make changes in timing, etc. "on the fly" without having to shut down the synthesizer.

At the same time that the program is primarily "just for fun", don't dismiss it as trivial. It definitely produces 4 part harmonies and even those that are not directly useable in a composition can serve as inspirational lubrication to the gears of creativity. If you're involved in producing commercial jingles, this is a terrific tool.

As you play with the program you will begin to get a feel for how various probabilities affect the composition and you're sure to learn some things about composition that you never knew before.

Finally, a very special thanks to Bob Yannes who sent me a listing of a similar program (PINK FREUD) which generates 4 part canons on a P4700/3. I haven't reviewed this program thoroughly yet, but knowing Bob it's sure to be neat. I'm sure that he wouldn't mind my sharing copies of the listing with anyone who sends a SASE.

'Til next time, my best to all.



NOTE DURATIONS



Each of the 4 output channels has associated with it its own duration timer and two variables in the computer's memory which determine what characteristics the time values of the notes produced by that channel will have. In the interest of convenience, we'll name these two variables MASK and TIME; or, simply M and T.

We need to think of each of these variables as being composed of a high half-byte (hhb) and a low half-byte (lhb). The hex number $F3 (an arbitrary example) has an hhb of $F and an lhb of $3. This is necessary because the half-bytes determine two separate parameters.

The lower half-bytes of MASK and TIME (M1 and T1 respectively) interact to determine what time values are possible from a given channel. A channel can be restricted so that it produces only 1/16 notes or 1/16 and 1/8 notes or a wide variety of other possibilities as summarized in the table below:


Note that this is a partial table intended only to demonstrate the pattern.

Other combinations of M1 and T1 produce other possible time values. Some combinations not listed will produce undesirable results.

The high-half-bytes of MASK and TIME (Mb and Th) interact to determine the probability that the note being produced by that channel will be dotted (its duration extended by half of its actual value).

In actual practice, it is most convenient to set Mh to $F and regulate the probability using only Th. The influence of Th on the probabilities of a dotted note is illustrated below:

Th Probability of dotted note
$8 one in two
$4 one in four
$2 one in eight
$1 one in sixteen
$0 zero


EXAMPLE: A channel which has MASK and TIME values of $F3 and $11 respectively will be capable of producing 1/16, 1/8, 1/4 and 1/2 notes with a one in sixteen probability of the note being dotted. A channel with M and T of $F0 and $01 will produce nothing but 1/16 notes, none of which will be dotted.

The page zero addresses of the MASK and TIME parameters for the four output channels are given below:




TEMPO



By using the MUS-1 subroutine LOOK to gather data from the AGO keyboard, PINK TUNES follows our standard protocol of using the keyboard encoder clock rate as the system master clock. Analog control of tempo may be provided by varying this clock rate as has been mentioned in previous columns.

PINK also has a variable at zero page location $A9 which gives gross digital control of tempo. The recommended range of values for this variable are from $FF (far too fast) to $F0 (insanely slow).



GLIDE AND TRANSPOSE



PINK uses the MUS-1 QuASH drivers (NOTE) and therefore allows for both independent pitch transpositions of any and/or all 4 channels as well as providing a means of enabling or disabling glides.

Though not strictly true, it is most convenient to think of these variables as being divided into high half-byte and low half-byte with the hhb controlling glide ($8 turns the glide on, $0 turns it off) and the lhb determining transposition. For example, a channel which has this transposing variable set to $8C will have its glide turned on and be playing notes an octave higher than the actual note selected by PINK.

Here are the transposing variable addresses:




CYCLE CONTROL



The variable at zero page location $D3 controls the number of notes which will be played before the cycle repeats. Changing the contents of this location to $20 (for instance) will cause 4 bars of eighth notes to be played before the tune repeats. $40 would produce 8 bars of eighth notes.

Setting the contents of the location to $00 amounts to enabling a "free run" mode in which the patterns do not repeat (in practical terms).

If you want to get really fancy, you can change program location $188 from its current value of 85 (STA to the zero page) to EA (a NOP) and the result will be that on successive cycles) the time values of notes will not change but the actual notes played will, producing a strong rhythmic tie from cycle to cycle. It also doesn't always work, sometimes a repeating loop will be entered anyway. Other times the duration of a tune will be 2 or more times as long as the actual cycle time.

To change a cyclic tune, touch control key 0.



DE-PINKING



To get some feel for the effect that the Voss pink-ing algorithm has on the composition, you may want to change it slightly. There are a couple of easy ways that this can be done. By changing the current instruction at program location $11C from $45 (Exclusive-OR on the zero page) to $EA (a NOP), you slightly de-pink the note selector, making it somewhat more random. You may have to listen a while before you notice the difference, but there is one.

To completely eliminate the Voss algorithm make these substitutions beginning at location $118; A9 FF EA EA EA EA. This change is equivalent to rolling all 5 of our alleged 4 sided dice each time a new note is selected and will produce changes that even a tone deaf aborigine would recognize.



THE SYNTHESIZER



The module complement of a P4700/J is not large enough to do a true 4 voice, 4 part composition; since this package has only 3 oscillators. Even lacking a true 4th voice, however the 4th harmony part can still be put to good use.

Here is the most universal of the patches used during the development of PINK TUNES:


Note that the 4th harmony part (from channel D of the QuASH) is used to set the center frequency of the VCF.

In use, it is handy to think of channel A as a lead voice, channel B counter-point and channel C bass line. Using this concept, the channel C oscillator would ordinarily be tuned an octave below channels A and B.



THE CANDIDATE NOTES



Selection of the candidate notes that you give PINK TUNES and the order in which they're entered play a big part in the feel of the final composition. As an obvious example, the pseudo-pentatonic scale resulting from entering only accidentals (sharps and flats) tends to produce oriental sounding compositions.

The selection of notes is "pinked" on a compositional (rather than a per-channel) basis, which means that the 4 notes being played at any one time tend to cluster around a relatively short series of entries in the candidate table. The significance of this is that it allows statistical control of changes in key signature. For example, entering the candidate sequence C1, E1, G1, C2, E2, G2, C3, G2, A2, F2, D2, A1, F1, D1, F1, A1 will produce a composition that periodically changes from the key of C to D minor.

It is important to remember that the candidate table will always contain 16 notes and in order to produce consistant harmonies, all 16 notes must be harmonious. Also remember that notes at the ends of the table (oldest and newest entries) have a lower probability of being played than the notes in the middle.



(Click image for higher resolution version)


(Click image for higher resolution version)


More from these topics


Browse by Topic:

Algorythmic Composition

Composing / Art

Computing



Previous Article in this issue

Name That Tone

Next article in this issue

Industry Notes


Publisher: Polyphony - Polyphony Publishing Company

The current copyright owner/s of this content may differ from the originally published copyright notice.
More details on copyright ownership...

 

Polyphony - Jul/Aug 1978

Donated & scanned by: Vesa Lahteenmaki

Feature by John Simonton

Previous article in this issue:

> Name That Tone

Next article in this issue:

> Industry Notes


Help Support The Things You Love

mu:zines is the result of thousands of hours of effort, and will require many thousands more going forward to reach our goals of getting all this content online.

If you value this resource, you can support this project - it really helps!

Donations for July 2024
Issues donated this month: 14

New issues that have been donated or scanned for us this month.

Funds donated this month: £20.00

All donations and support are gratefully appreciated - thank you.


Magazines Needed - Can You Help?

Do you have any of these magazine issues?

> See all issues we need

If so, and you can donate, lend or scan them to help complete our archive, please get in touch via the Contribute page - thanks!

If you're enjoying the site, please consider supporting me to help build this archive...

...with a one time Donation, or a recurring Donation of just £2 a month. It really helps - thank you!
muzines_logo_02

Small Print

Terms of usePrivacy