windowswinapiaudiowinmm

multi channel sound with winmm, many WaveOutOpen?


I am trying to play a sound on Windows XP in multi-channel (parallel) manner. I had read somewhere that playing parallel sounds with WinMM is maybe not possible, but here is what I observe:

When I call WaveOutOpen() once, and then call many WaveOutWrite() many times then sounds are not parallel - they are queued.

But when I call WaveOutOpen say nine times (and then store nine handles to it) and then call nine times WaveOutWrite() with nine different sounds they are played in parallel (multi-channel) - that is they are mixed.

It seems to work but I am not sure if it is okay because I don't find it stated clearly in any tutorial or documentation.

It is okay to play sound in such 'many WaveOutOpen' way??


Solution

  • When I call WaveOutOpen() once, and then call many WaveOutWrite() many times then sounds are not parallel - they are queued.

    That's exactly what is supposed to happen. WaveOutWrite queues the next buffer. It allows you to send the audio you want to play in small chunks.

    But when I call WaveOutOpen say nine times (and then store nine handles to it) and then call nine times WaveOutWrite() with nine different sounds they are played in parallel (multi-channel) - that is they are mixed.

    Again, this is correct and expected. This is the simplest way to play back many simultaneous sounds. If you want sample accurate mixing however, you should mix the audio samples yourself into one stream of samples and play that through a single WaveOut device.