473,394 Members | 4,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 7004
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: vikram | last post by:
in a stereo type of wave file i want to know what is this left & right info in a wave file??? how do i read the left & right info from a .wav file to a buffer..
9
by: Morris Neuman | last post by:
Im working with VS 2005 and trying to use a Hyperlink field in a datagrid to play a wave file that is not located in the website folders but is in a plain folder on the same machine, windows 2003...
0
by: ryan186 | last post by:
I need to write in java to get a wave file from the internet chunk by chunk, given the IP address, but i have no idea how to write, can some body give me a hand? Thank you
0
by: Simrat Kaur Sandhu | last post by:
hello friends can anybody tell me how to read data from a wave file.. i have writen code as ... class file { private: FILE *fp; char id; char *sound_buffer; //four bytes to hold 'RIFF' long...
2
by: Lint Radley | last post by:
Hello Everyone, I've seen online many examples online using a DLLImport of WinMM.dll to a WAVE file in C#/.NET. I haven't seen any methods in the .NET Framework - does it not exist, or am I...
2
by: homevista | last post by:
Our goal here: We want the PC to call a designated phone number when something happens, and report it in easy-to-understand spoken audio snippets which are saved in the form of pre-recorded wave...
1
by: homevista | last post by:
Part II: Wave file - How to read to a buffer Wave (or Wav) is the standard format for storing audio data on the PC. As software developers, we are interested in the internal structure of the file...
6
by: homevista | last post by:
PART III: Putting things together In part I we examined the modem to verify that it supported voice. If so, we took a note about the voice data format that we would use. In the second part, we...
3
by: andrew.smith.cpp | last post by:
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++ ?...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.