Import with #import "std/audio_mpeg".

Mp3Info :: struct { version: s32; layer: s32; channels: s32; rate: s32; frames: s64; mp3_frames: s64; frame_samples: s32; delay: s32; padding: s32; bitrate: s32; vbr: bool; audio_at: s64; audio_end: s64; }

`frames` is the exact PCM frame count a decoder returns: a Xing/Info frame count (or the walked frames) times the frame length, minus the LAME encoder delay and padding. Bitrate is nominal for CBR, the average for VBR.

Mp3Header :: struct { version: s32; layer: s32; rate: s32; channels: s32; kbps: s32; samples: s32; bytes: s64; crc: bool; }
Mp3MaxStreamFrames :: 4147200000
Mp3ParseHeader :: (input: []u8, at: s64, header: *Mp3Header) -> s32

Parses the four-byte frame header at AT: Malformed when there is none, Unsupported for free-format frames, whose length no header states.

Mp3Inspect :: (input: []u8, info: *Mp3Info) -> s32

Validates the whole stream before any decoder sees it. Every byte between the leading ID3v2 tags and the trailing ID3v1/APEv2 tags must be a complete frame with the first frame's version, layer, rate and channel count, optionally followed by zero padding. A partial last frame, a Xing count above the walked frames, junk between frames and non-MPEG input are Malformed. Clears INFO on failure.

Mp3Seconds :: (info: *Mp3Info) -> float64
Mp3PrintInfo :: (info: *Mp3Info)

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

Source ↗ · All modules