wav.h
WAV files.
#include <sonore/wav.h>- 1type
- 3other declarations
On this page
Design notes
A reader and a writer for the one format that matters in practice: RIFF/WAVE carrying 16-bit PCM, 24-bit PCM or 32-bit float. That covers what users actually drop on a plugin (impulse responses, samples) and what a standalone build renders out. Compressed formats are somebody else's job: the OS ships codecs, and a plugin that decodes MP3 itself is carrying liability, not value.
Offline-only by design: these functions allocate and do file IO, so they belong in prepare()-time code and tools, never in process().
Types 1
Decoded audio: interleaved floats, -1..1, plus the facts about them.
Functions 2
- fn
inline bool readWav(const char* path, WavData* out, size_t maxSamples = kMaxDecodedSamples)Read a WAV file. Returns false (leavingwav.h:75outempty) on anything it does not understand, rather than guessing at bytes: a wrong guess here becomes a blast of full-scale noise through a user's monitors. - fn
inline bool writeWav(const char* path, const float* interleaved, size_t numFrames, uint16_t numChannels, uint32_t sampleRate)Write interleaved floats as a 32-bit float WAV. Float, not 16-bit PCM, because the standalone's renders are for INSPECTION: quantising the thing you are trying to measure defeats the purpose.wav.h:206
Constants 1
- const
static constexpr size_t kMaxDecodedSamples = 256u * 1024u * 1024uThe most audio any decoder in this SDK will materialise from one file.wav.h:47