Hey, let’s build a retro synth music player! (Part 2)

To make a music synthesizer, we need to understand how audio works. It’s a complicated subject and my goal isn’t to explain it fully here. I’ve provided links to better resources. We just need a minimal of understanding to build our synthesizer.

Audio is made by vibrations. Your computer’s speaker vibrates, causing the air around it to vibrate, and that air’s vibration is picked up by your ears.

A musical note is generated by vibrations (waves) at specific frequencies (the note’s pitch). A vibration at 440 Hz (i.e. having your speaker vibrate back and forth 440 times in one second) is heard as an A note. (Hz is short for Hertz and is a unit of frequency that just means “cycles per second”.) Notes on a musical scale each vibrate at specific frequencies and loudness. The higher the frequency, the higher the pitch of the note. Scales are a complicated subject, so I won’t go into too much more detail. The loudness of a note is dictated by the amplitude of the wave.

Our music synthesizer is going to emulate how retro game systems and consoles from the ’80s worked. These generated sounds by playing tones with specific shapes, aka “waveforms”, that were easy to easy to produce by these chips. These were typically square waves, triangle waves, or “noise” (randomness).

Watch this visualization of the Legend of Zelda theme to see what I mean. Each quadrant is playing an instrument, and you can clearly see the shape of each one. The bass tones are in the lower left and the snare drum effect is in the bottom right.

Listen to how each shape sounds and notice how the higher pitch sounds make a wave with more peaks and troughs in the same amount of space (or time). See how bass in the lower left has fewer peaks and troughs since it’s playing at a lower frequency than the square waves in the top two quadrants? Pay attention to the amplitude of the waves as well. Towards the end of the song, you can see them gradually decrease until they go silent.

Look at how the snare drum sound is achieved with a really noisy looking wave. That’s because it’s a noise wave, which looks like random peaks and troughs. Noise waves were typically used in old game systems for explosion sounds, crowd noise, ocean waves, and snare drums.

There’s one last thing to note in the video: there are only ever four instruments playing at any one time! Old game systems and computers were often limited in the number of instruments they could play at once. Our synthesizer will limit itself to a fixed number of instruments as well just to make it authentic.

Finally, watch the video below by The 8-Bit Guy for a really good summary of how old game systems played audio. This is how we’re going to do things too!

Okay, that’s enough for today. Next time we’ll talk about ADSR envelopes.

For a way deeper article on musical synthesis, see this article.