I am using AsioOut
because need to minimize latency as much as possible. Since I can only run 1 AsioOut at a time, I am using a MixingWaveProvider32
to play back multiple sounds at the same time. The problem I am running into is that I don't know how to properly remove 1 sound without pausing all the others.
I can easily add a new IWaveProvider
(AudioFileReader
in my case) to the MixingWaveProvider32
by simply adding it as an input stream, but if I try to remove it the same way the audio starts glitching (I think it's looping the last available buffer). I can prevent this by stopping the AsioOut
before swapping the sound, but this brings 2 problems:
AsioOut.Stop()
(the method never finishes).How do I properly remove 1 sound without running into these problems?
I found a solution myself: By running all sounds through a WaveChannel32
before putting them in the MixingWaveProvider32
I can add and remove the sounds at any time without stopping the AsioOut
without getting any audio glitches.