This project has moved. For the latest updates, please go here.

How about adding *.flac support?

Nov 21, 2014 at 11:55 AM
Hello Mark and NAudio developers,

you have created an adorable lib so far and I wonder, why you haven´t integrated a FlacReader yet. There are already some approaches that really work with it in pure C#, it would be really great if you could integrate one of them into NAudio:

I can also offer you my help with porting an testing. Please let me know what you think.

Kind regards

Nov 25, 2014 at 11:26 AM
Not interested at all? Or no time? Please give some statement...
Nov 25, 2014 at 1:26 PM

If you want one of these (pick Flacbox) integrated with NAudio, at the least you'll need to pull down a copy of the NAudio code, integrate the flac library, then submit a pull request. I can't guarantee it'll get accepted, but at least the code will be out there for others to see.

Nov 25, 2014 at 1:52 PM
hi Freefall,

Sorry for not getting back to you earlier. FLAC support would be great but is not something I've personally needed which is the main reason why it's not in there yet. I'd gladly accept a pull request for it, so long as you are sure that the original creators of the FLAC code were happy with it being used within NAudio. If you plan to do this, please discuss first so that we can make sure it is implemented in a way that fits with the design and philosophy of NAudio.

An alternative is to create a small add-on library e.g. (NAudio.Flac.dll) that references NAudio and FlacBox (or similar) that people wanting to work with FLAC can add to their projects. NAudio already has some similar add-on libraries for WMA and Lame which avoid the core getting too bloated.

Nov 25, 2014 at 2:06 PM
Hello Mark,

> I'd gladly accept a pull request for it, so long as you are sure that the original creators of the FLAC code were happy with it being used within NAudio. If you plan to do this, please discuss first so that we can make sure it is implemented in a way that fits with the design and philosophy of NAudio.

Ok, so the Flac decoding project in question must also implement MS-PL license? About implementing a solution I´ll tell you later when I´m back at home.
I need to do some researches first. If I implement one, I´d create a streamreader-like flac decoder as you did in the past, so that it should fit into NAudio style.

Kind regards

Nov 25, 2014 at 2:12 PM
yes, needs to be MS-PL compatible license. Usually that is fine, but it means GPL or LGPL source cannot be reused.

Nov 25, 2014 at 2:52 PM
What about Flacbox MIT License? And do you want the flac Decoder integrated or as external addon? And requirements about the Decoding speed?

Nov 25, 2014 at 4:26 PM
MIT should be compatible, but I'd reach out to the owner of that project first to be sure.
I've contemplated updating NAudio to be MIT at some point, since it seems to be a more established standard for a commercial friendly open source license.

No specific decoding speed requirements, although NAudio users will expect to be able to play FLAC files in realtime.
Nov 25, 2014 at 5:45 PM
Edited Nov 26, 2014 at 7:27 AM
OK, so I finished my flac implementation. I´ve taken the source from:, which also provides an MS-PL license.
Of course all credits go to them.

Working VB .NET sample Code:
Imports System.IO
Imports NAudio.Wave
Imports NAudio.Flac
Imports NAudio

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim Flac As WaveStream = New FlacReader(New MemoryStream(My.Resources.Testsound))
        Dim WO As New NAudio.Wave.WaveOut()
        WO.Volume = 0.2
    End Sub
End Class
Library available at Of course I will answer any questions as far as I can.

Kind regards

Marked as answer by Freefall on 11/25/2014 at 11:39 AM
Nov 25, 2014 at 6:27 PM
Please use C#. No professional .net programmer takes VB seriously..
Nov 26, 2014 at 7:21 AM
Please use C#. No professional .net programmer takes VB seriously..

If you read my post carefully you can see that it was only the sample written in VB. Library still is C# code.
Nov 26, 2014 at 7:33 AM
I know, but if most of the .net people should take the sample seriously, VB is not the way. Just saying!
Nov 26, 2014 at 7:53 AM
Ok, I can also provide C# sample code if you prefer that. I also did a pull request. Will you integrate it Mark?
Nov 26, 2014 at 8:34 AM
hi Freefall,

Are you able to find out who actually created this C# port of the FLAC decoder originally? I doubt it was done by the creators of cscore, who have incorporated large amounts of code from many other libraries (including NAudio). Sorry to be a pain, but it is important to me that permission is granted for all the code contained within NAudio.

Nov 26, 2014 at 9:13 AM
Edited Nov 27, 2014 at 6:20 AM
Hello Mark,

