This project has moved and is read-only. For the latest updates, please go here.

FireAndForget sounds played at intervals

Mar 24, 2014 at 7:38 AM
Using the sample code for FireAndForget sound playback, I'm loading up 31 CachedSound objects and playing them back at small intervals (<100ms). Playing the sounds using the same code as used in the sample leads to sounds being "queued up" and played back at regular intervals.

I clearly don't understand how the MixingSampleProvider is supposed to work since it seems like it should be playing my sounds as I send them, not playing the last 4 sounds I sent it some time ago at once.

My only other working solution at this point has been to create a new IWavePlayer, Channel ,and Stream for each sound, which is clearly not an optimal solution. I need upwards of 40-50 very short (<1second) sounds to be played in rapid succession; for example a sound for each key on the keyboard played back like someone is typing. Mixers seems like the way to go, but I can't get over this sound delay.
Mar 25, 2014 at 8:29 AM
There will be a latency of the duration of the buffer you are using in your IWavePlayer. Also the MixingSampleProvider does only allow new inputs to be added between calls to Read, so if during the time of one buffer you added four sounds, they would all end up getting added to start at the exact same instant. A quick fix to this would be the OffsetSampleProvider. You can look at the drum machine demo in the WPF sample project, which shows how much more accurate queuing up of sounds to be played can be achieved.
Marked as answer by gokiburikin on 3/25/2014 at 1:16 AM
Mar 25, 2014 at 9:17 AM
Thank you. That answered all of my questions and shed some light on the issue which is now resolved.