BACK TO BLOG LIST

SUBSCRIBE: RSS ATOM

Sound on the Apple II

by NJB // // Lafayette, CO

© 2025 Nicholas Bernhard

CC-BY-SA 4.0

I have been playing around with making sound on my Apple II. The Apple II had the best sound in home computing back in 1977, because it actually had sound. There was a single-channel speaker inside that could produce beeps and clicks. Neither the Commodore PET nor the TRS-80 had any speakers at the time.

The sound from this speaker came in two varieties: the “bell”, which produced a nice, loud beep, and the “click”. For a very simple game written in BASIC, this was better than nothing. However, if you’re really clever, the click can be manipulated to produce all manner of sounds.

In essence, by producing clicks in rapid succession, higher tones can be produced. What I found is that Applesoft BASIC is fine for simple sound effects, but is just too slow for producing music.

Here’s the best I could come up with:

90 S = -16336
100 FOR I = 0 TO 200 : T = PEEK(S) : T = PEEK(S) : NEXT I

The speaker click on the Apple II is stored in RAM at position -16336 (in decimal notation). The PEEK() command pulls a value from a particular memory address. To produce a click, the PEEK() command is assigned to a variable. One could type T = PEEK(-16336), but it’s faster to assign that number to a variable beforehand, as I did on line 90.

To make things even faster, I put the whole for-loop on line 100. I run the PEEK(S) command twice: this turns the speaker on and off. The two-line program above produces a tone pretty close to F. This was the highest tone I was able to make.

Running various combinations of PEEKs will produce different frequencies. For example, if you have the CPU do some artithmetic in the for-loop, this will slow the computer down enough to produce a lower tone. If the first PEEK uses the cariable S, and the second one uses -16336, that will produce a different tone. If I included a comment in the loop with REM, this slowed things down enough that I couldn’t hear any tone.

I played around with many different combinations, and was able to get about a dozen different notes across one and a half octaves to sort-of work. I also found out that if I ran the loop for too long, the note would go up one semi-tone. Perhaps that was the speaker hitting its stride?

The verdict is that Applesoft BASIC is too slow for creating music on the Apple II. If I wanted to have a little melody play at the start of a program, that would have to be done in 6502 Assembly.

I am curious to see how well Integer BASIC would work for sound, since it was known for being at least ten times faster than Applesoft BASIC. I can also use BASIC for simple sounds. For example, a heartbeat sound, even one that can speed up or slow down, would be very doable. White noise for a jumpscare in a game would be doable, too. I can even imagine a kind of “womp-womp” sound on a game-over screen, if exact pitch isn’t an issue.

Have you had any experience with sound on the Apple II? If you have, email a comment to me and I’ll post it here.

SHOW/HIDE COMMENTS
  • No comments yet.

WANT TO COMMENT?