Minimal WAV (RIFF/WAVE) decoder -> float32 sample buffer.
Parses the header in pure Lua and hands the raw PCM data chunk to the C
sound.from_pcm decoder (fast, format-aware). Supports uncompressed integer
PCM (8/16/24/32-bit) and IEEE float32, including the WAVE_FORMAT_EXTENSIBLE
wrapper. Optionally resamples to a target rate so an asset recorded at 44.1 kHz
plays correctly on a 48 kHz device.
| Name | Signature |
|---|---|
| decode | decode(data, opts) -> buf, info/err |
| load | load(path, opts) -> buf, info/err |
decode(
data,opts) ->buf,info/err
Decode WAV bytes into a sample buffer
Returns the float32 buffer and an info table { channels, rate, bits, frames }. opts.rate resamples the result to that sample rate (pass
dev:rate() so assets play at the right pitch). Returns nil and an error
string on failure.
load(
path,opts) ->buf,info/err
Load and decode a WAV file from disk
Reads the file at path and decodes it with decode (same opts and
returns). Returns nil and an error string on failure.