Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code for Sound - Internal PC Speaker

Status
Not open for further replies.

CSpannos

IS-IT--Management
Mar 21, 2001
32
US
Hello everyone,

I am trying to write a little program that allow me to get an audible signal or alert from the internal PC speaker, not the sound card.

I'm new to C++, but I remember doing this in Turbo Pascal a long time ago. I was able to select the frequency or pitch, and set the length. I remember being able to compose little songs, with the proper loops. Can this be done in C++. I'm working with Borland C++ Builder 5 in windows, and also in the built-in compilers in Unix - SunOS.
I searched through all the posts, and all I came up with is the following code that allows you to include a wave file, but doesn't help me with the internal speaker thing:

Code:
#include <windows.h>

int main(void) {

PSZ lpszFileName = &quot;c:\\windows\\media\\lockdown.wav&quot;;
char lpszCmd[512];

wsprintf(lpszCmd, &quot;open %s type waveaudio alias wave wait&quot;, lpszFileName);
mciSendString(lpszCmd, NULL, 0, 0);

wsprintf(lpszCmd, &quot;play wave wait&quot;);
mciSendString(lpszCmd, NULL, 0, 0);

wsprintf(lpszCmd, &quot;close wave&quot;);
mciSendString(lpszCmd, NULL, 0, 0);
}

Thanks in advance,
-Kosta
 
you should include other file than windows.h. I'll see and will post there.Also you sold link some library. By the way, mci* functions use COM interfaces on the background. You can access direct the windows media player through COM. See its IDispatch. Ion Filipski
1c.bmp


filipski@excite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top