how do i play sounds, such as a background song, in consul applications? also, is there a way i can have the song/sound/whatever "in" the program, so that the user doesnt have to have it saved on their computer? thanks
how do i play sounds, such as a background song, in consul applications? also, is there a way i can have the song/sound/whatever "in" the program, so that the user doesnt have to have it saved on their computer? thanks
For a windows console application, you have to include windows.h. Then you can use PlaySound() to play a wave file from the disk, or the various MIDI functions. None of this is ANSI standard C++ stuff... Any graphics or sound requires non ANSI libraries.
The problem with PlaySound is that it has to read from the disk "continuously" and it needs lots of CPU-bus time. so it's not usually a good idea to play wave sounds in the background. MIDI is easier on the processing load, because you're essentially just sending the set-up and the notes to the sound card. With wave files, you're sending 44K samples per second (per channel) for CD quality sound.
I don't have any MIDI examples, but you should find lots of info in your compiler documentation/help.
True DOS is another story. You'd need the old DOS sound card drivers which may not be available for your sound card.
(Using the little internal PC speaker is another story too.)