• Please review our updated Terms and Rules here

Demo of digitized audio through PC speaker

vwestlife

Veteran Member
Joined
May 2, 2008
Messages
5,388
Location
central NJ
Somehow I remembered an old DOS demo called "ATOM.EXE". A check through my disk collection turned up nothing, and it's nowhere to be found on the web. Finally, I found it the old fashioned way: through a USENET binary!

It's mostly a demo of playing digitized audio (a short music clip) through the ordinary PC speaker. According to the demo's text scroll, the audio is 1-bit at 12000 Hz (mono) -- for comparison, full CD-quality audio is 16-bit at 44100 Hz (x 2 channels for stereo). The entire program, including embedded digital audio sample, is only 23K in size!

I'm not sure how much processing power this demo requires. On USENET, one person referred to playing it on a Tandy 1000SX, which is a 7.16 MHz 8088, and the text in the demo itself implies that a 386SX is more than enough power to run it. I recorded a video clip of it from my Compaq PIII-850 laptop, which certainly had much power to spare, but provides a convenient composite video output and PC speaker audio through the line-out jack. I'm quite surprised just how clear the 80x25 color text is through my old Matrox video capture card's composite input -- there's no "color bleed" at all, and you can actually still read the text even on the YouTube clip that I made:

http://www.youtube.com/watch?v=HstgfH9FWV4

I stopped the demo after about four minutes, otherwise it would just keep going and going. What you don't see is that it blinks the keyboard and floppy drive LEDs in time to the music!
 
Way back when I had a program that played MOD files, which were (amiga?) music files that were somewhat similar to a midi file but used digitized samples stored in the file. Three or four voices, I think. The program I had would attempt to play them through the PC speaker. The results were amazing, though no substitute for a real sound card.

I had a 386sx-40 at the time, so horsepower was no problem.
 
Yes, many MOD players could play through the PC speaker. There was also a PC speaker driver for Windows 3.1, but in order to get decent sound, it had to devote all of the CPU time to the audio playback, freezing up your mouse and keyboard until the sound was done.
 
Yes, this is an oldie but goodie demoscene demo.

The reason the audio is so small is the same reason the quality is somewhat terrible; it's 1-bit audio. Typical PC speaker digitized audio was 4-bit (in the case of PCjr/Tandy soundchip tricks), 6-bit (Realsound), or 8-bit (MOD players). The 1-bit trick was popular in the mid 1980s because information and source was published on how to build a small circuit you connected to the parallel port to record your voice.

For voice, it's great. For music, not so much :)
 
There's a piece of software out there (the name currently escapes me) which will let you play MP3s through your PC speaker. I had it running on a 486 laptop. The sound was crap, but I believe the PC "speakers" in those old laptops were actually buzzers, much like what your wristwatch uses to make sound :)

There was a PC at work running Win95 that had the driver to play sound through the PC speaker, but I wiped everything off it and installed pure DOS.
 
There is an MP3 player for 486s and higher but it uses soundcards; since you were on a laptop, most likely it was using the embedded soundcard.

I have an IBM desktop that routes soundcard output to the internal speaker if you don't have any external speakers hooked up. Very neat trick for a desktop computer.
 
I have an IBM desktop that routes soundcard output to the internal speaker if you don't have any external speakers hooked up. Very neat trick for a desktop computer.
Most "business"-class computers with integrated sound include a built-in speaker, because in a corporate environment it removes the hassle of having to give everyone a set of external speakers. The quality of the built-in speaker ranges from horrible to surprisingly good, but compared to what passes for a pair of external speakers these days, it's no big difference. (At my company, most people still use Altec Lansing ACS-90 speakers which Dell used in the late '90s, because the speakers they've shipped with new computers since then are far poorer in quality.)

Anyway, one problem with digitzed audio through the standard PC speaker is that the resulting volume is too quiet. I used to have a program which let you program Tandy-style 3-voice music using BASIC "PLAY" commands and then play it through a regular PC speaker, but you could hardly hear it. It seems like the Atom demo tries to overcome that by overmodulating the audio, which produces a loud but painfully distorted sound.
 
