Solved

working with internal speaker

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Login Script to Copy Folders 12 35
How do you programatically show and hide the Windows 10 On-Screen-Keyboard? 3 654
maxBlock challenge 30 128
Path of Workbook 3 76
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

786 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