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

Windows 8 WinRT Metro Style Support

May 6, 2012 at 6:30 PM

Thanks for this great library!

Is support for Windows 8 WinRT Metro Style apps planned by leveraging the MediaCapture API?

May 7, 2012 at 10:15 PM

I'd love to do this for a future version of NAudio. Not top of the priority list at the moment though.


Aug 24, 2012 at 6:13 AM


Would you accept patches that would add support for WinRT and/or other platforms?

  - Tom


Aug 27, 2012 at 9:58 PM

hi Tom,

I do accept patches but please read these notes about submitting patches. NAudio currently builds against .NET 2.0, and maintaining backwards compatibility is important. There would only be a certain subset of NAudio that would apply with WinRT in any case, so I could imagine a separate project just bringing in fewer files might be possible. I have got VS2012 installed on my dev PC myself now, so I may get the chance at some point to experiment with how WinRT and NAudio can be combined.


Aug 29, 2012 at 9:11 AM

Hi Tom, 

Have you done your patch yet ? I'm also considering doing mine. I want to convert a subset of NAudio (CoreAudio) in order to use it in a store application. Right now I'm stuck with custom marshaling (ICustomMarshaler doesn't exist). Is your patch available ? Have you the same problem ? 



Oct 8, 2012 at 5:24 PM

Hi Mark,

Do you have any plan to release a WinRT version of NAudio? I am currently using NAudio 1.5 in my WinRT Javascript application to convert MP3 to WAV using Naudio. It works like a charm but unfortunately the application does not pass the appcert tool certification... The tool says that naudio.dll uses some APIs that are forbidden.

I am aware it is not on your priority list but I just check.

The other idea I have is to remove from naudio source all the methods and libraries not necessary in the methods I use. Here is what I do:

public static void ConvertMp3toPcm(string sourceFilename, string outputFileName, string pcmFilename)
            if (string.IsNullOrEmpty(sourceFilename))
                throw new ArgumentNullException("sourceFilename");

            if (string.IsNullOrEmpty(outputFileName))
                throw new ArgumentNullException("outputFileName");

            if (string.IsNullOrEmpty(pcmFilename))
                throw new ArgumentNullException("pcmFilename");

                using (Mp3FileReader reader = new Mp3FileReader(sourceFilename))
                    using (WaveStream waveStream = WaveFormatConversionStream.CreatePcmStream(reader))
                        WaveFileWriter.CreateWaveFile(outputFileName, waveStream);

                //Re-encode the stream with a mono channel, 16bits and 16kHz
                using (WaveStream readWaveStream = new WaveFileReader(outputFileName))
                    WaveFormat target = new WaveFormat(16000, 16, 1);

                    WaveFormatConversionStream monoStream = new WaveFormatConversionStream(target, readWaveStream);
                    WaveFileWriter.CreateWaveFile(pcmFilename, monoStream);


I don't know if the licensing of Naudio would allow me to do this. I have to check.

Thanks a lot,


Oct 8, 2012 at 5:30 PM

I'd love to make a WinRT version of NAudio, but as you have discovered, NAudio contains wrappers for lots of APIs that are disallowed in WinRT (I assume this will include all waveIn, waveOut, and acm functions). I'm hoping to experiment with Windows 8 and see what is possible in the near future. There are some new Audio APIs that are part of WinRT, which I presume Windows Store applications are supposed to use exclusively.

Oct 8, 2012 at 5:51 PM

Sure I understand. Thanks anyway.


Dec 1, 2012 at 11:23 PM

How is WinRT support efforts going? I downloaded the project and it looks like there's been some progress. Would it be worthwhile for me to fork and do some work?

Dec 2, 2012 at 7:41 AM

Hi tcl,

Did you see my recent blog post on adding Windows Store support to NAudio? I'm actively working on it at the moment, but there is some way to go. Here's the key tasks that need to be completed.

1. Media Foundation. This is because ACM and DMO which NAudio already supported are both not allowed in Windows Store apps. The main three things we need are a MediaFoundationReader (which is mostly complete, just needs some tweaks), a MediaFoundationEncoder (which I have prototyped the internals of, just need to give it a nice public API), and a MediaFoundationResampler, which another forum user Manu is kindly helping out with, so hopefully there will be enough Media Foundation interop in the very near future.

2. WASAPI. Even though I have already done all the hard work on WASAPI interop, it will need to be modified to work with Windows Store apps. Currently I've not decided whether to make completely separate WasapiOut and WasapiIn classes for the Win8. I don't know whether loopback capture is possible. There is a great article on CodeProject showing how it can be done (in VB), so I'm hoping that when I get onto this in the very near future, it should be done quite quickly.

3. Streams NAudio depends heavily on the Stream base class, but the WinRT API now seems to prefer IInputStream, IOutputStream and IRandomAccessStream. There are a lot of classes (e.g. the WaveFileReader, WaveFileWriter, MP3FileReader, AiffFileReader, AiffFileWriter) that will at least need new constructors. I don't really want to have to maintain two completely separate versions of all these classes, so one interesting task will be to see what the simplest change that allows them to be used with the regular Windows Store file APIs is.

4. Demo Project I'm also going to create a Windows Store demo app. It will follow a similar structure to the WPF and WinForms ones, allowing me to very quickly add in new demos. Before we announce WinRT support we need two main demos. One reads files using MediaFoundationPlayer and plays them through WASAPI, and the other records from the microphone and encodes to WMA/MP3 using the MediaFoundationEncoder. I'll probably throw in some visualisation like waveform drawing as well. Once I've got the basic demo store app's structure in place, it should be easy for people to contribute other WinRT demos to it.

If you want to contribute, the best way at the moment is probably to prototype a proof of concept for one of these tasks, since the overall project is still very fluid and so I may not be able to merge in large contributions. Let me know if there is anything above that takes your interest.

Dec 3, 2012 at 7:22 AM


Thanks for the thoughtful reply. I hadn't seen your blog post before. I'll dig into the WinRT project over the next couple of weeks and see if/where I can help.


Feb 20, 2013 at 2:46 PM
Edited Feb 20, 2013 at 2:47 PM
Any news on the WinRT front?

In partucular I'm looking for a way to draw an audio graph from the MediaCapture microphone stream in C#.
Similar to yours here
Feb 21, 2013 at 11:45 AM
hi, the WinRT support is coming along reasonably well, although I haven't had a chance to work on it in the last few weeks. If you get the latest code out, you can see what has been done so far. The WPF drawing code might be able to translate across, as WinRT has a very similar XAML-based graphics system.

Sep 12, 2013 at 10:55 AM
Edited Sep 12, 2013 at 11:01 AM
Thank you for your great work.
I am eagerly waiting for the WinRT version of NAudio, as I am trying to create an equalizer for a Windows 8 Style app I am creating.
I see that quite a few months have passed since your last post here, wanted to see how everything is coming along.
Hope you guys have been successful in porting this great product over to WinRT :)

