can't play wav sound...

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2004
Posts: 22
Reputation: kakilang is an unknown quantity at this point 
Solved Threads: 0
kakilang's Avatar
kakilang kakilang is offline Offline
Newbie Poster

can't play wav sound...

 
0
  #1
Oct 29th, 2004
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
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 3,972
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 920
Moderator
vegaseat's Avatar
vegaseat vegaseat is online now Online
DaniWeb's Hypocrite

Re: can't play wav sound...

 
0
  #2
Oct 29th, 2004
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!
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,612
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 713
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: can't play wav sound...

 
0
  #3
Oct 29th, 2004
>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.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 3,972
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 920
Moderator
vegaseat's Avatar
vegaseat vegaseat is online now Online
DaniWeb's Hypocrite

Re: can't play wav sound...

 
0
  #4
Oct 29th, 2004
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.
  1. PlayWav("chimes.wav")
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 22
Reputation: kakilang is an unknown quantity at this point 
Solved Threads: 0
kakilang's Avatar
kakilang kakilang is offline Offline
Newbie Poster

Re: can't play wav sound...

 
0
  #5
Oct 29th, 2004
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??
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,612
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 713
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: can't play wav sound...

 
0
  #6
Oct 30th, 2004
>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.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 22
Reputation: kakilang is an unknown quantity at this point 
Solved Threads: 0
kakilang's Avatar
kakilang kakilang is offline Offline
Newbie Poster

Re: can't play wav sound...

 
0
  #7
Oct 30th, 2004
thx for helps
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 22
Reputation: kakilang is an unknown quantity at this point 
Solved Threads: 0
kakilang's Avatar
kakilang kakilang is offline Offline
Newbie Poster

Re: can't play wav sound...

 
-1
  #8
Nov 21st, 2004
Bump Bump Bump
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 3,972
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 920
Moderator
vegaseat's Avatar
vegaseat vegaseat is online now Online
DaniWeb's Hypocrite

Re: can't play wav sound...

 
0
  #9
Nov 21st, 2004
kakilang seems to be bored and needs something to chew on. I just threw up a little code snippet called "An AVI Media Player (GUI code for Dev C++)" check it out there.
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 10
Reputation: bballmitch is an unknown quantity at this point 
Solved Threads: 0
bballmitch bballmitch is offline Offline
Newbie Poster

Re: can't play wav sound...

 
0
  #10
Jun 21st, 2005
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??
umm...thats still not working for me. it keeps giving me this error....
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC