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

Discussion in 'C++' started by andrew.smith.cpp@gmail.com, May 7, 2008.

  1. Guest

    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
     
    , May 7, 2008
    #1
    1. Advertising

  2. Daniel Pitts Guest

    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/>
     
    Daniel Pitts, May 7, 2008
    #2
    1. Advertising

  3. Guest

    On May 7, 8:02 pm, Daniel Pitts
    <> wrote:
    > 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
     
    , May 7, 2008
    #3
  4. Daniel Pitts Guest

    wrote:
    > On May 7, 8:02 pm, Daniel Pitts
    > <> wrote:
    >> 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/>
     
    Daniel Pitts, May 7, 2008
    #4
  5. Guest

    On May 8, 2:56 am, Andy Champ <> wrote:
    > 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
     
    , May 8, 2008
    #5
  6. Markus Moll Guest

    Hi

    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
     
    Markus Moll, May 8, 2008
    #6
  7. Default User Guest

    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
     
    Default User, May 8, 2008
    #7
  8. James Kanze Guest

    On May 7, 10:00 pm, Paavo Helde <> wrote:
    > wrote in news:6a5edae1-7698-4d95-98fa-
    > :
    > > 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::eek:stringstream cmd ;
    cmd << "kill " << systemReturnValue ;
    system( cmd.str().c_str() ) ;

    can be used to stop the process.)

    --
    James Kanze (GABI Software) email:
    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
     
    James Kanze, May 9, 2008
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TW9ycmlzIE5ldW1hbg==?=

    Datagrid Hyperlink field to play file system wave file help.

    =?Utf-8?B?TW9ycmlzIE5ldW1hbg==?=, Aug 24, 2006, in forum: ASP .Net
    Replies:
    9
    Views:
    5,327
    Guido Helmers
    Sep 11, 2006
  2. red floyd
    Replies:
    5
    Views:
    1,055
    Nathan Wijnia
    Jun 21, 2007
  3. Karthik
    Replies:
    0
    Views:
    806
    Karthik
    Sep 5, 2007
  4. Replies:
    4
    Views:
    1,008
    James Kanze
    May 9, 2008
  5. rara10
    Replies:
    0
    Views:
    952
    rara10
    Jan 30, 2009
Loading...

Share This Page