View Full Version : Demo of digitized audio through PC speaker
vwestlife
May 11th, 2008, 10:32 PM
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!
shawn510
May 12th, 2008, 08:23 AM
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.
vwestlife
May 12th, 2008, 08:29 AM
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.
Trixter
May 12th, 2008, 08:53 AM
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 :-)
Bungo Pony
May 12th, 2008, 02:09 PM
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.
Trixter
May 12th, 2008, 02:13 PM
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.
vwestlife
May 12th, 2008, 02:53 PM
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.
vwestlife
May 12th, 2008, 05:48 PM
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.
Great Hierophant
May 12th, 2008, 09:05 PM
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.
Trixter
May 12th, 2008, 10:17 PM
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.
Trixter
May 12th, 2008, 10:19 PM
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.
Trixter
May 12th, 2008, 10:19 PM
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.
vwestlife
May 12th, 2008, 10:26 PM
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!
nige the hippy
May 13th, 2008, 02:59 AM
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.
carlsson
May 13th, 2008, 03:38 AM
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.
Trixter
May 13th, 2008, 02:37 PM
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.
evildragon
May 13th, 2008, 02:58 PM
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).
carlsson
May 13th, 2008, 03:24 PM
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. ;-)
Bungo Pony
May 14th, 2008, 05:54 AM
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.
The software is called DSS which can be downloaded here:
http://www.opus.co.tt/dave/download/dss.zip
There was no sound card in the laptop. I had set the player to use the PC speaker.
Floppies_only
May 14th, 2008, 01:54 PM
Finally, I found it the old fashioned way: through a USENET binary!
I read that Google Groups doesn't archive binaries. Was this program recently posted on USENET? Could you tell us what group it was on?
Thanks,
Sean
vwestlife
May 14th, 2008, 03:30 PM
I read that Google Groups doesn't archive binaries. Was this program recently posted on USENET? Could you tell us what group it was on?
Thanks,
Sean
Someone posted it to "alt.test.group" in 1996 as a "just testing, ignore" message, but by the file name and download size I knew it was exactly what I was looking for!
http://groups.google.com/group/alt.test.group/msg/f421db1ad4f4bbb9
I think Google Groups may block USENET groups that are explicitly for binaries, but if you happen to come across a binary post in a non-binaries group, you can download it.
Trixter
May 14th, 2008, 11:35 PM
The C64 sound chip (!) is also memory-mapped, which tends to speed up operation quite a bit compared to I/O based solutions.
Indeed!
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
Very impressive! But I have to point out that one of the "breakthroughs" was ignoring interrupts and just polling in a tight loop. On PC, we can't do that, because PCs are all different speeds and architectures. So on PC we have to use interrupts, and an interrupt call wastes 70 cycles, so that's why PC has worse performance in this area. Also, C64 has 4 timers, PC only has two (three, but one is needed to refresh DRAM so you can't use it) and, of the two, only one is wired to the PC speaker...
carlsson
May 15th, 2008, 01:49 AM
Four timers; two CIA, one raster beam, one NMI?
By the way, wouldn't it be possible to write a tightly polling program for the 4.77 MHz IBM PC 5150 that will work on that model but perhaps no other? Yes, people would bitch about it not being compatible with other vintage PCs but the point would be to prove how many samples you could pull from the CPU if it has nothing other to attend to. Compatibility is overrated anyhow. ;-)
Trixter
May 15th, 2008, 06:10 PM
Four timers; two CIA, one raster beam, one NMI?
Still better than PC. PC has three timers: One for firing off program code at an interval, one for refreshing DMA (users can't use this), and one for use as an actual timer that can be read and tied to the speaker and stuff. No video interrupt; no NMI (unless on 286 and higher).
By the way, wouldn't it be possible to write a tightly polling program for the 4.77 MHz IBM PC 5150 that will work on that model but perhaps no other? Yes, people would bitch about it not being compatible with other vintage PCs but the point would be to prove how many samples you could pull from the CPU if it has nothing other to attend to. Compatibility is overrated anyhow. ;-)
Sure, there are very many music programs, at least five completely different techniques for making multi-channel audio through the PC speaker. Most only work on original PC though, so where's the fun in that if others can't run/hear your work?
Also, I'm not sure polling would work on 4.77MHz 8088 through the speaker... I laid in bed last night thinking about it :-) and came to the conclusion that I'm not sure it could be useful, because the addressable timer in the PC is very fast (compare to the speed of a program) and many hundreds of ticks could go by while the program is doing its thing. Each program instruction costs 2-13 cycles to execute -- and another 4-20 cycles just to read from memory! -- so it wouldn't even be a case of polling, it would be a tight loop with custom "for->next loop"-style waiting instructions for timing.
I have ideas on multi-channel sound generation that I'd like to add to MONOTONE someday; the simplest one, and it should be compatible across all platforms, is to use three registers as square-wave generators; inc each reg by the period, and take the most-significant bit as the state of the speaker. With all three going at once, the speaker will output three simultaneous square waves.
Someday I hope to figure out what Tim Follin was doing on the spectrum -- some of the multi-channel "phasor" output I have STILL not figured out 20 years later...
Great Hierophant
May 15th, 2008, 10:45 PM
The C64 sound chip (!) is also memory-mapped, which tends to speed up operation quite a bit compared to I/O based solutions.
This assumes that the 6502 can access memory in a C64 faster than an Intel 8088 in an 5150. In the 5150, I/O is accessed just as fast or almost as fast as memory, since both busses are set to the same speed.
There was an extremely obscure sound card called the Innovation Sound Standard which mapped its SID's registers directly to 31 separate I/O addresses. That is a lot of addresses to use when the 5150 had only 1024 total that were to be used.
carlsson
May 15th, 2008, 11:46 PM
If you map the registers to so many I/O addresses, isn't it the same thing as making the chip memory-mapped except that you'll have a different way to access it? I was thinking of the typical setup with one-two I/O ports to a sound chip with 4-24 registers, where you have to send multiple commands in serial. Often one command to choose register and then another command for the data.
vwestlife
May 18th, 2008, 01:07 PM
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
I found it! "Polyphonic Music 1.20: Three voice music on PC":
http://ftp.arnes.si/simtel.net/msdos/music-pre.html
Also somewhere deep in my collection I have a program which shows a living room with a Christmas tree, fireplace, and grandfather clock, and plays Christmas carols through the PC speaker (single voice) while clicking the IBM PC cassette motor relay on and off to simulate the ticking of the clock! That's perhaps the most unused "sound effect" source on a PC! :)
BrunoFlorindo
November 10th, 2008, 06:46 PM
By the way, wouldn't it be possible to write a tightly polling program for the 4.77 MHz IBM PC 5150 that will work on that model but perhaps no other? Yes, people would bitch about it not being compatible with other vintage PCs but the point would be to prove how many samples you could pull from the CPU if it has nothing other to attend to. Compatibility is overrated anyhow. ;-)
I've seen it done on 3.5Mhz 8-bit computers. The cpu is used 100% during the process, but the result is impressive (for such machines). I also heard impressive 4-bit digitized music on the MSX, but it was done through the YM chip.
BrunoFlorindo
November 10th, 2008, 06:55 PM
I have ideas on multi-channel sound generation that I'd like to add to MONOTONE someday; the simplest one, and it should be compatible across all platforms, is to use three registers as square-wave generators; inc each reg by the period, and take the most-significant bit as the state of the speaker. With all three going at once, the speaker will output three simultaneous square waves.
This sounds a lot like the principle behind playing digitized samples on Spectrums with the AY chip. :)
Someday I hope to figure out what Tim Follin was doing on the spectrum -- some of the multi-channel "phasor" output I have STILL not figured out 20 years later...
If you have questions about 1-bit music on the Spectrum, try talking to Mr. Beep, Gasman or Yerzmyey. All of them can be found on WOS.
Trixter
November 11th, 2008, 03:18 PM
What is WOS?
Chuck(G)
November 11th, 2008, 03:39 PM
I found it! "Polyphonic Music 1.20: Three voice music on PC":
http://ftp.arnes.si/simtel.net/msdos/music-pre.html
Also somewhere deep in my collection I have a program which shows a living room with a Christmas tree, fireplace, and grandfather clock, and plays Christmas carols through the PC speaker (single voice) while clicking the IBM PC cassette motor relay on and off to simulate the ticking of the clock! That's perhaps the most unused "sound effect" source on a PC! :)
I remember early on that there were some "pianoman" polyphonic-on-a-PC bit bangers. Not in the same class as voice, but entertaining enough.
Right now, I can think of two desktops that I have hooked up that will play the sound card output through the PC internal speaker (absent an external speaker connection); a Compaq Deskpro PIII and an HP Vectra PII system. So they weren't all that uncommon.
Moving a little off-topic, I was into making music on my Altair 8800 by executing EI/DI instructions in a loop--the 8080 interrupt status is fed to a front-panel LED--just hook a capacitor to it and feed it to an amplifier. Lots of fun, even at 2MHz.
Terry Yager
November 11th, 2008, 04:00 PM
What is WOS?
Ooo,ooo...I know this one! WorldOfSpectrum!
--T
carlsson
November 12th, 2008, 11:47 AM
Even www.worldofspectrum.org (http://www.worldofspectrum.org). It is a ZX Spectrum community site with legal downloads, archived magazines and an active ZX forum.
tikbalang
November 26th, 2008, 08:40 AM
here is "virtual sound blaster" by andrew zabolotny.
http://ericauer.cosmodata.virtuaserver.com.br/soft/by-others/dos-virtual-soundblaster--vsb202.zip
it emulates SB 1.xx on covox (lpt1) or pc speaker. the source is also available.
http://ericauer.cosmodata.virtuaserver.com.br/soft/by-others/
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.