Opens a file and copies Vorbis ARTIST/ALBUM/TITLE comments. Returns false on unsupported or malformed headers, including Vorbis on WebAssembly, which has no native decoder. PCM 8/16/24/32-bit and IMA ADPCM, one or two channels, are accepted on every target.
#import "Extensions/Audio_Stream";
Bounded, seekable decoding of WAV PCM/IMA ADPCM and Ogg Vorbis files. A reader owns its file and scratch block; it never loads the whole recording.
Procedures#
(r: *Reader)
Releases file handles, comments and block buffers. Safe after a failed open or repeated close.
Moves to an exact source frame; out-of-range requests clamp to the recording's ends.
Reads interleaved signed 16-bit samples into caller storage. Returns frames decoded, zero at EOF, or -1 on a file/codec failure. Storage must fit a whole number of frames.
Types#
An open decoder. Keep it on one thread, close it before reuse, and do not copy it.
position and frames count frames, not individual interleaved channel samples.
Reader :: struct {
file: File;
opened: bool;
vorbis: *V.stb_vorbis;
channels: s32;
rate: s32;
frames: s64;
position: s64;
artist: string;
album: string;
title: string;
format: W.Waveformatex;
extra: W.Wave_Extra_Info;
offset: s64;
block: [] u8;
decoded: [] s16;
cached_block: s64 = -1;
}