Import with #import "std/vorbis".

VorbisAudio :: struct { channels: s32; rate: s32; frames: s64; nominal_bitrate: s32; maximum_bitrate: s32; minimum_bitrate: s32; short_block: s32; long_block: s32; modes: s32; packets: s64; comments: s64; end_trim: s64; }

`frames` is the exact PCM frame count a decoder returns: the final granule position, which trims the last packet(s). Bitrates are the header's hints, 0 when unset.

VorbisComments :: struct { text: Vec(u8); vendor: s64; spans: Vec(s64); }

An owned copy of the comment header: the vendor string, then each user comment ("FIELD=value", UTF-8 by the specification; not validated here). Free it with VorbisCommentsFree (or let the vectors go out of scope).

VorbisMaxStreamFrames :: 4147200000
VorbisRecognizes :: (input: []u8) -> bool

True when the first Ogg packet is a Vorbis identification header; Ogg Opus and other Ogg codecs are not.

VorbisInspect :: (input: []u8, info: *VorbisAudio) -> s32

Validates every page and header of a single logical Ogg Vorbis stream before any decoder sees it, clearing INFO on failure. Truncation, CRC errors, bad headers, packets that are not audio, granule positions that disagree with the packets' block sizes and non-Vorbis input are Malformed; chained or multiplexed streams and a timeline not starting at zero are Unsupported.

VorbisInspectComments :: (input: []u8, info: *VorbisAudio, comments: *VorbisComments) -> s32

VorbisInspect that also copies the comment header into COMMENTS, which is unchanged on failure.

VorbisCommentsFree :: (comments: *VorbisComments)
VorbisCommentCount :: (comments: *VorbisComments) -> s64
VorbisVendor :: (comments: *VorbisComments) -> string

The returned strings borrow COMMENTS until it is freed or refilled.

VorbisComment :: (comments: *VorbisComments, index: s64) -> string

Comment INDEX (0..VorbisCommentCount-1) as stored, "" when out of range.

VorbisCommentValue :: (comments: *VorbisComments, field: string) -> string

The value of the first comment whose field name equals FIELD, ignoring ASCII case (Vorbis field names are case-insensitive), or "".

VorbisSeconds :: (info: *VorbisAudio) -> float64
VorbisPrintInfo :: (info: *VorbisAudio)

One summary line, shared by the CLI and the Windows decode check.

VorbisPrintComments :: (comments: *VorbisComments)

The vendor and each comment on its own line.

VorbisProbe :: (input: []u8, audio: *VorbisAudio) -> bool

Full portable validation with the stream's channels, rate and exact length. Metadata is cleared on failure; no native decoder is needed.

Source ↗ · All modules