0 Comments Posted in:

Just a quick update about my plans for a v2 of NAudio. NAudio 2 will have a few small bugfixes, but should mostly be a highly backwards compatible update. Most of the changes will be to do with project organization.

Multiple Assemblies

The biggest change is that NAudio is now a collection of smaller libraries. This is because a lot of NAudio contains platform specific interop wrappers that are not applicable to all users.

  • NAudio.Core is a .NET Standard package which includes all of the cross-platform parts of NAudio. All of the interfaces, lots of helpers plus things like WaveFileReader and WaveFileWriter are in here
  • NAudio.MIDI contains the MIDI events, which can be used cross platform, and also the WinMM MIDI interop which is Windows specific.
  • NAudio.WinMM contains all of the Windows audio API support for the long-standing WinMM APIs. Most notably the WaveInEvent and WaveOutEvent classes which are still often the best choice for audio recording and playback on Windows, plus other old Windows API support such as ACM (codecs) and the mixer.
  • NAudio.WASAPI contains all the interop for the newer Windows audio APIs including WASAPI, DMO (DirectX Media Objects) and MediaFoundation
  • NAudio.WinForms contains anything with a WinForms dependency. This includes the original WaveIn and WaveOut classes which use Windows messages for callbacks. Note that it is totally fine to use these in a WPF application. However, this package is probably not needed in most cases
  • NAudio.Asio contains the interop for ASIO
  • NAudio.Uap contains all the support for the UAP platform, with a new minimum version of 17763 (Windows 10 version 1809). To be honest, most of this is still experimental and I'm tempted to drop it. It was really just a proof of concept I made a few years back and is a pain to maintain.
  • NAudio this still exists as a top-level package that references all of the sub-packages, hopefully making it easy for people who don't want to know or care about what is where. There are a couple of classes that had to go at this layer, which are AudioFileReader since that combines readers from several different sub-assemblies, and Mp3FileReader which by default uses ACM. However a new Mp3FileReaderBase can be used if you want to provide a different MP3 frame decoder (e.g. NLayer)
  • NAudio.Extras - contains some useful helper classes from the demo applications. This is also a potential good place for contributors to add some of their own helper classes that aren't a good fit for the core libraries.

I've kept everything in a monorepo, as this makes life a lot easier testing the code. I might even bring in a few more satellite libraries such as NAudio.SharpMediaFoundation.

Dropped .NET 3.5 support

Note that I've finally dropped .NET 3.5 support. The lowest version NAudio 2 will support is .NET 4.7.2. However you can of course still use NAudio 1 with .NET 3.5 if you are still stuck on a legacy version of the .NET Framework.

Strong Naming

I have also taken this opportunity to strong name the assemblies. This was always a source of controversy, as some people wanted it strong named, and others didn't, and I wasn't sure of the implications of suddenly switching. However, the official guidance from Microsoft has changed over the years, with the recommendation now being that you do strong-name your libraries, and so releasing a new major version seems a good time to introduce it.

Switching to the MIT License

I have also chosen to move away from the MS-PL to the more standard and well-known MIT license. They are both permissive and commercial friendly licenses, so I don't anticipate any problems here.

Azure Pipeline

I also did some work on improving the Azure Pipeline build so it can run the unit tests. The previous build set up was rather unreliable, and this should make it easier to evaluate pull requests.

Feedback

I'd love for you to try out the beta builds of NAudio 2, and let me know if they unexpectedly break anything in your applications. And please give me any feedback on these changes to NAudio. I want to do a bit more testing myself before pushing these changes live, but hopefully it won't be too long.

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.
Vote on HN