• C

PC Speaker Access

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.


Who is Participating?
duneramConnect With a Mentor Commented:
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)

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.
are you trying to do sound via a soundcard or just directly thru the speaker?
dpnguyenAuthor Commented:

  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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.