I am interested in how to load a wave file and playing.
But I want to learn easier codes or applications first.
I will learn from single to complex.
Main Topics
Browse All TopicsHi. Experts:
I could output "Beep" by writing follows:
printf('\b'); //C language
cout<<'\b'; //C++ language
But I want to output a single tone like "DO","RA","ME"....and so on.Could someone give me some recommends or simple codes to learn?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
In which programming environment? Back in the good old DOS-days or Turbo C 2 or Borland C 3, one could use <conio.h> with "sound" and "delay". Under Windows you can use "waveOutWrite" to play a wave sample in the memory (you can fill it with a sine wave in advance). Or - as _Rob_ suggested - play a WAV file using the "PlaySound" function.
Find a wav file.
Copy it to C:\
Rename it to test.wav
Edit your program too look like:
#include <windows.h>
#pragma comment( lib, "winmm.lib" )
int main(int argc, char* argv[])
{
PlaySound( "C:\\TEST.WAV", NULL, SND_FILENAME|SND_SYNC );
return 0;
}
It is much more work to get the program to play tunes with the internal PC speaker since (to my knowledge) there is no function like beep( frequeny, duration ).
Using the internal speaker is obsolete anyway.
/rob
And I know that the internal PC speaker is controlled via in/out instructions. Those instructions can't be used in a normal application since those instructions access hardware directly. So you need to write a device driver. Believe me, you don't want to do that :-)
I've seen drivers for this that others have written, go to google, and search for
internal speaker driver windows
if you still plan on using the speaker.
Like joghurt said, to make simple tones in Windows you allocate a memory buffer, use the math sin function to fill the buffer with a tone, and then play the buffer with a multimedia function.
I could help you with that if that is the path you want to follow.
I will however refuse to help to make the internal speaker beep. It is a waste of time and work since it can't be used for anything useful anyway.
/rob
If you still have an urge to play with the PC speaker, check http://dome.impulzus.com/p
Though it's written in assembly and not C/C++, it's simply enough to understand and enjoy. (124 bytes long when compiled. ;-)
It will work under DOS and Windows 9x/Me, but not under NT/2000/XP.
Business Accounts
Answer for Membership
by: _Rob_Posted on 2003-04-28 at 12:21:50ID: 8414832
Aren't you interested in how to load a wave file and playing that instead?
/rob