sound.wav

index ยท sound

Overview

A WAV (RIFF/WAVE) decoder. Lua parses the header and hands the data chunk to the C sound.from_pcm. It reads integer PCM of 8, 16, 24 and 32 bits and IEEE float32, plain or in the WAVE_FORMAT_EXTENSIBLE wrapper.

Functions

NameSignature
decodedecode(data, opts) -> buf, info/err
loadload(path, opts) -> buf, info/err

decode(data, opts) -> buf, info/err

Decode WAV bytes into a sample buffer

Returns the buffer and { channels, rate, bits, frames }. opts.rate resamples the buffer to that rate; pass dev:rate() so the asset plays at its pitch. Returns nil and an error on failure.

load(path, opts) -> buf, info/err

Load and decode a WAV file from disk

Reads the file and returns what decode returns for its bytes.