NAudio 1.7 Release Notes
It’s been just over a year since the last release, so an updated release of NAudio is long overdue and there’s a lot of great new features added over the last year which I’m really excited to make official. In particular, this release adds Media Foundation support, allowing you to play from a much wider variety of audio file types, including extracting audio from video files. There’s also been significant progress on Windows 8 store app support although it still isn’t quite ready for official release.
As usual you can get it via NuGet. Last year NAudio 1.6 was downloaded 29616 times from Codeplex and 7089 times on NuGet.
What’s new in NAudio 1.7?
MediaFoundationReader
allows you to play any audio files that Media Foundation can play, which on Windows 7 and above means playback of AAC, MP3, WMA, as well as playing the audio from video files.MediaFoundationEncoder
allows you to easily encode audio using any Media Foundation Encoders installed on your machine. The WPF Demo application shows this in action, allowing you to encode AAC, MP3 and WMA files in Windows 8.MediaFoundationTransform
is a low-level class designed to be inherited from, allowing you to get direct access to Media Foundation Transforms if that’s what you need.MediaFoundationResampler
direct access to the Media Foundation Resampler MFT as anIWaveProvider
, with the capability to set the quality level.- NAudio is now built against .NET 3.5. This allows us to make use of language features such as extension methods, LINQ and Action/Func parameters.
- You can enumerate Media Foundation Transforms to see what’s installed. The WPF Demo Application shows how to do this.
WasapiCapture
supports exclusive mode, and a new WASAPI capture demo has been added to the WPF demo application, allowing you to experiment more easily to see what capture formats your soundcard will support.- A new
ToSampleProvider
extension method onIWaveProvider
now makes it trivially easy to to convert any PCMIWaveProvider
to anISampleProvider
. There is also another extension method allowing anISampleProvider
to be passed directly into anyIWavePlayer
implementation without the need for converting back to anIWaveProvider
first. WaveFileWriter
supports creating a 16 bit WAV file directly from anISampleProvider
with the newCreateWaveFile16
static method.IWavePosition
interface implemented by severalIWavePlayer
classes allows greater accuracy of determining exact position of playback. Contribution courtesy of ioctlLR- AIFF File Writer (courtesy of Gaiwa)
- Added the ability to add a local ACM driver allowing you to use ACM codecs without installing them. Use
AcmDriver.AddLocalDriver
ReadFully
property allows you to create never-endingMixingSampleProvider
, for use when dynamically adding and removing inputs.WasapiOut
now allows setting the playback volume directly on theMMDevice
.- Support for sending MIDI Sysex messages, thanks to Marcel Schot
- A new
BiQuadFilter
for easy creation of various filter types including high pass, low pass etc - A new
EnvelopeGenerator
class for creating ADSR envelopes based on a blog post from Nigel Redmon. - Lots of bugfixes (see the commit history for more details). Some highlights include…
- Fixed a long-standing issue with
MP3FileReader
incorrectly interpreting some metadata as an MP3 frame then throwing an exception saying the sample rate has changed. WaveFileReader.TryReadFloat
works in stereo files- Fixed possible memory exception with large buffer sizes for
WaveInBuffer
and WaveOutBuffer Various code cleanups including removal of use of ApplicationException, and removal of all classes marked as obsolete.
- Fixed a long-standing issue with
- Preview Release of WinRT support. The NAudio nuget package now includes a WinRT version of NAudio for Windows 8 store apps. This currently supports basic recording and playback. This should still very much be thought of as a preview release. There are still several parts of NAudio (in particular several of the file readers and writers) that are not accessible, and we may need to replace the MFT Resampler used by WASAPI with a fully managed one, as it might mean that Windows Store certification testing fails.
- Use
WasapiOutRT
for playback - Use
WasapiCaptureRT
for record (thanks to Kassoul for some performance enhancement suggestions) There is a demo application in the NAudio source code showing record and playback
- Use
NAudio Training
Another thing I’ve wanted to do for ages is to create some really good training materials for NAudio. I began this with the release of my Digital Audio Fundamentals course on Pluralsight, which is all about giving you the background understanding you need in order to work effectively with NAudio. And I’m on the verge of releasing the follow-on course which is around 6 hours of in-depth training on how to use NAudio. Keep an eye on my Pluralsight Author page and you should see it in a couple of weeks. I’ll also announce it here on my blog. You do need to be a Pluralsight subscriber to watch these videos, but it’s only $29 for a month’s subscription, which also gives you access to their entire library, making it a great deal.
What’s next?
I’ve still got lots of plans for NAudio. Here’s a few of the things near the top of my list for NAudio 1.8:
- Finish Windows Store support. In particular, this means ensuring it passes Windows App Certification
- I’d really like to add a fully managed resampler, which would help out in a lot of scenarios. I’ve got one ported from C already, but sadly it’s license (LGPL) isn’t compatible with NAudio’s.
- More Media Foundation features. In particular, supporting reading from and writing to streams.
- I’ll probably obsolete the DirectX Media Object components, as they serve little purpose now that we have MediaFoundation support
- More managed effects implemented as
ISampleProvider
- I have some ideas for making a fluent API for NAudio to make it much easier to construct complex signal chains in a single line.
Hope you find NAudio useful. Don’t forget to get in touch and tell me what you’ve built with it.