Special Sound is a short music/sound demonstration that sweeps three simultaneous tone channels of the TS2068’s AY-3-8912 sound chip through a rising frequency sequence. A FOR loop drives register pairs so that three voices play harmonically offset pitches (x, x+8, and x+12) while shared amplitude registers are held at maximum volume (15). After the sweep completes, a brief shutdown sequence silences all channels and an envelope register is set before the program waits for a keypress and loops indefinitely.
Program Structure
The program consists of just four logical sections compressed into three executable lines:
REMheader (line 0) — title and copyright notice, no executable content.- Line 10: initialises
y=0and opens aFORloop,x=0 TO 140. - Line 20: issues a single multi-register
SOUNDstatement per iteration, thenNEXT xcloses the loop. - Line 30: shutdown
SOUNDcall,PAUSE 0to wait for a keypress, thenGO TO 1— which targets the non-existent line 1, so execution falls through to line 10, effectively restarting the sweep.
AY-3-8912 Register Usage
The TS2068 exposes the AY sound chip through the } (SOUND) keyword. Each SOUND call accepts register/value pairs. The registers used here are:
| Register | Function | Value in loop |
|---|---|---|
| 0 | Channel A fine pitch | x (0–140) |
| 1 | Channel A coarse pitch | y (0) |
| 2 | Channel B fine pitch | x+8 |
| 3 | Channel B coarse pitch | y (0) |
| 4 | Channel C fine pitch | x+12 |
| 5 | Channel C coarse pitch | y (0) |
| 7 | Mixer (tone/noise enable) | 56 (all tones on, noise off) |
| 8 | Channel A amplitude | 15 (maximum, no envelope) |
| 9 | Channel B amplitude | 15 |
| 10 | Channel C amplitude | 15 |
Mixer value 56 in binary is 00111000, which disables noise on all three channels while enabling tone output — a standard configuration for pure-tone music.
Notable Techniques
- Harmonic offsets: The three voices are pitched at
x,x+8, andx+12respectively. Because AY pitch registers are inversely proportional to frequency, fixed additive offsets produce a consistent (though not perfectly equal-tempered) harmonic spread across the sweep. - Single SOUND call per frame: Grouping all ten register writes into one statement minimises interpreter overhead inside the loop, keeping the sweep reasonably smooth.
- Shutdown sequence (line 30):
SOUND 10,16;8,16;9,16;12,20;13,0sets channel amplitudes to 16 (envelope-driven mode), programs the envelope period (register 12), and resets the envelope shape (register 13 = 0), providing a tidy release rather than an abrupt cutoff. - Restart via GO TO 1:
GO TO 1with no line 1 defined causes the interpreter to find the next available line (line 10), making this a concise infinite-loop idiom without needingGO TO 10. - Variable
y=0as coarse pitch: Holding all coarse pitch registers at zero limits each voice to the lower 8-bit range of pitch values, keeping frequencies in the audible mid-to-high range during the sweep.
Content
Image Gallery
Source Code
0 REM Special Sound Written by Eric Boisvert ©1986 BYTE POWER
10 LET y=0: FOR x=0 TO 140
20 SOUND 0,x;1,y;2,x+8;3,y;4,x+12;5,y;8,15;10,15;9,15;7,56
30 NEXT x: SOUND 10,16;8,16;9,16;12,20;13,0: PAUSE 0: GO TO 1
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.