Decoding FLAC audio files in C#
Published July 26th, 2010 in ProgrammingFlacReader + WavWriter
As a follow-up to my previous article on FLAC and encoding uncompressed audio, I have further developed the Wav2Flac library and added FLAC decoding to the WAVE container. Some key points of this aspect of the WavFlacTest library are:
- Support for 16- and 24-bit audio streams
- Support for virtually all FLAC channel mappings: mono, stereo, 5.1, 7.1, etc.
- The resulting file is a bit-for-bit copy of the original audio stream
All source code and the compiled 32-bit FLAC library can be downloaded from here.
Known limitations
- Due to the wave format used being 32-bit, uncompressed files greater than 2GB in size might not play in full in some players.
- Even though FlacReader can receive metadata callbacks, the data is not interpreted. This can be further developed using the FLAC API documentation.
3 Responses to “Decoding FLAC audio files in C#”
Leave a Reply
Search
About |

Stanimir Stoyanov is a programmer, Microsoft MVP, and Windows enthusiast. Read More...
He's currently working on an array of projects using Visual Studio 2010 on Windows 7.
Latest
- Blocking unwanted advertisements and malware with a HOSTS file
- Multithreading with Windows Forms in C#
- Честита Коледа (и поздравления на спечелилите)!
- A simple backup solution using ImageX, a Windows Imaging tool
- Soon: MSDN Ultimate Subscriptions Giveaway
- Decoding FLAC audio files in C#
- Inline Tweet Translator
- Resizing forms while keeping aspect ratio
- Encoding uncompressed audio with FLAC in C#
- Indicating progress in console windows

OK The Wav 2 Flac encoder (even if you have to declare the calling convention in DllImport under VS2010 in order to avoid the “StackImbalance” exception)
The Wav 2 Flac doesn’t work (I use VS2010) - I always get the error in the console “Cannot Open File Stream”
I don’t know how to fix it!
Please help!
Stefano (IT)
I also get the error in the console application CANNOT PROCESS UNTIL EOF
Thank you for posting your code here.
It is extremely useful to see this, and I’m using the code for a personal project.
I might humbly suggest perhaps implementing an event system for reporting status and progress within those callbacks, so that the classes can be separated from the console class, as the code can be used in non-console applications (perhaps a Windows Forms app, which is what I’m developing).
I may try and make such changes myself, and converting the code to VB.NET for myself.
Really nice work wrapping the FLAC and WAV APIs.