PC Speaker Access

Posted on 1998-08-26
Last Modified: 2010-04-15
Hi Everyone,

  I'm writing an opengl program for Windows 95 and want to add some sound.  The "Beep" and "MessageBeep" functions work but are to slow with response time (it is a real time simulation I'm writing).  

  I've come along some faq's that have told me about how the speaker is addressed on port 21 and things like that.  I haven't done any hardware programming before and have not been able to find C code to learn from (although I have found lots of pascal code).  

  If anyone knows functions the names of some functions, url's, or even routines that would help, I would greatly appreciate it.


Question by:dpnguyen
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Expert Comment

ID: 1252317
I was gonna work up an example from some old asm code, but my code ended up throwing a priveleged instruction, and that's probably why Beep and MessageBeep are slow.

Expert Comment

ID: 1252318
are you trying to do sound via a soundcard or just directly thru the speaker?

Accepted Solution

duneram earned 100 total points
ID: 1252319
Take a look at article : Q138857  on the FastTips:

this article shows how to install a PC speaker driver on Win95 to play wav files and stuff like that.  The name of the driver is  (SPEAKER.DRV)and its available through Microsoft Download Service (MSDL)

This article explains why programs run slow or hang when trying to use the pc speaker in win95:  Q134591

Games Using the PC Speaker May Run Slowly or Hang
Last reviewed: August 23, 1995
Article ID: Q134591  
The information in this article applies to:
Microsoft Windows 95

When you run a game that uses the PC speaker to play sounds, your computer may run slowly or stop responding (hang).

This problem can occur if the game tries to set the timer chip to a rate faster than Windows 95 can handle. When this occurs, the game does not receive timer ticks as rapidly as it expects, causing the game to run slowly.

To correct this problem, configure the game to run in MS-DOS mode. To do so, follow these steps:

In Windows Explorer or My Computer, use the right mouse button to click the game's executable file, and then click Properties on the menu that appears.

On the Program tab, click Advanced.

Click the MS-DOS Mode check box to select it, and then click OK.

To run the program with the new configuration, double-click the game's executable file. Do not type the game's executable filename at an MS-DOS prompt to start the game.

Microsoft FastTips is available 24 hours a day, 7 days a week, from a touch-tone telephone. To order items from this catalog, first select the items you want to receive, noting the five- to six-digit number of the Item ID shown below for each item, and then:

          Dial the toll-free FastTips number (800) 936-4300.
          When prompted, select the Win32 Software Development Kit.
          Press one (1) on your phone keypad to select Express Order Service.
          When prompted, select the delivery method, fax.
          When prompted, enter your three-digit area code and seven-digit fax number on your phone keypad.
          When prompted, enter the number of the Item ID and press #, for up to five items.

     When finished, simply hang up. If you have problems receiving a fax, please call (425)


Author Comment

ID: 1252320

  Thanks for the reply.  I was looking for a solution that had to do with directly accessing the PC speaker.  All I want it to do is beep, nothing fancy, just a beep, but in real time.  I don't even want to have my program touch the sound card at any time, just the pc speaker.  I just wanted to know if there is way using VC++ to do it.


Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode ( They will have you believe that Unicode requires you to use…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question