The Machine Can Sing
C64 BASIC has no sound keyword at all — because sound here isn't a word, it's a chip. The SID lives in memory at 54272, and a handful of POKEs give it a note, a voice, and a sound that moves while your program runs.
The Spectrum sang with one word: BEEP. Search C64 BASIC for the same and you'll find
nothing — there is no sound keyword. That's not a gap; it's a clue. Sound on the C64
isn't a command, it's a chip — the SID, one of the most famous sound chips ever made,
sitting in memory at 54272. You play it the way you light the screen: by POKE. It
takes more pokes than BEEP did — but in return you get to choose the shape of the sound,
not just its pitch.
Milestone 1 — one note, by hand
A note needs four things set: how loud, how the note rises and falls, what pitch, and which voice. Each is a register — an address — in the SID's block at 54272:
10 POKE 54296,15
20 POKE 54277,0
30 POKE 54278,240
40 POKE 54273,17
50 POKE 54272,37
60 POKE 54276,17
70 FOR T=1 TO 800
80 NEXT T
90 POKE 54276,16
Line 10 sets the volume (54296, range 0–15). Lines 20–30 set the envelope — how
the note attacks, decays, sustains, and releases (54277 and 54278); here it rises
instantly and holds. Lines 40–50 set the pitch as a two-byte number (54273 high,
54272 low) — roughly middle C. Line 60 is the switch: POKE 54276, 17 picks the
triangle waveform and opens the "gate", which starts the note. The loop holds it, then
POKE 54276, 16 shuts the gate and the note releases.
That's more setup than one note seems to need. But every line is a choice the beeper never gave you — and the next two milestones change just one of them.
Milestone 2 — the same note, a different voice
The SID can make the same pitch sound completely different by changing its waveform —
the shape of the wave it draws. That's the second number in line 60. Triangle (16) is soft
and flute-like; sawtooth (32) is bright and buzzy. Change one byte:
10 POKE 54296,15
20 POKE 54277,0
30 POKE 54278,240
40 POKE 54273,17
50 POKE 54272,37
60 POKE 54276,33
70 FOR T=1 TO 800
80 NEXT T
90 POKE 54276,32
POKE 54276, 33 is sawtooth (32) plus the gate (1); POKE 54276, 32 closes it. Same
note as before, but listen to the difference in tone:
Four waveforms wait behind that one register: triangle (16), sawtooth (32), pulse
(64), and noise (128). The beeper had one voice; the SID hands you a palette of them.
Milestone 3 — a sound that moves
Here's what BEEP truly couldn't do. The SID keeps playing on its own while your program
runs, so you can change its pitch as it sounds — a loop that pokes a falling frequency
makes a downward swoop, the classic laser zap:
10 POKE 54296,15
20 POKE 54277,0
30 POKE 54278,240
40 POKE 54276,33
50 FOR F=200 TO 20 STEP -3
60 POKE 54273,F
70 NEXT F
80 POKE 54276,32
The gate opens once (line 40). Then the loop pokes the high byte of the pitch from 200
down to 20, and the note slides down with it before the gate closes. RUN it:
The note isn't a fixed thing you trigger and wait for — it's a chip you can keep talking to while it plays. Sweep up for a power-up, down for a zap, fast for a blip, slow for a siren.
When it doesn't work
- Total silence. The most common cause: volume never set.
POKE 54296, 15first, every time. Also check the gate — a note only sounds afterPOKE 54276opens it. - The note never stops. You opened the gate but never closed it. Poke the waveform
register again with the gate bit (
1) removed —17becomes16,33becomes32. - A click, then nothing. Your envelope released instantly. Set sustain so the note holds
while the gate is open —
POKE 54278, 240is full sustain. ?ILLEGAL QUANTITY ERROR. A poke value ran past 255. Pitch is two bytes for a reason — split anything over 255 across54273(÷256) and54272(remainder).
Before and after
You started with a machine that has no sound keyword and finished playing a note, switching
its voice, and sweeping its pitch in flight — all by POKEing the SID. The idea underneath:
sound on the C64 is a chip at 54272, not a command — set volume, envelope, pitch, and a
waveform-plus-gate, and the SID sings.
Try this
- Noise for an explosion. Change the waveform to
128+gate (129on,128off) and drop the pitch low. - A rising power-up. Sweep the frequency up instead of down —
FOR F=20 TO 200. - A two-note jingle. Play one pitch, close the gate, change
54273/54272, open it again — a tiny tune.
What you've learnt
- The C64 has no sound keyword; sound is the SID chip at 54272, played by
POKE. - A note needs volume (
54296), an envelope (54277/54278), a pitch (two bytes,54273/54272), and a waveform + gate (54276). - The gate bit (
+1) starts a note; removing it releases the note. - The same pitch on a different waveform is a different voice — and you can change the pitch while it plays.
What's next
The SID has three voices, not one — three notes at once, the secret behind the C64's music.
That's a game's job, not a primer's. Next we turn from output to input: in Unit 12 we
PEEK address 56320 and read the joystick.