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. Realtime sound mixing

Realtime sound mixing

Scheduled Pinned Locked Moved C / C++ / MFC
game-devgraphicshelptutorialquestion
4 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.
  • W Offline
    W Offline
    wParam
    wrote on last edited by
    #1

    Does anyone know how, or have a link to a place that has info on how to do realtime mixing of wav files? I've gotten the mixing down, and it works fine, just have channels and "mix" them by adding bytes of the wav. My problem is that I'm doing this for a game, and because the output buffer is 1024 bytes, sometimes you can notice a delay between when the event (an explosion in this case) occurs and when the sound plays. But making the buffer short enough so that the delay isn't noticable is so short that my computer (pIII-450) can't keep up. Is there a way to access the data you've already passed to waveOutWrite? Or is there some other way I might be able to get rid of this stupid delay. (I know directsound can probably handle it, but I'm interested in a non-directx solution, if one exists.) -wP

    R L L 3 Replies Last reply
    0
    • W wParam

      Does anyone know how, or have a link to a place that has info on how to do realtime mixing of wav files? I've gotten the mixing down, and it works fine, just have channels and "mix" them by adding bytes of the wav. My problem is that I'm doing this for a game, and because the output buffer is 1024 bytes, sometimes you can notice a delay between when the event (an explosion in this case) occurs and when the sound plays. But making the buffer short enough so that the delay isn't noticable is so short that my computer (pIII-450) can't keep up. Is there a way to access the data you've already passed to waveOutWrite? Or is there some other way I might be able to get rid of this stupid delay. (I know directsound can probably handle it, but I'm interested in a non-directx solution, if one exists.) -wP

      R Offline
      R Offline
      RockNix
      wrote on last edited by
      #2

      Hi, have you tried using more but shorter buffers ? Ok this will cause a higher use of the write functions - but shorter buffers have of course shorter delay in change. But wait - You are using 1024 Sample Buffers ? I guess for a game you are using 44,1k/16bit/mono ? That means the total play-time of the buffer is about 23ms. Therefor a change needs at least this time to appear. On the other side this time can only appear as a short chorusing effect because the time is to short for human hearing to notify 2 seperate sounds. I think you should not notify a delay. Maybe you have a great preformance loss in your wave-mixer ? You should check it out. To raise up speed you should not use the wave-event (don`t know if you did). Better use the WaveOutProc-CALLBACK. Then you should put the output routine in a seperate thread. Hope it helps Mario /// ---------------------- www.klangwerker.de mario@klangwerker.de ----------------------

      1 Reply Last reply
      0
      • W wParam

        Does anyone know how, or have a link to a place that has info on how to do realtime mixing of wav files? I've gotten the mixing down, and it works fine, just have channels and "mix" them by adding bytes of the wav. My problem is that I'm doing this for a game, and because the output buffer is 1024 bytes, sometimes you can notice a delay between when the event (an explosion in this case) occurs and when the sound plays. But making the buffer short enough so that the delay isn't noticable is so short that my computer (pIII-450) can't keep up. Is there a way to access the data you've already passed to waveOutWrite? Or is there some other way I might be able to get rid of this stupid delay. (I know directsound can probably handle it, but I'm interested in a non-directx solution, if one exists.) -wP

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Hi, I would recommend having a quick look at the FMOD sound library. It's been around for a while, so is quite mature and stable. Have a look at www.fmod.org for further details. Hope this helps, Regards, Craig.

        1 Reply Last reply
        0
        • W wParam

          Does anyone know how, or have a link to a place that has info on how to do realtime mixing of wav files? I've gotten the mixing down, and it works fine, just have channels and "mix" them by adding bytes of the wav. My problem is that I'm doing this for a game, and because the output buffer is 1024 bytes, sometimes you can notice a delay between when the event (an explosion in this case) occurs and when the sound plays. But making the buffer short enough so that the delay isn't noticable is so short that my computer (pIII-450) can't keep up. Is there a way to access the data you've already passed to waveOutWrite? Or is there some other way I might be able to get rid of this stupid delay. (I know directsound can probably handle it, but I'm interested in a non-directx solution, if one exists.) -wP

          L Offline
          L Offline
          l a u r e n
          wrote on last edited by
          #4

          am just curious ... is there a reason for not using directx? after all they have spent the past 6 years getting it kinda right i understand :suss: --- "every year we invent better idiot proof systems and every year they invent better idiots"

          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