Versatile micro reviewed
Gary Herman POKEs around Commodore's new 64K micro and comes up with some interesting noises.
Marketed in Britain as a direct competitor to the BBC micro, the Commodore 64 emerges well out of the comparison. With the price now down to around £250 (you'll have to pay extra for a specialised cassette recorder to store programs and data), it is without doubt a serious contender for what is generally acknowledged as the BBC's crown.
The 64's major failing is its BASIC, which seems to have been produced in a hurry — probably in order to get the machine into the shops quickly. As a result, there are few facilities for structured programming or program editing (although the screen editing is a joy) and complex sound and graphics facilities have been tacked on to a more-or-less standard BASIC in the form of machine code routines accessed by POKEing direct into memory locations. When it comes to sound-making, this is not necessarily a bad thing. While you lose in terms of clarity (programs tending to look like forests of numbers), you gain in speed and flexibility. You don't have to be a programming genius, either, to write suitable subroutines which can stand in for BASIC commands.
There are three channels (or 'voices') to play with — each independently controlled by up to seven sound parameters. The relevant memory locations are numbered 54272 through 54278 for channel one, 54279 through 54285 for channel two and 54286 through 54292 for channel 3. BE WARNED: the manual contains a number of misprints when dealing with these locations, and it's easy for a programmer to make similar mistakes. Once you know the memory locations for channel 1 (and these are accurately printed in the manual), just add seven to find and use the corresponding locations for channel 2 and another seven to find the locations for channel 3.
Sound is enabled for all three channels by POKEing a volume setting (0 to 15) into location 54296. The seven parameters for each channel are (in order of memory location) a low and a high byte to set note frequency (these two are read together and are the single most confusing figures in the whole operation); a low and a high byte to set pulse width (only necessary when a pulse or square waveform is specified); a byte to set the waveform (17 for triangular, 33 for sawtooth, 65 for pulse and 129 for white noise); a byte to set the attack/decay characteristics of the note and a byte to set the sustain/release characteristics. These latter envelope parameters (ADSR) must be entered into a program first, followed by waveform and any other required settings. Default values are zero.
A note continues playing until it is turned off (by resetting the volume or by setting the waveform to zero), so FOR...NEXT loops or other delaying techniques can be used to create crotchets, quavers, dotted notes and so on.
The combination of delays and the ADSR envelope settings can create interesting decay and sustain effects. All this can also be put inside a FOR...NEXT loop to create complex envelopes for experimental music and sound effects. Try this (on channel one only):
10 V = 54296: LF = 54272: HF = 54273: W = 54276: AD = 54277: SR = 54278
20 L = 75: H = 50: DUR = 100: ST = 10: A = 9: S = 0: DEL=10: WF= 17
30 FOR X = 1 TO DUR STEP ST: VOL= 15—3.3*LOG(X)
40 POKE V, VOL
50 POKE AD, A: POKE SR, S
60 POKE W, WF
70 H=ABS (H-VOL)
80 POKE HF, H: POKE LF, L
90 FOR D = 1 TO DEL: NEXT D
100 NEXT X
As it stands, this program should produce a tremulous flutey sound. Changing any of the values in line 20 (especially ST, S and WF) will create more interesting effects. Setting H low should give a fruity bass sound (the 64's range is a full eight octaves). Replacing VOL in line 70 by 2*VOL will give a marked alternation between high and low frequencies. To repeat the sound just add '110 GOTO 30'. Or try changing the values of the line 20 variables by inserting an appropriate line 105 first. The possibilities are enormous.
Since all the values are POKEd in this way, there is scope for fascinating experiment. Unfortunately, the Commodore manual has hardly anything to say about the machine's memory map (and most of that is about graphics). I ran a simple program to POKE different values into each of the locations between 54272 and 54296 and discovered some interesting, if unpredictable effects (beware of POKEing anything but zero into 542951). POKEing different values into the waveform locations (54276, 54283 and 54290) gives a wider range of sounds than the manual mentions (try 85, 21 or 141). it also seems that POKEing some locations in an otherwise unused channel can filter sound being produced in another channel — very valuable for the computer musician.
Finally, using GET AS to scan the keyboard in order to play in real time enables you to control the sustain to some extent by varying the amount of time for which you depress a key. Rapid key strokes are also 'memorised' by the computer to make a form of primitive sequencer.
The 64 is obviously a machine that will repay intelligent investigation. A hi-fi outlet and ports which are clearly identified in the manual help its reputation as a serious machine (a reputation enhanced by the pleasantly professional keyboard). There is some ready-written software for composers but, unfortunately and typically, I'm afraid, it seemed impossible to get hold of. Perhaps a few queries from musicians will help suppliers buck up their ideas.
Feature by Gary Herman
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!