For anyone wondering how you can get sound this good out of the PC Speaker, it's down to making clever use of the timer chip that drives the speaker to implement pulse-width modulation. The timer chip has two modes that are useful for making sound: square waves and a single-shot mode that makes the output high until the timer runs out, then turns it low until reset by a software command. Square wave mode is cheap and what's used for most PC Speaker sound effects, as you only need to write to the chip when you want the frequency changed. PWM is very different. In this case, you use the single-shot mode and change the value used every time you reset it, and you reset it very frequently. How frequently? Well, that depends on your output sample-rate. 16kHz is pretty typical. Contrast it to square-wave mode usage where 140Hz is a common frequency to change settings. Not even 1% of the PWM rate. The catch with implementing PWM is that you need to be precise about your timing, and that ends up being very CPU-intensive. You have no DMA, so you have to do the timing yourself. Coming up with a way to do both PWM and running a game is really impressive.
This is a technique commonly used on the 8 bit ZX spectrum, which in the base had no audio HW, only a 1 bit "PC speaker" fully controlled by the CPU. If the entire 3.5Mhz CPU power was used for PCM audio, something similar to the Pinball on the i386 was created. ua-cam.com/video/1eW39C1hQgU/v-deo.html ua-cam.com/video/yJy45MHrPjc/v-deo.html Let's say the 3.5Mhz Spectrum is equivalent to about 2Mhz of that i386. In ASM code, this is a manageable audio technique even during gameplay. CPU at 33Mhz can handle it.
Some other games and software also could use the speaker like this. Pinball Illusions' intro music was my favorite track, that also played through the speaker. And the popular impulse tracker also played many tracked music. Do you know gasmask chapter 2? Or church of house? That was the sound at that times... :) You may find them on the modarchive.
More amazing is that they were able to have the game playable while playing back PWM audio. It's amazing because the technique requires precise timing of writing to the timer chip that runs the speaker, and that tends to be really heavy on the CPU, yet somehow they managed to not only mix a 4-channel MOD file, but take user inputs and draw full-screen graphics for the game as well. When I say it's heavy on the CPU, I mean it. The famous 8088MPH demo uses it in the closing credits (the rest of the music being cheap beeps), and after mixing the music and playing it through the speaker, only has enough CPU time left over on an 8088 to put a few text-mode characters on the screen.
It required good programming skills since the PC speaker has no DMA (direct memory access). It usually stalls the CPU while playing back PCM audio. Also, the sound quality and loudness is very limited in a PC-speaker. But it was impressive at the time. I played the game on my first PC, a 40 MHz AMD 386, and it was very smooth even with the highest audio quality selected.
Yep, I'm using a standard PC-speaker (0,5w). The sound was recorded using the built-in camera mic. I have a newer video (gameplay) with better sound. The mic was placed next to the PC speaker this time.
For anyone wondering how you can get sound this good out of the PC Speaker, it's down to making clever use of the timer chip that drives the speaker to implement pulse-width modulation.
The timer chip has two modes that are useful for making sound: square waves and a single-shot mode that makes the output high until the timer runs out, then turns it low until reset by a software command. Square wave mode is cheap and what's used for most PC Speaker sound effects, as you only need to write to the chip when you want the frequency changed.
PWM is very different. In this case, you use the single-shot mode and change the value used every time you reset it, and you reset it very frequently. How frequently? Well, that depends on your output sample-rate. 16kHz is pretty typical. Contrast it to square-wave mode usage where 140Hz is a common frequency to change settings. Not even 1% of the PWM rate.
The catch with implementing PWM is that you need to be precise about your timing, and that ends up being very CPU-intensive. You have no DMA, so you have to do the timing yourself. Coming up with a way to do both PWM and running a game is really impressive.
Whoa, I've been wondering about this for almost 30 years now. Finnally an answear! Thank you.
THIS IS PC SPEAKER!? HOLY CRAP
Yep.
Yep. PWM by the sounds of it. I'm impressed the developers were able to find enough CPU to do it and still run a game.
To in the sinclair spectrum i remaber Game with realistic sound effects
This is a technique commonly used on the 8 bit ZX spectrum, which in the base had no audio HW, only a 1 bit "PC speaker" fully controlled by the CPU. If the entire 3.5Mhz CPU power was used for PCM audio, something similar to the Pinball on the i386 was created.
ua-cam.com/video/1eW39C1hQgU/v-deo.html
ua-cam.com/video/yJy45MHrPjc/v-deo.html
Let's say the 3.5Mhz Spectrum is equivalent to about 2Mhz of that i386. In ASM code, this is a manageable audio technique even during gameplay. CPU at 33Mhz can handle it.
Pure Magic it was ... Pure Magic
Thank you for not shakily handholding a stupidphone in an angle while making the video.
Some other games and software also could use the speaker like this. Pinball Illusions' intro music was my favorite track, that also played through the speaker. And the popular impulse tracker also played many tracked music. Do you know gasmask chapter 2? Or church of house? That was the sound at that times... :) You may find them on the modarchive.
To alone in the dark was impressive sound effect Just with pc speaker
Sounds amazing for a pc speaker owo
More amazing is that they were able to have the game playable while playing back PWM audio. It's amazing because the technique requires precise timing of writing to the timer chip that runs the speaker, and that tends to be really heavy on the CPU, yet somehow they managed to not only mix a 4-channel MOD file, but take user inputs and draw full-screen graphics for the game as well. When I say it's heavy on the CPU, I mean it. The famous 8088MPH demo uses it in the closing credits (the rest of the music being cheap beeps), and after mixing the music and playing it through the speaker, only has enough CPU time left over on an 8088 to put a few text-mode characters on the screen.
Why all games don’t use this Technology at the time . No adlib or sound blaster needed
It required good programming skills since the PC speaker has no DMA (direct memory access). It usually stalls the CPU while playing back PCM audio. Also, the sound quality and loudness is very limited in a PC-speaker. But it was impressive at the time. I played the game on my first PC, a 40 MHz AMD 386, and it was very smooth even with the highest audio quality selected.
I never understood how this was possible. And why no one else was able to pull it off.
It is because it used so much CPU. You should check the game Mach 3.
Are you sure you didn’t select a sound card on accident? This sounds fuckin amazing
Yep, I'm using a standard PC-speaker (0,5w). The sound was recorded using the built-in camera mic.
I have a newer video (gameplay) with better sound. The mic was placed next to the PC speaker this time.
I am shocked this is a PC Speaker doing all this