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

Buffer exception for WasapiLoopbackCapture on Windows 8 64 bit system

Oct 29, 2013 at 5:36 AM
I am trying to make network chat application, that I was capturing the sound using wasapiloopback, and trying to playback, I was using the BufferedWaveProvider to add samples when the DataAvailable fires of the capture, it works fine on a Windows7 64 bit OS, however it always give "Buffer full" expception when I tried on Windows8 64 OS, any idea about why this happens?

another question I had is that as I am new to NAudio, how can I compress the sound captured from the WasapiLoopback, and then send it over the network.
Oct 29, 2013 at 12:41 PM
well what is playing from the BufferedWaveProvider? If you keep adding stuff but not removing it, it will fill it up.

To get you started on NetworkChat, have a look at the source code for the Network Chat demo in the NAudioDemo project. I'm also very close to releasing an NAudio tutorial video series on Pluralsight which includes a module on streaming audio.
Oct 29, 2013 at 4:07 PM
Thanks, Mark.

I get the playback working by changing the project configuration and target from Any CPU to x86.

Here is the piece of my code.
the Format is -- 32 bit PCM: 44kHz 2 channels wBitsPerSample:32 dwChannelMask:3 subFormat:00000003-0000-0010-8000-00aa00389b71 extraSize:22

so My question is how can I encode and decode the buffer? thanks a lot
            DirectSoundOut dsOut = null;
            BufferedWaveProvider provider = null;
        WasapiLoopbackCapture loopback = new WasapiLoopbackCapture();
        var format = loopback.WaveFormat;
            provider = new BufferedWaveProvider(format);
            dsOut = new DirectSoundOut(1000);
            loopback.DataAvailable += loopback_DataAvailable;

void loopback_DataAvailable(object sender, WaveInEventArgs e)
            //provider.AddSamples(decoded, 0, decoded.Length);
            provider.AddSamples(e.Buffer, 0, e.BytesRecorded);
Oct 31, 2013 at 10:06 AM
Has anyone has the same requirement to encode/decode the data recorded by wasapiloopack?
Nov 1, 2013 at 5:10 PM
first convert from the 32 bit floating point samples to 16 bit ones, then you can use ACM codecs to encode the audio.
Nov 9, 2013 at 7:44 AM
Thanks, I did exactly what you said, and you it worked well, thanks.