The 8-bit Guy on youtube has an excellent video covering how early computers and game consoles played sound and music 1.
He has split up his video into 3 sections:
The beeper speaker is a very simple speaker controller by the CPU which can produce clicking noises. The CPU would have to time the clicking noises exactly right to produce the required tone. As it runs all the logic on the cpu it slows down the game and the audio produced is CPU limited.
In the early 1980s computers started coming with dedicated audio chips to take away the load from the CPU.
Each system would have a different number of Voices/Channels. Basically this allows multiple notes to be plays at the same time as each voice/channel can only do one note.
|Commodore 64||3 Voices|
The first 2 voices were only capable of producing square waves. The 3rd voice can only produce a triangle and is used for bass notes. The 4th voice can only produce random noise. The 5th voice was for PCM sample sounds but apparently rarely used.
You can see a visualisation of the wave in a play though of Mario bros 3 in the video by Bizqwit below 2:
Although the C64 only had 3 voices, each one could use whatever waveform it wanted out of the following options:
Here are a few of the sound cards developed for the IBM-PC:
Notice that they both use the same audio chip inside (Yamaha YM3812).
9 Voices were available in this chip and similar to the C64 they were independently programmable so each voice could have its own waveform. Unlike the NES where each voice could only use one waveform.
Audio would be built up of small audio clips called “samples”. The concept of a “Mod Tracker” was developed to take advantage of this capability.