rockbox/decoder

Decode an audio file to interleaved-stereo S16LE PCM, one chunk at a time.

Wraps the Rockbox codec engine. The codec state is process-wide, so only one Decoder may decode at a time — opening a second one blocks until the first is freed. It is a NIF resource, freed by the BEAM garbage collector — no explicit close.

Types

Opaque decoder handle (a NIF resource).

pub type Decoder

Values

pub fn elapsed_ms(decoder: Decoder) -> Int

Playback position last reported by the codec, in milliseconds.

pub fn finished(decoder: Decoder) -> #(Bool, Int)

#(done, code): done is True once the track has ended; code is the exit status (0 = clean end, negative = codec error), valid only when done.

pub fn metadata(decoder: Decoder) -> metadata.Metadata

Tags and stream properties (same shape as metadata.read).

pub fn next_chunk(
  decoder: Decoder,
) -> option.Option(#(BitArray, Int))

Next buffer of decoded PCM as #(samples, sample_rate), where samples is a little-endian int16 buffer of interleaved stereo PCM. None at end of track (or after a codec error — see finished).

pub fn open(path: String) -> Decoder

Open a decoder for the local audio file at path.

pub fn seek_ms(decoder: Decoder, ms: Int) -> Nil

Request a seek to ms milliseconds.

Search Document