Posted in:

I'm really pleased to announce the release of NAudio version 3, which includes a complete modernization of the entire library, many bug-fixes and performance improvements, and adds several key new features including cross-platform support on Linux and the ability to host VST 3 effects.

There's too many changes to discuss them all in detail in this post, but I did want to highlight a few of the most important changes.

First of all, almost all of the interop of the COM Interop has been rewritten, making use of the newer GeneratedComInterface attribute which supports NativeAOT and uses source generation. Likewise, interop that used the legacy DllImport approach is rewritten to use LibraryImport. This improves performance and provides better support for trimming.

Second, there has been a significant redesign to the core interfaces such as IWaveProvider and ISampleProvider to use Span<T> for passing round audio buffers. This allows for higher performing code and eliminates the need for unnecessary copying of audio buffers. This will only affect you if you've created your own custom implementations of these interfaces, and even then it's a relatively easy change to make (and arguably simpler to work with).

Third, I embarked on a review of every single open issue and pull request. There were hundreds of these and this took a huge amount of time, even with AI assistance. This resulted in a lot of bug fixes and improvements to the library. Virtually all the reported issues are now resolved. Many thanks to everyone who reported a bug, created a PR, or suggested a new feature. I regret that many of these contributions went unacknowledged for a long time - I was simply unable to keep up with the volume of them, but I am glad to have finally got round to reviewing them all.

Fourth, the library has gained several very powerful new capabilities - including a whole suite of fully managed effects, and the ability to host VST3 effects. There's even a fully managed sampler and sequencer, and improved SoundFont 2 support, meaning you can render a multi-timbral MIDI file through a GM SoundFont.

Fifth, there are new and improved classes for working with WASAPI and ASIO, the two most important and modern audio playback and recording APIs for Windows. Going forwards, you should use WasapiPlayer, WasapiRecorder, or AsioDevice for all your audio recording and playback needs. These expose even more capabilities than were previously supported including WASAPI low latency mode, and individual process audio capture.

Sixth, NAudio is no longer Windows-only. I've moved all the Windows-only features into their own assemblies, leaving NAudio.Core and NAudio.Midi as fully cross-platform. And a new NAudio.Alsa library supports playback and recording on Linux, and is augmented by NAudio.SoundFile which opens the door to reading and writing many common audio file formats on Linux (and other platforms). I'm hopeful that MacOS support is going to follow in the near future thanks to an in-progress community contribution.

This is of course a big change to the library, and so there is an NAudio 2 to NAudio 3migration guide available which I'd encourage you to use (especially useful if you want to point an AI coding harness at it to evaluate your existing NAudio 2 codebase for upgrades).

This rework took me several months and hundreds of hours, but even then it was only possible due to the acceleration that Claude Code was able to provide. Six months of access was generously provided by Anthropic as part of their Claude for Open Source initiative so many thanks to them.

Of course, I know that AI-assisted coding can be a controversial topic with concerns that it produces vibe-coded "slop". I've endeavoured to ensure that the quality bar remains as high as possible. One advantage with a library like NAudio is that, as much of the code consists of interop wrappers, it's usually apparent very quickly whether it works or not. But there certainly were a few nasty bugs and access violations that took a long time to track down, even with AI assistance. So I've allowed a period of stabilization and published lots of preview releases to allow the community to give as much feedback as possible, and I think now is a good time to release where we're up to.

There are still a few ideas on my NAudio wishlist that didn't make the cut this time (especially around improving the situation for repositionable sample providers), but I think there is enough disruption for this major release. In fact, in many ways NAudio is now quite close to being "complete" - I don't necessarily want to try to add every conceivable audio-related capability to the library, but instead provide a powerful and extensible toolkit that supports audio development on .NET and provides many of the most essential capabilities in an easy to consume manner. I hope you'll agree that NAudio 3 achieves this goal, but of course I welcome feedback, so do raise issues on GitHub if you encounter any issues.

Want to get up to speed with the the fundamentals principles of digital audio and how to got about writing audio applications with NAudio? Be sure to check out my Pluralsight courses, Digital Audio Fundamentals, and Audio Programming with NAudio.