To provide a better example of how digitized audio through the PC speaker can sound, I fired up the DOS "MOD" player IPlay, playing the unforgettable music track "CAMBOD.MOD" (a.k.a. "go-for-it") through what it calls the "PC Honker", mixed at 22 kHz (for a maximum audio bandwidth of 11 kHz):

http://www.youtube.com/watch?v=Wu5zd5fCaPA

It takes at least a 386 to provide that kind of sampling rate on a MOD player, but even a "turbo XT" should be able to play MOD files if you choose a lower sampling rate.
 
I am sorry, but while I understand the theory of how the PC Speaker works and can produce sounds of greater fidelity than it was designed to do, I just have difficulty accepting that the IBM PC's Speaker (cone) can produce this. This is something that I have to see done on a PC first hand (i.e. being in the same room with the PC) in order to fully appreciate what is being done. I will be content only when I see the speaker cone vibrate and hear its sound.
 
It seems like the Atom demo tries to overcome that by overmodulating the audio, which produces a loud but painfully distorted sound.

Yes and no. The sound is 1-bit, which means the speaker, by nature of the data, does fully extend and return. The program isn't trying to overmodulate; the data, by it's very format, is already overmodulated.
 
It takes at least a 386 to provide that kind of sampling rate on a MOD player, but even a "turbo XT" should be able to play MOD files if you choose a lower sampling rate.

Not on the PC Speaker, no. On a Sound Blaster, sure, because you can use DMA to transfer data as the next block is being calculated. I myself wrote an 8088/4.77MHz modplayer that plays at 8KHz on a Sound Blaster.

For MOD playback on the PC speaker, you need at least a 286 at around 10MHz or higher.
 
I am sorry, but while I understand the theory of how the PC Speaker works and can produce sounds of greater fidelity than it was designed to do, I just have difficulty accepting that the IBM PC's Speaker (cone) can produce this. This is something that I have to see done on a PC first hand (i.e. being in the same room with the PC) in order to fully appreciate what is being done. I will be content only when I see the speaker cone vibrate and hear its sound.

You can run the aforementioned programs yourself, if you like :) Just boot to DOS first.
 
I am sorry, but while I understand the theory of how the PC Speaker works and can produce sounds of greater fidelity than it was designed to do, I just have difficulty accepting that the IBM PC's Speaker (cone) can produce this. This is something that I have to see done on a PC first hand (i.e. being in the same room with the PC) in order to fully appreciate what is being done. I will be content only when I see the speaker cone vibrate and hear its sound.
Here are a bunch of audio playback programs for DOS, many of which support the PC speaker:

http://short.stop.home.att.net/freesoft/sound.htm

I used Inertia Player (IPLAY) 1.22, which is available for download on that page. Run ISETUP first and choose PC speaker as the output device. I'm not sure if it runs under Windows XP, but I know it works fine from within Windows 98 and ME, as well as plain ol' DOS, of course. I've found that when playing through the PC speaker, it's best to reduce the "Volume Amplify" (using the bracket keys) to 50% or 60% in order to reduce distortion and provide a cleaner sound. And as for the actual ".MOD" music files to play, you can find tons of them here:

http://artscene.textfiles.com/music/mods/

p.s. I finally found out after all these years... CAMBOD.MOD is based on the 1981 Kim Wilde song "Cambodia." It's a very catchy arrangement!
 
I just wonder how much this thread is going over the head of anyone under about 35.

For the uninitiated...

Most modern PCs have a built in sound card driving (amongst other things) the internal speaker with a more or less cd-quality audio signal. what you hear is only dependent on the quality of the speaker built into the box.

Whereas...

the "PC Speaker" in it's original form was driven from a transistor switch, on the end of 1 bit of an output port. You switch the port on and off at e.g. 1khz, and all you get is a 1khz square wave beep.

If you need proper analogue audio out, then you have to pulse-width-modulate the data on the port (i.e. switch it on and off very fast with varying mark-space ratios) to simulate all the levels in between "0" and "1" It takes some effort to write a program to play a wav, and loads of effort to write a complete midi synth, quite a nifty bit of software.
 
