if i want to play sound in a c++ program, can win32 console application do so? what function should i use? and do i have to include any other library??
please help, thank you so much
if i want to play sound in a c++ program, can win32 console application do so? what function should i use? and do i have to include any other library??
please help, thank you so much
hth
-nv
She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."
When in doubt, read the FAQ.
Then ask a smart question.
You can use the PlaySound() function. MSDN link:
http://msdn.microsoft.com/library/de...mfunc_9uxw.asp
Don't forget to link to Winmm.lib and include Mmsystem.h
how can you play sounds not using microsoft products? is there nothing in the stl that can do this?almost every time someone on here askes for a graphic sample or a play sound sample, they are referred back to ms products.does linix, unix not have sounds and graphics?or, are you confined to the little black box?( i know better), just want to see what kind of answers we get back.
Using the MS software to play sound is easy, especially since you seem to be working on a Windows machine, so you can use the Win32 MultiMedia API, see the links as provided above. If you don't want to use MS software, there are lots of libraries available which you can use. For example:
http://www.thefreecountry.com/develo...ibraries.shtml
"can win32 console application do so?"
The question sounded quite system specific, so we gave specific answers.
hth
-nv
She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."
When in doubt, read the FAQ.
Then ask a smart question.
Well last night I was looking through cprogramming's soucre code section and it had a sound example. So here ya go-
http://www.cprogramming.com/source/w...on=Jump&LID=29
I know of a library that can play wavs and mp3s and it might be platform independant. I'll dig it up, I've posted it before I think.
EDIT:
yes, fmod is it, i'll include a tutorial that shows it being used
FMOD stuff
Last edited by Shadow12345; 01-02-2003 at 04:01 PM.
FMOD ?Originally posted by Shadow12345
I know of a library that can play wavs and mp3s and it might be platform independant. I'll dig it up, I've posted it before I think.
http://www.fmod.org/
"...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers
so can it be done in the win32 console application?
i have browse through the msdn library and they have provide a function there, can it be done by just including the function in the program?
What kind of sound are you planning to play? wav? mp3?
You can use PlaySound() for wav declared in windows.h
defined in winmm.lib
SDL(libsdl.org), clanlib(clanlib.org), allegro(?? lol never looked into it), many more.. graphics, input, sound, and what not
all three of those are platform independent. btw, C/C++ is not like BASIC with gfx and sound in the language, you have to use apis and libraries (above ).
>so can it be done in the win32 console application?
Sure. Your application must know how to handle the soundcard and how to handle the format of the file (MP3, WAV etc.) you will be using. Note that a win32 console application is in short a win32 application without a GUI.