Solved

working with internal speaker

Posted on 2002-05-22
3
340 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
  • 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Need to retreive data from .TFS file exported by DVR 8 166
xyBalance chalenge 58 88
mixString challenge 36 98
wordappend challenge 8 85
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now