Solved

working with internal speaker

Posted on 2002-05-22
3
379 Views
Last Modified: 2013-11-20
how can i work with internal speaker in mfc?
( i want have a function simular sound in c++ that work only with internal speaker)
0
Comment
Question by:jCISCO3640
[X]
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
3 Comments
 
LVL 4

Expert Comment

by:mblat
ID: 7030411
Beep
The Beep function generates simple tones on the speaker. The function is synchronous; it does not return control to its caller until the sound finishes.

BOOL Beep(
  DWORD dwFreq,      // sound frequency
  DWORD dwDuration   // sound duration
);
Parameters
dwFreq
Windows NT/ 2000: [in] Specifies the frequency, in hertz, of the sound. This parameter must be in the range 37 through 32,767 (0x25 through 0x7FFF).
dwDuration
Windows NT/ 2000: [in] Specifies the duration, in milliseconds, of the sound.
Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks
Windows 95: The Beep function ignores the dwFreq and dwDuration parameters. On computers with a sound card, the function plays the default sound event. On computers without a sound card, the function plays the standard system beep.
0
 

Author Comment

by:jCISCO3640
ID: 7034207
i want use it in win98
0
 
LVL 4

Accepted Solution

by:
mblat earned 50 total points
ID: 7035568
That should work under Win98....

/* Speaker control.  Call this function with a non-zero argument to
   turn the speaker on at the desired frequency.
   Call it with zero to turn the speaker off.  */
void Beep(int nFreq)
{
   int tmp;

   if (nFreq != 0)
   {
      // Set up the divisor for the desired frequency
      long fq = 1190000L / (long)nFreq;

      // Set up the frequency control timer
      _outp(67, 0xb6);
      _outp(66, fq & 0xff);
      _outp(66, (fq >> 8) & 0xff);

      // Turn on the speaker
      tmp = _inp(97);
      _outp(97, tmp | 0x03);
   }
   else
   {
      // Turn off the speaker
      tmp = _inp(97);
      _outp(97, tmp & 0xfc);
   }
}
0

Featured Post

Industry Leaders: 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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

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