Sound from within MFC programs

I've looked at Directsound and it doesn't seem to be as straightforward as I need. All I need my program to do is generate the occasional beep from the soundcard, independent of driver. Is there anywhere an activex or ocx or some simple to use component I could use to generate a beep of a specified length with one single call?

Who is Participating?
chensuConnect With a Mentor Commented:
On Windows NT, you can use the Beep function. But the Beep function ignores the dwFreq and dwDuration parameters on Windows 9x, in which case, you can write your own Beep function using low-level audio functions or DirectSound. If you want a straightforward method, I suggest you use the PlaySound function. Pre-record or download some wave files and play them using the PlaySound function. For example,

::PlaySound("beep1.wav", NULL, SND_ASYNC | SND_FILENAME);
>> All I need my program to do is generate the occasional beep
Why don't you use ::MessageBeep() ??
rudebarbAuthor Commented:
>> All I need my program to do is generate the occasional >> beep

nil_dib> Why don't you use ::MessageBeep() ??
Because on a lot of notebook sound systems this just
sounds off the Windows chime.wav instead of a beep.

If you just want to produce a beep sound you can just use the function sndPlaySound() Which is a synchronous option for playing small sounds. This is found in mmsystem.h and you must ofcourse include the library winmm.lib into your project settings
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.