469,954 Members | 1,657 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,954 developers. It's quick & easy.

To Play ".wave" file with C++(Background music)

Hello :-)
how can i play a ".wav" file in C++.means with the help of the C++
code i just want to play a "a.wav" file more then 10 times. i just
want to play background music.
Can i do it in C++ ?
if yes then how ?

Thanks
Jun 27 '08 #1
10 6414
an**************@gmail.com wrote:
Hello :-)
how can i play a ".wav" file in C++.means with the help of the C++
code i just want to play a "a.wav" file more then 10 times. i just
want to play background music.
Can i do it in C++ ?
if yes then how ?

Thanks
You can, but its not a simple question nor a simple solution. If you
are a beginner to C++, it is likely out of your league. I'm *not* a
beginner, and I would struggle with it :-)

--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
Jun 27 '08 #2
On May 7, 8:02 pm, Daniel Pitts
<newsgroup.spamfil...@virtualinfinity.netwrote:
andrew.smith....@gmail.com wrote:
Hello :-)
how can i play a ".wav" file in C++.means with the help of the C++
code i just want to play a "a.wav" file more then 10 times. i just
want to play background music.
Can i do it in C++ ?
if yes then how ?
Thanks

You can, but its not a simple question nor a simple solution. If you
are a beginner to C++, it is likely out of your league. I'm *not* a
beginner, and I would struggle with it :-)

--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
Hello D :-)
I m Not a Beginner but i don't know anything about it.
i search its archive but all are showing "PlaySound" Function with the
"windows.h" header and i m user of "g++"
its not working there. so what should i use for it.
Boz of i have to play a music with the code of C++.
if u know then Tell Me How?
Thanks
Jun 27 '08 #3
an**************@gmail.com wrote:
On May 7, 8:02 pm, Daniel Pitts
<newsgroup.spamfil...@virtualinfinity.netwrote:
>andrew.smith....@gmail.com wrote:
>>Hello :-)
how can i play a ".wav" file in C++.means with the help of the C++
code i just want to play a "a.wav" file more then 10 times. i just
want to play background music.
Can i do it in C++ ?
if yes then how ?
Thanks
You can, but its not a simple question nor a simple solution. If you
are a beginner to C++, it is likely out of your league. I'm *not* a
beginner, and I would struggle with it :-)

--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
Hello D :-)
I m Not a Beginner but i don't know anything about it.
i search its archive but all are showing "PlaySound" Function with the
"windows.h" header and i m user of "g++"
its not working there. so what should i use for it.
Boz of i have to play a music with the code of C++.
if u know then Tell Me How?
Thanks
It depends on what OS/platform your targeting. There is no standard way
to do it.

--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
Jun 27 '08 #4
an**************@gmail.com wrote in news:6a5edae1-7698-4d95-98fa-
24**********@p39g2000prm.googlegroups.com:
On May 7, 8:02 pm, Daniel Pitts
[...]
I m Not a Beginner but i don't know anything about it.
i search its archive but all are showing "PlaySound" Function with the
"windows.h" header and i m user of "g++"
its not working there. so what should i use for it.
g++ works also in Windows and presumably is able to include <windows.h(if
you have downloaded and installed the Windows SDK first of course).

If you are not on Windows you have to find other means. On Linux a simple
bash script should be enough for such things, no need for C++.
hth
Paavo
Jun 27 '08 #5
an**************@gmail.com wrote:
I m Not a Beginner but i don't know anything about it.
i search its archive but all are showing "PlaySound" Function with the
"windows.h" header and i m user of "g++"
its not working there. so what should i use for it.
Boz of i have to play a music with the code of C++.
if u know then Tell Me How?
Thanks
PlaySound will do the trick - or you could link to the media player
control if you want to do anything more clever. either way, you should
ask on one of the microsoft.public groups, rather than here.

Andy
Jun 27 '08 #6
On May 8, 2:56 am, Andy Champ <no....@nospam.comwrote:
andrew.smith....@gmail.com wrote:
I m Not a Beginner but i don't know anything about it.
i search its archive but all are showing "PlaySound" Function with the
"windows.h" header and i m user of "g++"
its not working there. so what should i use for it.
Boz of i have to play a music with the code of C++.
if u know then Tell Me How?
Thanks

PlaySound will do the trick - or you could link to the media player
control if you want to do anything more clever. either way, you should
ask on one of the microsoft.public groups, rather than here.

Andy
again i m telling that i have "arch linux" and "g++" complier
Jun 27 '08 #7
Hi

an**************@gmail.com wrote:
again i m telling that i have "arch linux" and "g++" complier
You have not told us before. Anyway, you might want to have a look at libSDL
(http://www.libsdl.org/)

Markus

Jun 27 '08 #8
an**************@gmail.com wrote:

again i m telling that i have "arch linux" and "g++" complier
And if that matters, you're probably in the wrong group.

<http://www.parashift.com/c++-faq-lite/how-to-post.html>

Brian
Jun 27 '08 #9
an**************@gmail.com wrote:
>
again i m telling that i have "arch linux" and "g++" complier
Actually, at the time I wrote that, you had only said

"i search its archive but all are showing "PlaySound" Function with the
"windows.h" header"

Which sounds pretty much like Windoze. I can't help you on Linux.

Andy
Jun 27 '08 #10
On May 7, 10:00 pm, Paavo Helde <nob...@ebi.eewrote:
andrew.smith....@gmail.com wrote in news:6a5edae1-7698-4d95-98fa-
2440d5f9b...@p39g2000prm.googlegroups.com:
On May 7, 8:02 pm, Daniel Pitts
[...]
I m Not a Beginner but i don't know anything about it.
i search its archive but all are showing "PlaySound" Function with the
"windows.h" header and i m user of "g++"
its not working there. so what should i use for it.
g++ works also in Windows and presumably is able to include
<windows.h(if you have downloaded and installed the Windows
SDK first of course).
If you are not on Windows you have to find other means. On
Linux a simple bash script should be enough for such things,
no need for C++.
In general, if the goal is just to play some background music,
and no real interaction is involved, the best solution is likely
to be to figure out the system dependent command line request to
do it, and invoke that via the system() function. On most
systems, system() will return something which can later be
converted into a command line request to kill the process, if
that's needed as well. (On the systems I'm familiar with,
system returns the process id, and something like:

std::ostringstream cmd ;
cmd << "kill " << systemReturnValue ;
system( cmd.str().c_str() ) ;

can be used to stop the process.)

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Jun 27 '08 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by vikram | last post: by
2 posts views Thread by Lint Radley | last post: by
3 posts views Thread by andrew.smith.cpp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.