| | |
can't play wav sound...
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
below is the source code that i type, but it can't play the wav sound
[PHP]#include <windows.h>
#include <mmsystem.h>
int main()
{
PlaySound("chimes.wav",NULL,SND_FILENAME|SND_LOOP|SND_ASYNC);
return o;
}[/PHP]
when i compile this source code the compiler prompt link error
can anyone help to show the problem
i using windows xp and dec c++ 4.9.9.0 compiler
[PHP]#include <windows.h>
#include <mmsystem.h>
int main()
{
PlaySound("chimes.wav",NULL,SND_FILENAME|SND_LOOP|SND_ASYNC);
return o;
}[/PHP]
when i compile this source code the compiler prompt link error
can anyone help to show the problem
i using windows xp and dec c++ 4.9.9.0 compiler
Now it gets hairy!
You are talking GUI programming and need to bind with winmm.lib or such, or perhaps load winmm.dll. BCX makes that easy and has a sample! Dev-Cpp has something like like libwinmm.a in the \lib directory. Maybe we have to wait till Narue wakes up, he knows everything and will help you!
You are talking GUI programming and need to bind with winmm.lib or such, or perhaps load winmm.dll. BCX makes that easy and has a sample! Dev-Cpp has something like like libwinmm.a in the \lib directory. Maybe we have to wait till Narue wakes up, he knows everything and will help you!
May 'the Google' be with you!
>You are talking GUI programming
No, PlaySound isn't a GUI function, but it does require linking with a new library.
>can anyone help to show the problem
You need to link with winmm.lib. IIRC you can go to the Project menu, select Project Options, then in the box titled "Object File or Linker Options" add -lwinmm.lib to the list. I'm fairly certain that the library is available--but not linked--by default for Dev-C++, so after doing this your build should work fine.
No, PlaySound isn't a GUI function, but it does require linking with a new library.
>can anyone help to show the problem
You need to link with winmm.lib. IIRC you can go to the Project menu, select Project Options, then in the box titled "Object File or Linker Options" add -lwinmm.lib to the list. I'm fairly certain that the library is available--but not linked--by default for Dev-C++, so after doing this your build should work fine.
I'm here to prove you wrong.
If you succeed in DevCpp with this sound project, please post it! By the way, just in case you are curious, this would be the code for BCX, a one liner, short and simple! If you look at the generated C code, it uses PlaySound() from the winmm.dll which is in the Windows\system32\ directory. Compiles to a 24k executable that chimes.
C++ Syntax (Toggle Plain Text)
PlayWav("chimes.wav")
May 'the Google' be with you!
Vegaseat and Narue thx for yours help
i succeed play the wav sound Here i will review the step again of how to code a porgram that play wav sound by using Dev-c++ 4.9.9.0
1- create a project file.
2-Choose Console Application in Basic tab.
3-After Create the Project File go to Project Option
4-Choose Parameter tab
5-Click the Add Library or Object
6-Browse the location of Dev-c++ lib and choose the libwinmm
7-click ok and exit the Project Option
8-type the below source code
[PHP]#include <windows.h>
#include <mmsystem.h>
#include <conio.h>
using namespace std;
int main(int argc, char *argv[])
{
PlaySound("chimes.wav",NULL,SND_FILENAME|SND_ASYNC);//PLAY WAV SOUND ONCE
//PlaySound("chimes.wav",NULL,SND_FILENAME|SND_LOOP|SND_ASYNC);
//ANOTHER OPTION PLAY REPEATED WAV SOUND
getch();
return 0;
}[/PHP]
then when u run ur program there will be chimes wav sound
Does anyone know how to modify above source code in order to play Windows Media File or play bigger size of the wav file??
i succeed play the wav sound Here i will review the step again of how to code a porgram that play wav sound by using Dev-c++ 4.9.9.0
1- create a project file.
2-Choose Console Application in Basic tab.
3-After Create the Project File go to Project Option
4-Choose Parameter tab
5-Click the Add Library or Object
6-Browse the location of Dev-c++ lib and choose the libwinmm
7-click ok and exit the Project Option
8-type the below source code
[PHP]#include <windows.h>
#include <mmsystem.h>
#include <conio.h>
using namespace std;
int main(int argc, char *argv[])
{
PlaySound("chimes.wav",NULL,SND_FILENAME|SND_ASYNC);//PLAY WAV SOUND ONCE
//PlaySound("chimes.wav",NULL,SND_FILENAME|SND_LOOP|SND_ASYNC);
//ANOTHER OPTION PLAY REPEATED WAV SOUND
getch();
return 0;
}[/PHP]
then when u run ur program there will be chimes wav sound
Does anyone know how to modify above source code in order to play Windows Media File or play bigger size of the wav file??
>Does anyone know how to modify above source code in order to play Windows Media File or play bigger size of the wav file??
http://msdn.microsoft.com/library/de..._win32_mci.asp
Knock yourself out.
http://msdn.microsoft.com/library/de..._win32_mci.asp
Knock yourself out.
I'm here to prove you wrong.
•
•
Join Date: Jun 2005
Posts: 10
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by kakilang
Vegaseat and Narue thx for yours help
i succeed play the wav sound Here i will review the step again of how to code a porgram that play wav sound by using Dev-c++ 4.9.9.0
1- create a project file.
2-Choose Console Application in Basic tab.
3-After Create the Project File go to Project Option
4-Choose Parameter tab
5-Click the Add Library or Object
6-Browse the location of Dev-c++ lib and choose the libwinmm
7-click ok and exit the Project Option
8-type the below source code
[PHP]#include <windows.h>
#include <mmsystem.h>
#include <conio.h>
using namespace std;
int main(int argc, char *argv[])
{
PlaySound("chimes.wav",NULL,SND_FILENAME|SND_ASYNC);//PLAY WAV SOUND ONCE
//PlaySound("chimes.wav",NULL,SND_FILENAME|SND_LOOP|SND_ASYNC);
//ANOTHER OPTION PLAY REPEATED WAV SOUND
getch();
return 0;
}[/PHP]
then when u run ur program there will be chimes wav sound
Does anyone know how to modify above source code in order to play Windows Media File or play bigger size of the wav file??
C:\Documents and Settings\mitchell\Desktop\Playing sound\Makefile.win [Build Error] [Project1.exe] Error 1
i did EXACTLY what you said and it won't compile.
any help would be great. ![]() |
Similar Threads
- Code Snippet: This is a visual basic 6.0 wav sound player class that plays any selected sound file in .wav format. It has the filename property to select the file and play property to play the sound file. (Visual Basic 4 / 5 / 6)
- Play a wav. file (Java)
- Playing a wav sound from program (C++)
- Cpp program to play wav ffile (sound) (C++)
Other Threads in the C++ Forum
- Previous Thread: Masking a telephone directory
- Next Thread: Help with mmap
| Thread Tools | Search this Thread |
api array based binary c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock wordfrequency wxwidgets