I couldn´t find any references by the cscore author thefiloe. He might have ported that from a java project ( on his own or from any other source. I couldn´t find it out.
On his vb paradise thread he needed to fix some parts of the flac decoder from time to time, which would indicate that this was at least partly his own implementation. In "FlacMetadataStreamInfo.cs " there is also a reference to this link:

I will ask him for permission and where he got his information sources. I also thought of NAudio when I looked at the source code there, seems he used NAudio as a base for his own audio library. He should at least mention that at his official codeplex page for the sake of politeness, even if NAudio is MS-PL.

Nov 27, 2014 at 6:18 AM
Edited Nov 27, 2014 at 9:40 AM
Hello Mark,

finally, I talked with thefiloe from cscore and he made it clear, that he already has been giving credits to NAudio here: I´m sorry for my misapprehension.

He also told me, that we can use his flac decoder source for NAudio, even as he is not that happy with it. Of course all credits go to him for that, as he stated to be the original creator of the flac decoder library. I don´t understand why you compete against each other, merging both libraries with similar architecture would create a great .NET Audio lib with features that could even hold a candle to professional audio libraries e.g. Bass by un4seen, please just think about it.

Anyway, I´ve already created a NAudio flac plugin and he gave us the permission to publish it for use in NAudio. Please tell me, Mark, what the next steps now are.

Nov 28, 2014 at 1:49 PM

Next steps: Cancel your (blank) pull request, code up the integration, submit the changes, then re-submit the pull request. Once that is done, Mark will tell you the next steps (maybe none if your implementation is solid and fits with NAudio's overall design). That said, you'll need to track CsCore's changes for us so our implementation is as good as theirs. A (very) quick review of the code tells me it's a "new, from scratch" implementation, so there will be bugs to address.

I'll let Mark address the idea of merging projects, but the short version is that it ain't gonna happen and either project will do the majority of what people need. :)
Nov 28, 2014 at 2:24 PM
What do you mean by
blank pull request
I´ve written there where I´ve stored the plugin and project files, so I don´t get your point.
code up the integration
Already did, in form of a plugin. As you can see at my example above and on google code.
submit the changes
Sorry, I´m new to forks and this pull request stuff and so on, how can I submit a full project source as change?
Maybe none if your implementation is solid and fits with NAudio's overall design
Yes, it seems that the architecture is very similar and should therefore fit into NAudio design. That´s why I could
implement it in 2 hours. I also share Mark´s opinion, to integrate it as an plugin to don´t bloat NAudio´s source up.
you'll need to track CsCore's changes for us so our implementation is as good as theirs
I agree, since I´ve already encountered a bug. I´ll do my best to fix them and ensure it´s up to date as far as I can.
but the short version is that it ain't gonna happen and either project will do the majority of what people need
Well, I don´t want to argue with you, but I have a different opinion on that. You could reach so much if you let all misunderstandings behind.

Kind regards

Nov 28, 2014 at 2:36 PM
hey Freefall.

Thanks for contacting thefiloe. I had many conversations with him a few years back, and was hopeful that he could contribute some of his ideas to NAudio, but he has decided to do his own thing. I certainly would be up for collaboration in the future if that is possible. He has put some good ideas into cscore, and has the advantage of having a fresh start with the API rather than having to maintain backwards compatilbility. One idea I've had in mind for a while is possibly giving NAudio a bit of a fresh start for version 2.0, making more breaking changes, and maybe moving to GitHub at the same time.

And if he is the original creator and has given his permission, that is great, and there should be no problem incorporating it into NAudio. Because NAudio is used in a lot of large commercial applications, it is important that there are no question marks over the origin of the code it contains.

You should be able to add extra commits to your existing pull request. I do code review all pull requests to NAudio, and hopefully over the next week or so I'll get round to this. NAudio is just a spare time hobby project for me, and the amount of emails I get about it has got to the point that I can't keep up any more. I have 90 still waiting for a response at the moment. But I do try to prioritise things like this, and I'll be looking at your pull request over the next few weeks.

One thing I do ask contributors if possible is to also write some documentation about how to use the classes they add to NAudio. You may have already done this, but if not, please consider doing this.

Dec 22, 2014 at 12:05 PM
Flac Decoder news:

PS: Thefiloe in the end changed his mind, he said that his flac decoder may not be used in NAudio for an unknown reason. I can´t follow this small minded behaviour. I´m sorry for him and I´m a bit angry. He has been already given the permission and the plugin is finished now. So I let it published on google code, for those who need it anyway.

It´s damn legit anyway, as CSCore is MS-PL. Credited him of course for his work though.

Dec 22, 2014 at 7:25 PM
@Freefall: Thank you for trying and for publishing your work. I really had hoped Thefiloe would prove to be more open than that. Very disappointing.

I'll eventually write a FLAC decoder, so worst case we can add it to NAudio then. That'll probably be late next year at the earliest, though...

Truthfully, I think at some point I'm going to build a "common" framework for several audio stream containers & formats... Basically a .Net-native version of all the container formats (Ogg, ADTS [i.e., MPEG1/2 or MPEG4], ADIF [MPEG4], Matroska [i.e., MKA/MKV/WebM]), tag formats (ID3, Vorbis, etc.), and stream decoders (Vorbis, MP1/2/3, AAC, FLAC, OPUS, etc.). I have working code for at least 30% of it in published libraries, so it's not like I'll be starting from scratch...

Thoughts (especially Mark)?
Dec 22, 2014 at 7:44 PM
sounds awesome ioctlLR! Will be a great resource for the .NET community.
Dec 23, 2014 at 8:19 AM
Edited Dec 23, 2014 at 8:20 AM
@ ioctlLR: Sounds fantastic!! As Microsoft seems to see no need to apply a essential audio Framework for .NET this is a great approach.
I´d write my own decoder, but I don´t have the time to do so as I´m actually going for my final thesis on business engineering. I´d definately like to join the team and help where I can. In the end this library could grow to a lengendary audio library that can compete with bass or fmod. And for sure really many people would use it; including me, as I love to do audio related stuff in my spare free time.

Dec 23, 2014 at 9:05 AM
Windows 10+ will get native FLAC support.
Dec 28, 2014 at 2:17 PM
that's good to know,. it means we'll be able to add FLAC support for MediaFoundationReader and possibly for MediaFoundationEncoder too on Win 10 systems