This program is a collection of sound effects and audio demonstrations implemented as independent BASIC routines, each accessible by running from a specific line number. The effects include a BPO telephone ring, two-tone siren, galloping horses, motor noise, a digital watch beep, and an explosion sequence. Most routines use nested FOR loops with carefully tuned BEEP durations and pitches to simulate acoustic characteristics. The “Stop Tape” warning (line 111) is a reusable subroutine that cycles INK and PAPER colors via a swap idiom and displays a flashing banner across all 22 screen rows. Line 131 uses SOUND with multiple channel parameters for the explosion effect, which is distinct from the BEEP-based routines.
Program Structure
The listing is organized as a set of self-contained sound routines, each preceded by a REM label and occupying a block of lines at round-number boundaries (10, 20, 30, …, 130). There is no menu or dispatcher; the user runs a desired routine by typing GO TO followed by the appropriate line number. Each routine either loops indefinitely with GO TO back to itself, uses STOP, or (in the case of the “Stop Tape” warning) falls through to a continuation message.
Individual Routines
| Lines | Effect | Loop style |
|---|---|---|
| 10–15 | BPO telephone ringing | Infinite GO TO 10 |
| 20–25 | Background ambience | Infinite GO TO 20 |
| 30–31 | Motor running | Infinite GO TO 30 |
| 40–45 | Fast descending scale | Single pass, STOP |
| 50–51 | Two-tone siren | Infinite GO TO 50 |
| 60–61 | Filler sound | Infinite GO TO 60 |
| 70–75 | Warning signal | Infinite GO TO 70 |
| 80–85 | Digital watch | Infinite GO TO 80 |
| 90–100 | Galloping horses | Infinite GO TO 90 |
| 110–120 | Stop Tape warning | Self-contained, exits to demo loop |
| 130–131 | Explosion | Single pass (no loop-back) |
BEEP Technique
All audio except the explosion uses BEEP duration, pitch. Durations are kept very short (as low as .003 seconds) to create percussive or rapid-fire effects. Pitch values are in semitones relative to middle C; negative values (e.g., BEEP .005,-2 in the motor routine) produce sub-middle-C tones. The galloping horses routine (lines 90–100) modulates PAUSE duration using 6-f/5 and 25-f, expressions that tighten the inter-beat gap as the loop variable f increases, then loosen it on the return sweep, simulating acceleration and deceleration.
SOUND-Based Explosion
Line 131 uses SOUND with a multi-register syntax (6,x;7,7;8,16;9,16;12,140;13,1) rather than BEEP, giving direct access to the sound chip’s noise, envelope, and mixer registers. The loop counts x from 30 down to 10, varying the noise period register to sweep the character of the explosion. This is the only routine in the collection that goes beyond the BEEP abstraction.
Stop Tape Warning Routine
Lines 111–120 implement a reusable “Stop Tape” display. A classic color-swap idiom is used: LET c=a:LET a=b:LET b=c alternates INK and PAPER between values 1 and 6 on each of the 22 screen rows, producing a striped flashing banner. FLASH 1 is applied inside the PRINT AT statement. Line 115 prints to stream #1 (the lower screen) to show a prompt without disturbing the main display. The keypress detection loop at lines 116–118 plays a BPO-style ring tone; INKEY$ is checked at line 117 and branches to GO TO 119 (CLS and continuation) when any key is pressed. Note that the NEXT g and NEXT f on line 118 reference loop variables whose FOR statements are on line 116, which is syntactically valid but results in the outer loops being abandoned on a keypress.
Potential Anomalies
- The galloping horses routine uses
PAUSE 6-f/5; whenfreaches 20, this evaluates to2, which is still positive, but iffexceeded 30 the expression would go negative —PAUSEwith a negative argument behaves asPAUSE 0, so the loop bounds prevent an actual error here. - Line 118 has
NEXT g:NEXT fbut the enclosingFOR gis opened on line 116 and theFOR floop wraps both. If the keypress branch at line 117 fires, the interpreter jumps to 119, leaving the FOR–NEXT stack in an undefined state; aCLSat line 119 does not clear the stack, which could cause issues if this routine is embedded in a larger program. - Line 120 loops indefinitely on a
PRINTstatement with no exit, intended only as a demonstration placeholder.
Key BASIC Idioms
- Nested
FORloops with computed pitch arithmetic (e.g.,f+g-h,g+h-f,h+f-g) in the background sound routine to generate pseudo-random tonal variation. - Immediate
GO TOat the end of a block to create infinite sound loops without usingGO SUB. - Combined
BEEP/PAUSEinterleaving to shape rhythm, as in the telephone and digital watch routines.
Content
Image Gallery
Source Code
1 REM
2 REM A collection of sounds for use in programs
3 REM Taken from the book "Better programming for your Spectrum and ZX81"
4 REM Entered by G F Chambers
5 REM
10 REM BPO telephone ringing
11 FOR f=1 TO 10:FOR g=1 TO 2:FOR h=1 TO 8:BEEP .03,24:NEXT h:PAUSE 6:NEXT g:PAUSE 50:NEXT f
15 PAUSE 200:GO TO 10
20 REM Background sound
21 FOR f=2 TO 10 STEP 2:FOR g=1 TO 10 STEP 2:FOR h=1 TO 10 STEP 2:BEEP .1,f+g-h:BEEP .1,g+h-f:BEEP .1,h+f-g:NEXT h:NEXT g:NEXT f
25 PAUSE 200:GO TO 20
30 REM Sound of motor running
31 BEEP .005,5:BEEP .005,-2:PAUSE 2:GO TO 30
40 REM Fast descending scale
41 FOR f=1 TO 50:BEEP .05,60-f:NEXT f
45 STOP
50 REM Sound of 2-tone Siren
51 BEEP .6,18:BEEP .7,14.5:GO TO 50
60 REM Filler Sound
61 FOR f=1 TO 10:BEEP .1,1+f:BEEP .1,10:NEXT f:GO TO 60
70 REM Warning signal
71 FOR f=1 TO 30:BEEP .05,20:BEEP .05,0:NEXT f
75 GO TO 70
80 REM Digital Watch
81 FOR f=1 TO 10:BEEP .5,40:PAUSE 7:BEEP .5,40:PAUSE 35:NEXT f
85 GO TO 80
90 REM Galloping Horses
91 FOR f=10 TO 20:BEEP .003,10:PAUSE 6-f/5:BEEP .003,5:PAUSE 6-f/5:BEEP .003,1:PAUSE 25-f:NEXT f
100 FOR f=20 TO 10 STEP -1:BEEP .003,10:PAUSE 6-f/5:BEEP .003,5:PAUSE 6-f/5:BEEP .003,1:PAUSE 25-f:NEXT f:GO TO 90
110 REM A STOP TAPE warning
111 LET a=1:LET b=6:FOR i=0 TO 21
112 PRINT AT i,8; INK a; PAPER b; FLASH 1;" STOP THE TAPE "
113 LET c=a:LET a=b:LET b=c:NEXT i
115 PRINT #1; AT 1,3; INK 9;"PRESS ANY KEY TO CONTINUE"
116 FOR f=1 TO 10:FOR g=1 TO 2:FOR h=1 TO 10:BEEP .03,24:NEXT h:PAUSE 6:NEXT g
117 IF INKEY$ <>"" THEN GO TO 119
118 NEXT g:NEXT f
119 CLS
120 FLASH 0:PRINT AT 10,1;"YOUR PROGRAM CONTINUES HERE":GO TO 120
130 REM An Explosion
131 FOR x=30 TO 10 STEP -1:SOUND 6,x;7,7;8,16;9,16;12,140;13,1\{16}\{0}:NEXT x
9999 SAVE "sounds"
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.