An open source FLAC decoder.
Download dr_flac.h
dr_flac is an open source library for decoding FLAC files. It's written in C in a single file with no dependencies except for the C standard library, and is released into the public domain.
Features
  • Public domain.
  • Single file.
  • No dependencies except for the C standard library.
  • Sample exact reading and seeking.
  • Seamless Ogg encapsulation with support for multiplexed streams.
  • Supports metadata.
  • Decode from any data source including files, a block of memory or from callbacks.
  • A consistent API with dr_wav.
Examples
Example 1: Decoding from a file.
#define DR_FLAC_IMPLEMENTATION
#include "dr_flac.h"

int main()
{
    drflac* pFlac = drflac_open_file("my_song.flac");
    if (pFlac == NULL) {
        return -1;
    }

    int32_t* pSampleData = (int32_t*)malloc((size_t)pFlac->totalSampleCount * sizeof(int32_t));
    drflac_read_s32(pFlac, pFlac->totalSampleCount, pSampleData);

    // At this point pSampleData contains every decoded sample as signed 32-bit PCM.

    drflac_close(pFlac);
    return 0;
}
Developed by David Reid - mackron@gmail.com