Algorithms – How to Decode FLAC to PCM

algorithmsccompression

I'm trying to program a very basic FLAC player using 100% C# completely from scratch. My understanding of this type of thing is very limited, so I'm using this project as a way to learn about compression and decompression. I'm a computer science and math major currently in university, so I'm not adverse to learning whatever math may be involved.

I've looked up the format specifications on xiph.org and I understand how the headers and all are structured, but I can't seem to find a concise explanation of how the audio compression works. How do I go about converting the frames to pcm?

Sadly, my knowledge of C/C++ is extremely limited, as I only have experience with Java and C#. As such, trying to navigate the c++ code already out there is not a great starting point. I looked at FlacBox and learned quite a bit from it, but it's barely commented at all and I am lost trying to figure out how the conversion from flac to pcm works.

So what should I read as far as math goes so I can get started with this? Where can I find a basic algorithm for converting the audio frames to wav? Thanks.

Best Answer

You need to look a little closer at the format page on the FLAC website. The "prediction" paragraph leads to this article, which describes the AudioPak algorithm in detail, and also Shorten.

You should learn and understand these algorithms and the associated math before digging into the source code. That might take awhile.