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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Playing raw audio files thru c or c++

Playing raw audio files thru c or c++

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorial
8 Posts 4 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.
  • S Offline
    S Offline
    shiva shankar
    wrote on last edited by
    #1

    can anybody guide me to write c or c++ code to play an raw audio files thank you bye sham

    A A 2 Replies Last reply
    0
    • S shiva shankar

      can anybody guide me to write c or c++ code to play an raw audio files thank you bye sham

      A Offline
      A Offline
      Alexander M
      wrote on last edited by
      #2

      create a buffer with the characteristics of the raw sound (srate, bits etc) then copy the data in and start playing it. Don't try it, just do it! ;-)

      S 1 Reply Last reply
      0
      • A Alexander M

        create a buffer with the characteristics of the raw sound (srate, bits etc) then copy the data in and start playing it. Don't try it, just do it! ;-)

        S Offline
        S Offline
        shiva shankar
        wrote on last edited by
        #3

        i didn't get what your are trying say. please an you be more specfic.

        A 1 Reply Last reply
        0
        • S shiva shankar

          i didn't get what your are trying say. please an you be more specfic.

          A Offline
          A Offline
          Alexander M
          wrote on last edited by
          #4

          I propose that you use DirectSound. You create a buffer with the specifications of the wave data (sample rate, bits/blocksize, ...), then you lock the buffer, copy the data in, unlock it and then start playback. read the sdk for further information. Don't try it, just do it! ;-)

          D 1 Reply Last reply
          0
          • A Alexander M

            I propose that you use DirectSound. You create a buffer with the specifications of the wave data (sample rate, bits/blocksize, ...), then you lock the buffer, copy the data in, unlock it and then start playback. read the sdk for further information. Don't try it, just do it! ;-)

            D Offline
            D Offline
            Dimenser
            wrote on last edited by
            #5

            Here's what I do in Visual C++ 6.0. 1. Import the .wav file and name it something you'll remember, like IDR_BADBEEP. 2. Add #include "mmsystem.h" to the top of your file. 3. In Project/Settings/Link, add Winmm.lib 4. In the actual code where I want the sound effect to play, add: PlaySound(MAKEINTRESOURCE(IDR_BADBEEP),GetModuleHandle(NULL),SND_RESOURCE | SND_ASYNC); This will play the sound effect until the program is shut down, the sound effect is entirely played, or another sound effect is started. It's easy and works.:cool: Dimenser

            S 1 Reply Last reply
            0
            • S shiva shankar

              can anybody guide me to write c or c++ code to play an raw audio files thank you bye sham

              A Offline
              A Offline
              avenger_sb25
              wrote on last edited by
              #6

              simple, to play a .wav file in VC++ use PlaySound(...) function //look for the parameters at www.msdn.com And dont forget to include the winmm.lib in the project settings.


              Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs

              S 1 Reply Last reply
              0
              • A avenger_sb25

                simple, to play a .wav file in VC++ use PlaySound(...) function //look for the parameters at www.msdn.com And dont forget to include the winmm.lib in the project settings.


                Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs

                S Offline
                S Offline
                shiva shankar
                wrote on last edited by
                #7

                but i want play this raw with some sampling rate(Fs=8000), i don't thing this would support it.

                1 Reply Last reply
                0
                • D Dimenser

                  Here's what I do in Visual C++ 6.0. 1. Import the .wav file and name it something you'll remember, like IDR_BADBEEP. 2. Add #include "mmsystem.h" to the top of your file. 3. In Project/Settings/Link, add Winmm.lib 4. In the actual code where I want the sound effect to play, add: PlaySound(MAKEINTRESOURCE(IDR_BADBEEP),GetModuleHandle(NULL),SND_RESOURCE | SND_ASYNC); This will play the sound effect until the program is shut down, the sound effect is entirely played, or another sound effect is started. It's easy and works.:cool: Dimenser

                  S Offline
                  S Offline
                  shiva shankar
                  wrote on last edited by
                  #8

                  suggestion which you have given it support for only .wav file ,but i need to play .raw files at some sampling rate(Fs=8000).plz guide me.

                  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