Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Need a good sound API

Need a good sound API

Scheduled Pinned Locked Moved C / C++ / MFC
c++game-devjson
16 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hanan888
    wrote on last edited by
    #1

    I'm developing a game application, with multiple windows, in C++ on Win32. My sound needs is to play a few short sounds when some events happen, plus some background music in the main menu.

    CPalliniC H N S J 5 Replies Last reply
    0
    • H Hanan888

      I'm developing a game application, with multiple windows, in C++ on Win32. My sound needs is to play a few short sounds when some events happen, plus some background music in the main menu.

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      DiretcX Audio [^] doesn't fit your needs, does it? :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

      In testa che avete, signor di Ceprano?

      H 1 Reply Last reply
      0
      • CPalliniC CPallini

        DiretcX Audio [^] doesn't fit your needs, does it? :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

        H Offline
        H Offline
        Hanan888
        wrote on last edited by
        #3

        Thanks. I had a taste of DirectSound. My problem with it, takes me too long to figure out if I should explicitly stop a playing sound when switching focus to another window in my application or if it's done automatically somehow. According to XAudio2 Overview [^] : "For Windows game developers, XAudio2 is the long-awaited replacement for DirectSound". I would glad to read any recommendations / cons.

        M 1 Reply Last reply
        0
        • H Hanan888

          I'm developing a game application, with multiple windows, in C++ on Win32. My sound needs is to play a few short sounds when some events happen, plus some background music in the main menu.

          H Offline
          H Offline
          Hamid Taebi
          wrote on last edited by
          #4

          Or you can use of MCI_PLAY[^] with an example[^].

          H 1 Reply Last reply
          0
          • H Hanan888

            I'm developing a game application, with multiple windows, in C++ on Win32. My sound needs is to play a few short sounds when some events happen, plus some background music in the main menu.

            N Offline
            N Offline
            Nibu babu thomas
            wrote on last edited by
            #5

            Hanan888 wrote:

            My sound needs is to play a few short sounds

            Use sndPlaySound for playing short wav files.

            Hanan888 wrote:

            plus some background music

            Use SND_ASYNC | SND_LOOP to asynchronously play in the background without stopping. e.g.

            // Keeps playing in the background
            sndPlaySound(_T( "C:\WIndows\Media\notify.wav", SND_ASYNC | SND_LOOP );

            Another option is PlaySound. These API's are pretty limited but quite handy!

            Nibu babu thomas Microsoft MVP for VC++ Code must be written to be read, not by the compiler, but by another human being. Programming Blog: http://nibuthomas.wordpress.com

            modified on Thursday, June 19, 2008 9:39 AM

            H 1 Reply Last reply
            0
            • H Hanan888

              I'm developing a game application, with multiple windows, in C++ on Win32. My sound needs is to play a few short sounds when some events happen, plus some background music in the main menu.

              S Offline
              S Offline
              Saurabh Garg
              wrote on last edited by
              #6

              Have you tried SDL[^]? Saurabh-

              H 1 Reply Last reply
              0
              • N Nibu babu thomas

                Hanan888 wrote:

                My sound needs is to play a few short sounds

                Use sndPlaySound for playing short wav files.

                Hanan888 wrote:

                plus some background music

                Use SND_ASYNC | SND_LOOP to asynchronously play in the background without stopping. e.g.

                // Keeps playing in the background
                sndPlaySound(_T( "C:\WIndows\Media\notify.wav", SND_ASYNC | SND_LOOP );

                Another option is PlaySound. These API's are pretty limited but quite handy!

                Nibu babu thomas Microsoft MVP for VC++ Code must be written to be read, not by the compiler, but by another human being. Programming Blog: http://nibuthomas.wordpress.com

                modified on Thursday, June 19, 2008 9:39 AM

                H Offline
                H Offline
                Hamid Taebi
                wrote on last edited by
                #7

                I wanted to tell him sndPlaySound but I forgot its name :laugh: .

                N 1 Reply Last reply
                0
                • H Hamid Taebi

                  I wanted to tell him sndPlaySound but I forgot its name :laugh: .

                  N Offline
                  N Offline
                  Nibu babu thomas
                  wrote on last edited by
                  #8

                  :)

                  Nibu babu thomas Microsoft MVP for VC++ Code must be written to be read, not by the compiler, but by another human being. Programming Blog: http://nibuthomas.wordpress.com

                  1 Reply Last reply
                  0
                  • H Hanan888

                    Thanks. I had a taste of DirectSound. My problem with it, takes me too long to figure out if I should explicitly stop a playing sound when switching focus to another window in my application or if it's done automatically somehow. According to XAudio2 Overview [^] : "For Windows game developers, XAudio2 is the long-awaited replacement for DirectSound". I would glad to read any recommendations / cons.

                    M Offline
                    M Offline
                    Mark Salsbery
                    wrote on last edited by
                    #9

                    Hanan888 wrote:

                    My problem with it, takes me too long to figure out if I should explicitly stop a playing sound when switching focus to another window

                    Huh?  You'll have the same problem (whatever the problem is) with any of the audio APIs. DirectSound handles all the mixing for you so it should be the simplest to use.  It's used in a LOT of games. XAudio2 is great/new but for XP SP2+ only if that's an issue.

                    Mark Salsbery Microsoft MVP - Visual C++ :java:

                    H 1 Reply Last reply
                    0
                    • H Hanan888

                      I'm developing a game application, with multiple windows, in C++ on Win32. My sound needs is to play a few short sounds when some events happen, plus some background music in the main menu.

                      J Offline
                      J Offline
                      jkvato
                      wrote on last edited by
                      #10

                      You could also use a 3rd party audio library. I've tinkered with the following two: http://www.fmod.org/[^] http://www.un4seen.com/[^] They are overkill, perhaps, but they'll do what you need them to do. They are free for non-commercial use. They also have shareware licenses and full commercial licenses. Good luck!

                      1 Reply Last reply
                      0
                      • M Mark Salsbery

                        Hanan888 wrote:

                        My problem with it, takes me too long to figure out if I should explicitly stop a playing sound when switching focus to another window

                        Huh?  You'll have the same problem (whatever the problem is) with any of the audio APIs. DirectSound handles all the mixing for you so it should be the simplest to use.  It's used in a LOT of games. XAudio2 is great/new but for XP SP2+ only if that's an issue.

                        Mark Salsbery Microsoft MVP - Visual C++ :java:

                        H Offline
                        H Offline
                        Hanan888
                        wrote on last edited by
                        #11

                        Thanks.

                        Mark Salsbery wrote:

                        XAudio2 is great/new but for XP SP2+ only if that's an issue

                        Can you please be specific about that ?

                        M 1 Reply Last reply
                        0
                        • H Hamid Taebi

                          Or you can use of MCI_PLAY[^] with an example[^].

                          H Offline
                          H Offline
                          Hanan888
                          wrote on last edited by
                          #12

                          Thanks. Cool example, haven't still figured out if MCI is good for me. Have you had any experience using it ?

                          H 1 Reply Last reply
                          0
                          • S Saurabh Garg

                            Have you tried SDL[^]? Saurabh-

                            H Offline
                            H Offline
                            Hanan888
                            wrote on last edited by
                            #13

                            Thanks. I once looked at SDL documentation and I thought, using SDL is something that I might use to build the entire application, not to add functionality. Am I wrong ?

                            S 1 Reply Last reply
                            0
                            • H Hanan888

                              Thanks. I once looked at SDL documentation and I thought, using SDL is something that I might use to build the entire application, not to add functionality. Am I wrong ?

                              S Offline
                              S Offline
                              Saurabh Garg
                              wrote on last edited by
                              #14

                              I am not sure what you mean by "building an entire application" vs "adding functionality". SDL can be used to play sound. This is from the documentation. 1. Set audio playback of 8-bit and 16-bit audio, mono or stereo, with optional conversion if the format is not supported by the hardware. 2. Audio runs independently in a separate thread, filled via a user callback mechanism. 3. Designed for custom software audio mixers, but the example archive contains a complete audio/music output library. -Saurabh

                              1 Reply Last reply
                              0
                              • H Hanan888

                                Thanks.

                                Mark Salsbery wrote:

                                XAudio2 is great/new but for XP SP2+ only if that's an issue

                                Can you please be specific about that ?

                                M Offline
                                M Offline
                                Mark Salsbery
                                wrote on last edited by
                                #15

                                Hanan888 wrote:

                                Can you please be specific about that ?

                                It's not supported on unsupported operating systems, which means all OSs before XP. Mark

                                Mark Salsbery Microsoft MVP - Visual C++ :java:

                                1 Reply Last reply
                                0
                                • H Hanan888

                                  Thanks. Cool example, haven't still figured out if MCI is good for me. Have you had any experience using it ?

                                  H Offline
                                  H Offline
                                  Hamid Taebi
                                  wrote on last edited by
                                  #16

                                  Yeah,you can use of MCI for play mp3,wav,mpeg1,mpeg2,avi files.

                                  1 Reply Last reply
                                  0
                                  Reply
                                  • Reply as topic
                                  Log in to reply
                                  • Oldest to Newest
                                  • Newest to Oldest
                                  • Most Votes


                                  • Login

                                  • Don't have an account? Register

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • World
                                  • Users
                                  • Groups