An open source WAV decoder.
Download dr_wav.h
dr_wav is an open source library for decoding WAV 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.
  • Decode from any data source including files, a block of memory or from callbacks.
  • Seamless conversion of common internal data formats to either signed 32-bit PCM or IEEE 32-bit floating point. Supported internal formats include:
    • Unsigned 8-bit PCM
    • Signed 12-bit PCM
    • Signed 16-bit PCM
    • Signed 24-bit PCM
    • Signed 32-bit PCM
    • IEEE 32-bit floating point
    • IEEE 64-bit floating point.
    • A-law and u-law
  • Seamless support for Sony Wave64 (W64).
  • A consistent API with dr_flac.
Limitations and Future Plans
  • MS-ADPCM and IMA-ADPCM is not currently supported.
  • Support for common metadata blocks is not currently supported.
Examples
Example 1: Decoding from a file.
#define DR_WAV_IMPLEMENTATION
#include "dr_wav.h"

int main()
{
    drwav* pWav = drwav_open_file("my_sound.wav");
    if (pWav == NULL) {
        return -1;
    }

    int32_t* pSampleData = (int32_t*)malloc((size_t)pWav->totalSampleCount * sizeof(int32_t));
    drwav_read_s32(pWav, pWav->totalSampleCount, pSampleData);

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

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