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

Upgraded NAudio from v1.3.14 to v1.7.3 which crashes at _waveIn.StartRecording();

Apr 24, 2015 at 9:59 AM

I just upgraded the NAudio by using the latest NuGet package. Previously used NAudio source code ([](fixed M:B:T calculation in Audio File Inspector for MIDI )). Now it just crashes my application.

Crashes at _waveIn.StartRecording() -> OpenWaveInDevice() -> MmResult result = callbackInfo.WaveInOpen(out waveInHandle, DeviceNumber, WaveFormat, callback);
Using default device number 0 but that did not make any difference.

Any idea what is going on?
_waveIn = new WaveIn(_windowHandler);
// _waveIn.BufferMilliseconds = 50;
// _waveIn.DeviceNumber = capturingDeviceNumber;
// _waveIn.WaveFormat = _codec.RecordFormat;
_waveIn.DataAvailable += OnWaveInDataAvailable;
private void OnWaveInDataAvailable(object sender, WaveInEventArgs e)
        // Incomplete package - recording is stopping
        if (e.BytesRecorded < e.Buffer.Length)

        byte[] encoded = _codec.Encode(e.Buffer, 0, e.BytesRecorded);
        _udpSender.Send(encoded, encoded.Length);
    catch (SocketException socketException)
        // Ignore
    catch (Exception exception)
Apr 24, 2015 at 10:03 AM
what is the value of _windowHandler? Try calling the default WaveIn constructor, and also try using WaveInEvent instead.
Apr 24, 2015 at 10:22 AM
I tried the default constructor but same things happens:
_waveIn = new WaveIn();
I replace WaveIn with WaveInEvent and same result. It will not go pass the StartRecording method.
No error or exception, it will just stall there.
Apr 24, 2015 at 10:39 AM
I created minimum WPF application which is using latest NuGet package. Start and stopping the recording is working without problems (sadly :D).

This means that the other application is driving the NAudio into such state that it cannot handle the Wave In Start Recording anymore. Somehow the older library worked in that environment. I do not know how to debug it further...