Thanks Mark, I'm getting sound now, but not as much as I would expect. Here is the new code. It plays about 1 second of sound,
but only because I'm looping 100 times.
WaveFormat waveFormat = new WaveFormat(44100, 16, 2);
BufferedWaveProvider bufferedWaveProvider = new BufferedWaveProvider(waveFormat);
using (IWavePlayer waveOut = new WasapiOut(AudioClientShareMode.Exclusive, false, 2))
for (int i = 0; i < 100; i++)
bufferedWaveProvider.AddSamples(CreateAudioBuffer(176400), 0, 176400);
if (waveOut.PlaybackState != PlaybackState.Playing)
CreateAudioBuffer(176400) returns a byte array with 176400 elements, or in other words 176400 bytes.
Lets say I want to play 1 second of cd quality sound. How many bytes would I have to create?
I would assume that I need 176400 bytes to do this. My reasoning being cd quality sound plays 44,100
16bit stereo samples a second. So take 44,100 and multiply by 2 for stereo and multiply by 2 for 16 bit
and that is how I get 176,400. 176,400 = 44,100 * 2 * 2. When using a RawSourceWaveStream I get about
second of sound when playing 176,400 bytes, which is what I would expect. But when I use BufferedWaveProvider,
I only get about 1/100 of a second of sound. Any ideas why? Thanks again for the help!