THE SCORE
In f03c/04 you wired a passive piezo buzzer to the 6502 breadboard and toggled a pin at 440 Hz. The clicks merged into a tone. That was the irreducible minimum of electronic audio: a voltage, switched fast enough that a speaker cone interprets the switching as sound.
Real game hardware from the same era was more sophisticated. The Atari 2600's TIA chip had two audio channels — AUDC set the distortion type, AUDF set the frequency, AUDV set the volume. Write to those registers and the chip oscillated at your chosen frequency.
The Commodore 64 went further. Its SID chip — MOS Technology 6581, 1982 — had three independent oscillators, ADSR envelope generators, a programmable filter, and a ring modulator. Not a tone generator: a synthesizer, integrated into a single chip so an eight-bit computer could produce music that sounded like music.
The WWTBAM score — composed by Matthew Stiff for the 1998 ITV broadcast — is not SID output. It is a full orchestral recording, played back as a digital audio file. By 1998, PC sound cards had DACs — Digital-to-Analog Converters — that accepted digital samples and produced the analog signal a speaker needs. The path from our game code to the speaker is:
game code → fork → exec(aplay) → ALSA → sound card DAC → speakerThat is the same path the buzzer sat at the end of. The level of abstraction changed. The destination did not.

The show's score was engineered in layers. Quiet strings in the opening questions. The arrangement thickened as the prize climbed. Past the first safe level, a different cue entirely — the kind that made the studio audience hold their breath. The music was not decorative. It told the audience how scared to be, question by question.
In g01a the game
already knows its tier: level, safe_level, the prize strings in
PRIZES[]. What it lacks is a mechanism to play audio while the game
loop continues in the foreground. That mechanism is fork() and
exec() — the same tools
c05 used to build a
multi-process pipeline.
A child process replaces itself with aplay. The parent continues
running the game loop. When the tier changes, the parent sends SIGTERM
to the child, reaps it with waitpid, and spawns a new child with the
next WAV file. The code change is small. The effect is not.
The implementation pages add a music.c module to the g01a terminal
game: the audio design and API, the start_music implementation using
fork and execlp, the stop_music implementation using kill and
waitpid, and the integration into the game loop. Start at Setup.
The Audio Mechanism
g01c adds one module to the g01a terminal game: music.c, with two
functions.
pid_t start_music(const char *path);
void stop_music(pid_t pid);start_music calls fork(). In the child process, execlp replaces
the process image with aplay. The parent receives the child's PID and
returns it. stop_music sends SIGTERM to that PID and calls waitpid
to reap the child before returning.
The game stores the PID in a local variable music_pid inside
game_loop. Tier transitions — when level reaches 5 or 10 — stop
the current track and start the next. Win, loss, and walk-away all call
stop_music before returning.
The Music
Three royalty-free WAV files in a music/ directory:
| File | Tier | Questions | Mood |
|---|---|---|---|
music/tier1.wav | 1 | 1–5 | Calm, low stakes |
music/tier2.wav | 2 | 6–10 | Tense, rising urgency |
music/tier3.wav | 3 | 11–15 | Dramatic, final five |
The setup page specifies where to find suitable royalty-free tracks. The solution repository does not commit audio files — the tester generates a synthetic silence fixture.
The Project
Source is the g01a terminal game with two additions:
| File | Change |
|---|---|
music.h | New — start_music and stop_music declarations |
music.c | New — fork + execlp + kill + waitpid implementation |
game.h | Add #include "music.h" |
game.c | Add music_pid local; tier-switch calls; stop on all exit paths |
main.c, load.c, display.c | Unchanged |
Build and run:
make re
./game questions.txtThe Tester
The companion repo contains test.sh. It tests the music module
directly (process lifecycle: spawn, alive, killed, no zombie) and tests
tier-switching logic through a headless stub that drives the game loop
with scripted answers, without SDL2 and without audio output.
git clone https://github.com/thecodingidiot-com/g01c-the-developer-acoustic.git
cp g01c-the-developer-acoustic/test.sh ~/g01c-practice/
bash test.shThe Companion Repo
The reference solution is at
github.com/thecodingidiot-com/g01c-the-developer-acoustic.
The solution/ directory contains all seven source files, a Makefile,
questions.txt (30 questions), and test.sh.
This is the last chapter in the WWTBAD series. After g01c, the curriculum builds Dimitrio — a game where movement, collision, and sound serve gameplay rather than presentation.