?
Solved

working with internal speaker

Posted on 2002-05-22
3
Medium Priority
?
381 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 150 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: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

752 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