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

Playing Audio File Intermittently With WaveStream

Feb 27, 2013 at 10:40 PM
Hello,

Using 2 DirectSoundOut objects I am trying to repeatedly trigger a short wave file(100ms) clip with sinewave stream. I attempted to use a System.Timer and pass a double interval argument to trigger file play. This is all happening via UI slider control. All attempts have wreaked much havoc in terms of threading conflicts. Would it be better to dump the samples from file into a buffer and call from that? It only needs to play once and then pause apx .5 seconds, play again etc.

Thanks for your consideration.
Mar 1, 2013 at 3:24 PM
Yes, I usually try to open the output device and create a custom WaveProvider to feed the audio to be played into it. If you need sounds to be playing at the same time you'd need to use the MixingSampleProvider
Mar 1, 2013 at 10:49 PM
Ok, I see. Actually got around the whole timer thing by setting up a global counter that kept track of 2 second clip(as this was total interval between 100ms hit). I stored the 100ms sample integers in static utility class and wrote array of zeros(unititalized) for the difference. Then the global count would store the iteration of 2 second array when the IWaveProvider buffer[] from Read method would fill its 3520/7040 limit. Out of curiosity, are these set in stone, meaning can I alter the buffer size ever?

Thanks
Mar 2, 2013 at 7:59 AM
No buffer size is constant. You might find BufferedWaveProvider to be helpful here. You can just feed in audio to be played into it, and then use that to drive the DirectSoundOut
Mar 3, 2013 at 1:39 AM
BufferedWaveProvider is perfect. Much obliged.