Special Sound

This file is part of Byte Power September 1986. Download the collection to get this file.
Developer(s): Eric Boisvert
Date: 1986
Type: Program
Platform(s): TS 2068
Tags: Sound

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:

  1. REM header (line 0) — title and copyright notice, no executable content.
  2. Line 10: initialises y=0 and opens a FOR loop, x=0 TO 140.
  3. Line 20: issues a single multi-register SOUND statement per iteration, then NEXT x closes the loop.
  4. Line 30: shutdown SOUND call, PAUSE 0 to wait for a keypress, then GO 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:

RegisterFunctionValue in loop
0Channel A fine pitchx (0–140)
1Channel A coarse pitchy (0)
2Channel B fine pitchx+8
3Channel B coarse pitchy (0)
4Channel C fine pitchx+12
5Channel C coarse pitchy (0)
7Mixer (tone/noise enable)56 (all tones on, noise off)
8Channel A amplitude15 (maximum, no envelope)
9Channel B amplitude15
10Channel C amplitude15

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, and x+12 respectively. 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,0 sets 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 1 with no line 1 defined causes the interpreter to find the next available line (line 10), making this a concise infinite-loop idiom without needing GO TO 10.
  • Variable y=0 as 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.

Appears On

Tape-based magazine.

Related Articles

This month we will talk about the envelope generator. To enable the generator you must put the value 16 to...

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.