Is it really common that an integrated sound card on a semi-modern desktop PC can be connected to the internal speaker? Perhaps you need special drivers. Laptops are another matter. Apart from some branded computers and the very latest generations of PCs (Pentium II and newer), I rarely have observed built-in sound on the motherboards anyway.

I do understand exactly what you're talking about, and I'm only 33 and just briefly interested in the IBM PC architecture anyway. However I find it fascinating that you'd need a 10 MHz 286 to generate the software sample. I know of recent Commodore demos which plays a four channel MOD (with limited samples) as one big "volume" sample on the fly. The volume register on the VIC/64 though is four bits, which gives a better amplitude (?) than a 1-bit speaker, but the CPU at the other hand is 1 MHz 8-bit 6502 compared to a 10 MHz 16-bit 286. It is possible that retro PC programmers have developed similar MOD players for older PCs too, just not released for general use.
 
Is it really common that an integrated sound card on a semi-modern desktop PC can be connected to the internal speaker? Perhaps you need special drivers.

No, the OP was confused and meant to say laptops instead of desktops. Desktops that route the onboard soundcard to the internal speaker are extremely uncommon.

I do understand exactly what you're talking about, and I'm only 33 and just briefly interested in the IBM PC architecture anyway. However I find it fascinating that you'd need a 10 MHz 286 to generate the software sample. I know of recent Commodore demos which plays a four channel MOD (with limited samples) as one big "volume" sample on the fly. The volume register on the VIC/64 though is four bits, which gives a better amplitude (?) than a 1-bit speaker, but the CPU at the other hand is 1 MHz 8-bit 6502 compared to a 10 MHz 16-bit 286. It is possible that retro PC programmers have developed similar MOD players for older PCs too, just not released for general use.

There's a couple of things going on here, but first off, please direct me to some of these C64 demos with "4-channel MODs" because I'd like to examine them for myself.

So in the case of needing a 10MHz 286 to output MODs through the internal speaker: The piece of information you're missing is that the act of driving the internal speaker to produce digitized sound is a very CPU-intensive process. Driving a soundcard takes nearly no CPU time at all (DMA moves the sample data to the card in the background) but for the speaker you must perform about ten instructions per "pulse". Multiplied by a decent sampling rate (16KHz for example), that's 160000 instructions per second simply dedicated to making the speaker move -- none of that is calculating the MOD parameters and mixing the audio into a single output channel. So to do all of this effectively, you need about a 10MHz 286.

You can output digitized sound on the PC speaker on the original 4.77MHz 8088, but only just barely -- the entire machine is effectively dedicated to the task, leaving no time to perform realtime mixing. My MOD player for 4.77MHz 8088 can mix (just barely!) 9KHz audio; I have seen another (Galaxy, glx212.zip) that can do 11KHz, but in both players the sound output is through DMA to the sound blaster. So that's why MOD mixing + pc speaker output requires more horsepower than you would think.

Although C64's 6510 (6502) ran at 1MHz, it was very competitive due to it's low cycle counts. Because of that and the 8088's sometimes stupidly high cycle counts, and slow memory speed, I would just about say that the C64 and the original IBM PC were about equivalent in raw speed. The only way the PC wins is because it has 10 times more memory and can cache/precalc a lot more.
 
Last edited:
My IBM ThinkCentre has onboard sound out of the PC speaker too.. Pretty cool feature, especially since it's running OS X Leopard, and makes it very much like a Mac (which all Macs do this).
 
The C64 sound chip (!) is also memory-mapped, which tends to speed up operation quite a bit compared to I/O based solutions.

As for a MOD player, check out Polly Tracker:
http://aleksieeben.blogspot.com/2007/05/polly-tracker.html
http://noname.c64.org/csdb/release/?id=18605

Competition songs: http://noname.c64.org/csdb/release/?id=23038

Aleksi Eeben also has made a SID emulator for the VIC-20, using similar techniques. It is quite noisy and rather a proof of concept than enjoyable music, but the 1-bit PC speaker isn't the ultimate in Hi-Fi experiences neither. ;-)
 
Back
Top