I also wanted to know if it is possible to use NAudio for eliminating a certain range of frequencies from the input stream (basically what an equalizer is supposed to do). I am new to this, so a little bit of guidance - maybe some links to more information - would really be appreciated.

Thank you again.
Sep 12, 2013 at 11:29 AM
hi, you can trial the WinRT support using the Nuget package available here (need to select prerelease version)

It can't do very much at the moment, but might be enough depending on your needs.
Oct 23, 2013 at 5:18 AM
Mark - first off, your work is great. I can't believe how much you're able to produce in your "spare time".
I'm trying to get my head around your WasapiOutRT class and use it similarly to WaveOut in your AudibleDragging example from your traditional 1.3.8 version. Not having much luck, no sound. I'm trying to make Win8.1 metronome with configurable tones, no audio files.
Oct 24, 2013 at 10:58 PM
does the Windows 8 demo app in the NAudio source code work for you?
Oct 24, 2013 at 11:20 PM
I was able to load an audio file (mp3) in your demo app and the play button became enabled. However, once clicked, the play button sent no sound out.
Oct 25, 2013 at 1:27 AM
I'm sorry, I know this isn't the right place but, since this topic is alive, i wanna know about the support to FLAC files...
There's a topic about this but, actually, it's an old dead topic, unfortunatelly. Did anyone have success in playing FLAC songs?
Will NAudio support it natively someday?
Oct 25, 2013 at 7:17 AM
@adamrozek: hmmm, what device are you using, is it a MS Surface, or a regular Windows 8 machine?

@N_Neto: please start new threads for things like this. short answer is that there is an example of playing FLAC with NAudio in Yuval Naveh's Practice# open source app
Oct 25, 2013 at 3:13 PM
I'm using Windows 8.1 on a desktop
Oct 25, 2013 at 3:15 PM
you might need to debug the WasapiOutRT class, see if the playback thread is doing anything, or whether it is playing, just silently
Oct 26, 2013 at 4:48 AM
Got it! I wasn't implementing my Play method as an async with the await on the WasapiOutRT Init call.
Oct 28, 2013 at 12:06 PM
Yes init had to become async, as the user can get asked to grant permission during the call.
Oct 28, 2013 at 4:01 PM
Now my problem is getting the timing in sync with my metronome timespan. I tried an async delay but that's giving inaccurate timing. Going to try feeding the Wasapi object to a MediaStreamSource and use a MediaTimeline.
Oct 28, 2013 at 4:07 PM
for a metronome, I wouldn't recommend using timers at all. Just have an ISampleProvider that emits the sound after the correct number of samples. That gives you the best accuracy. See the drum machine sample in the WPF demo for an example.
Oct 28, 2013 at 4:24 PM
Edited Oct 28, 2013 at 4:28 PM
Thanks for the tip! I have a sprite I'm blinking on the beat using an animation Timeline, adjusting the ending keyframe at runtime, and that's been spot on. So I thought that path might work with the audio also. It's not a Timer per se (I did start down that path and found that messed with my threads & overall timing even more), but I do derive a TimeSpan object from the BeatsPerMinute translation.
Oct 29, 2013 at 4:47 AM
Good gravy... I'm quickly learning I have no idea what I'm doing with audio. I'm off to your Pluralsight course
Oct 29, 2013 at 12:42 PM
cool, the followup course (on NAudio) is really close to being released, but the digital audio fundamentals one will definitely be useful for you to watch first.
Jan 7, 2014 at 4:15 AM
Edited Jan 7, 2014 at 4:17 AM
Here's a quick "Getting Started" blog post using the 1.7.0 beta release in a WinRT app:
Jan 9, 2014 at 11:56 AM
great, thanks for writing this up BeerRoot.