Beep Beep
What's the deal with the Beep() API anyway?
It's one of the oldest Windows API, dating back to Windows 1.0. It's also one of the few audio APIs that my team doesn't own. The Beep API actually has its own dedicated driver (beep.sys). The reason for this is that the Beep() API works totally differently from any other audio API in the system.
Back when IBM built the first IBM PCs, they realized that they needed to have the ability to do SOME level of audio, even if it wasn't particularly high quality. So they built a speaker into the original PC hardware.
But how do you drive the speaker? It turns out that the original PC hardware used an 8253 programmable interval timer to control the system hardware timer. The 8253 was a pretty cool little chip - it would operate in 5 different modes - one shot timer, interrupt on terminal count, rate generator, square wave generator, software strobe or hardware strobe. It also contained three independent counters - counter 0 was used by the operating system, counter 1 was reserved for the hardware. The third counter, counter 2 was special. The IBM hardware engineers tied the OUT2 line from the 8253 to the speaker line, and they programmed the timer to operate in square wave generation mode.
What that means is that whenever the 2nd counter of the 8253 counted to 0, it would toggle the output of the OUT2 line from the 8253. This gave the PC a primitive way of generating very simple tones.
The original Windows Beep() API simply fiddled the controls on the 8253 to cause it to generate a square wave with the appropriate frequency, and that's what Beep.sys continues to do. Legacy APIs can be hard to remove sometimes :)
Nowadays, the internal PC speaker is often also connected to the PCs audio solution, that allows the PC to have sound even when there are no external speakers connected to the machine.
In addition to the simple beep, some very clever people figured out how they could use the 8253 to generate honest to goodness audio, I'm not sure how they succeeded in doing it but I remember someone had a PC speaker based sound driver for DOS available at one point - it totally killed your PCs performance but it DID play something better than BEEEEEEP.
Edit: s/interrupt conroller/interval timer/
Edit2: fixed description of channel 1 (in case someone comes along later and decides to depend on my error).
Comments
Anonymous
November 04, 2005
Believe it or not, Microsoft actually released a Windows 3.1 PC speaker audio driver. I know because at the time I was too poor to afford a sound blaster for my 386-33, but I downloaded that driver from Microsoft (via a long-distance modem call to Redmond, no less) and could play actual low-quality audio through the PC speaker, both wav and MIDI.Anonymous
November 04, 2005
The comment has been removedAnonymous
November 04, 2005
You mean Windows 98? See http://support.microsoft.com/kb/q138857/
A little scratchy, but works well on low-end machines - I loved that Windows 3.1 on my 16 MHz 286 could play the Windows '95 startup sound!
(I've since put a network and sound card in and it runs RDP over a wireless bridge to XP, but that's another story...)Anonymous
November 04, 2005
I remember using the PC Speaker driver for Win 3.1. You can still get it for Win95/98/ME:
How to Install and Use the PC Speaker Driver with Windows
http://support.microsoft.com/kb/q138857/Anonymous
November 04, 2005
I actually wrote a program that could play music in seven parts using just the PC speaker. Fifteen years ago; time flies! I made it play a movement of a Bach concerto, with a duration of ten minutes. It was a pure DOS program, however, and I had to disable all interrupts when it played, since I used the stack pointer in the code...Anonymous
November 04, 2005
Hah, this brings back some good memories. Some co workers late one evening deep in the vault of the server room. One programmer (me) upstairs know about this and knows how to make it run different tones different lengths. Imagine their puzzlement as a server starts beeping, like an alarm, then as they are looking to see which one is an alarm (I am watching them log into the terminals from terminal services) then as they get close to the server beeping I start playing Yankee Doodle Dandy.Anonymous
November 04, 2005
I remember back in the day a few games and a actually capitalized on the sound driver feature.. From what I remember there was a game called World Class Leaderboard Golf made by Access Software (which was later acquired by Microsoft for the Links series) had something they licensed or developed called "RealSound" which had pretty decent audio (for the time) though the PC speaker
Used to get a thrill on that old 8086 playing Leaderboard Golf (WCLB.exe) and acually hearing a metalliac "I think he hit a tree, Jim" from the PC speaker.
Most of the audio at that time was the bleeps and bloops of monotone sound -- and if you were lucky enough to have an AdLib card, some rudimentary midi audio...
Also recall that there was also a freeware sound driver for Windows 3.0 that someone hacked together which would allow to use the PC speaker as a wave audio device..
Thanks for the trip down memory lane ;)Anonymous
November 04, 2005
I remember that program, too. IIRC, it wasn't a driver, but an actual program that would let you load sound files (its own custom format, I think) and play them through the PC speaker. I wish I could remember it's name.
I was in college at the time, and after 10 years of hearing PC be-boops I was blown away when I first heard it. But as my EE friend explained to me, why shouldn't it be hard to do? It's a speaker!
'Course, anyone worth their salt back then had a Sound Blaster anyway. ;-)Anonymous
November 04, 2005
The comment has been removedAnonymous
November 04, 2005
http://support.microsoft.com/kb/q138857/
Windows 95, 98, and ME support!Anonymous
November 04, 2005
The comment has been removedAnonymous
November 04, 2005
The comment has been removedAnonymous
November 04, 2005
I have some classic Infosys games that actually played music over the PC speaker...
StickyKeys' notification sound comes over the PC speaker on my machine. Does it use Beep? It's particularly annoying since I work in a cubicle environment and most sound from my computer goes through my headphones.Anonymous
November 04, 2005
Just a minor correction, I think you meant to say "Programmable Interval Timer", not "Programmable Interrupt Controller"Anonymous
November 04, 2005
Maurits,
Funny you should mention that :)....
StickyKeys is Monday's post :)Anonymous
November 04, 2005
Actually, port 1 was not available for applications. It was used for driving RAM refreshing cycles. By increasing the divider in channel 0x1 the memory could be "overclocked" by the virtue of decreasing the chances of the memory bus being busy with refreshing. The downside was -- you guessed it right -- risk of loosing data.
This channel was not used in PS/2 and later models, and there was no access to it's output (not documented, at least)Anonymous
November 04, 2005
Does printf("7") work the same way as Beep()
-Jeu GeorgeAnonymous
November 04, 2005
I get "translation" of beeps by Virtual PC (and VMWare) from the virtual machine out to the audio card of the host machine. It is phenominally annoying, as I habitually use my audio player to control the volume... so every now and then I get a violently loud beep from the client. I can't disable this by disabling/uninstalling the system.speaker either!Anonymous
November 04, 2005
One of my first applications written when I was very young was in the QBasic interpreter that shipped with MSDos.
Played different tones over the PC Speaker in a loop. At the time I found it fairly interesting :-)
Interesting enough, up until a few days ago, the .NET framework only had a single Beep() API via the one of the VB assemblies. I spent today ripping out my Interop calls to the wav-based 'system beeps' and moving them to .net 2.0.
Thanks for the great post!Anonymous
November 04, 2005
in CMD, type "echo ^g" (^g mean you click CTRL-G, not Shift-6 G) - you'll get a beep, presumably a Beep(). I use it all the time to get notified when some log command finishes:
xcopy bla & echo ^gAnonymous
November 04, 2005
"net stop beep" will silence the beeper.
Ideal for when you've just accidentally listed several pages of 0x07 rich binary to the console.Anonymous
November 04, 2005
for the guy sitting next to the beeping girl - net stop beep should solve your problem :-)Anonymous
November 04, 2005
I remember a DOS driver that used i386’s protected mode to emulate a Sound Blaster on either PC Speaker or Covox. Covox was a simple 8-bit DAC which was plugged into an LPT port, and gave much better sound than 1-bit PC Speaker. Performance-wise, yes, it was a nightmare.Anonymous
November 05, 2005
The comment has been removedAnonymous
November 05, 2005
thanks for "net stop beep", it saved my night!
but why doesn't "beep" appear as a service when I do "net start"?Anonymous
November 05, 2005
"beep" is a driver (beep.sys). The "Net stop" command can be used to stop both drivers and services (loosely speaking, the service controller is responsible for starting drivers)Anonymous
November 06, 2005
The comment has been removedAnonymous
November 06, 2005
Hey, does that mean that if my video card / network card drivers have gone weird that I can "net stop"/"net start" them to reset them without rebooting?Anonymous
November 06, 2005
Miral, you can try, but I'm willing to bet that it won't work.
The video card driver is loaded by win32k.sys, the only way to unload/reload that is by rebooting the machine.
The network stack can be unloaded but that assumes that every app that uses it knows how to deal with PnP notifications - most don'tAnonymous
November 06, 2005
The comment has been removedAnonymous
November 06, 2005
Norman, that trick didn't work with the IBM PC, it was too well shielded.
The TRS-80, on the other hand.....
I had a friend in college who had a TRS-80 and he showed how he could make music on his stereo with it.Anonymous
November 07, 2005
On my first day of work at NCR (1980), I walked up to the console of the mainframe and, since all the terminals in college made a beep when you pressed control-g, I pressed control-g.
Unfortunately, on this particular NCR mainframe, it invoked the debugger and stopped the machine.
Which several people were actually USING at the time.Anonymous
November 07, 2005
The comment has been removedAnonymous
November 08, 2005
The comment has been removedAnonymous
November 08, 2005
The comment has been removedAnonymous
November 13, 2005
Quote: "From what I remember there was a game called World Class Leaderboard Golf made by Access Software (which was later acquired by Microsoft for the Links series) had something they licensed or developed called "RealSound" which had pretty decent audio (for the time) though the PC speaker"
Sean, Access also made other games, most notably "Mean Streets" that was one of the first VGA games IIRC, and it too used RealSound. It had decent graphics even for those of us stuck with EGA, and the sound was indeed playable! :) I think they did a remake of that game, but I never got around checking it out. "Mean Streets" was an adventure game with a good exciting story. Can't get games of that caliber today! :/Anonymous
November 14, 2005
The comment has been removedAnonymous
January 10, 2006
The comment has been removedAnonymous
January 23, 2006
cool! now if only it would act as a real "Sounds and Audio Devices"!
I have a c****** laptop running windows 98, and the sound card doesn't work ("Device not present or drivers not loaded" error?)
So i went around looking for some sort of driver to use the PC Speaker (worked...)Anonymous
January 02, 2007
Was mein Vista momentan an Ton zu wenig hat, das hat mein Dienstnotebook zu viel: Ton. Ständig piept einen der interne PC-Lautsprecher (oder seine heutige Entsprechung) an, wenn man sich vertippt, verklickt, vertut... Und das Ganze in einer LautstärkAnonymous
May 31, 2009
PingBack from http://outdoorceilingfansite.info/story.php?id=4754Anonymous
May 31, 2009
PingBack from http://outdoorceilingfansite.info/story.php?id=22390Anonymous
June 13, 2009
PingBack from http://quickdietsite.info/story.php?id=1126Anonymous
June 16, 2009
PingBack from http://topalternativedating.info/story.php?id=3058