Import with #import "std/audio".
AUDIO_RATE :: 48000AUDIO_VOICES :: 32AudioSource :: struct { state: *void; read: AudioSourceRead; rewind: AudioSourceRewind; close: AudioSourceClose; seek: AudioSourceSeek; rate: s32; channels: s32; frames: s64; }Interleaved float32 frames at `rate`, from a decoder.
AudioSourceRead :: #type (state: *void, output: []float32, frames: s64) -> s64AudioSourceRewind :: #type (state: *void) -> boolAudioSourceClose :: #type (state: *void)AudioSourceSeek :: #type (state: *void, frame: s64) -> boolA decoder: whether BYTES are its format, and a source over them. The bytes
AudioDecoderProbe :: #type (bytes: []u8) -> boolA decoder: whether BYTES are its format, and a source over them. The bytes stay valid and unchanged until the source closes.
AudioDecoderOpen :: #type (bytes: []u8, source: *AudioSource) -> boolAudioTap :: #type (samples: []float32, frames: s64)Sees each mixed block: `frames` stereo frames, on the sink's audio thread.
AudioLockCall :: #type ()AudioVoiceState :: enum { Unloaded = 0; Stopped = 1; Playing = 2; Paused = 3; Finished = 4; }AudioVoice :: struct { slot: s32; generation: u32; }AudioDecodedSource :: (samples: *Vec(float32), rate: s32, channels: s32, source: *AudioSource) -> boolA source over frames decoded whole, which it takes from SAMPLES.
AudioUseDecoder :: (probe: AudioDecoderProbe, open: AudioDecoderOpen) -> boolA decoder module registers itself from its initializer.
AudioUseLock :: (enter: AudioLockCall, leave: AudioLockCall)The sink's lock around changes the audio thread could see.
AudioUseTap :: (next: AudioTap)AudioSetMasterGain :: (gain: float32)AudioRender :: (output: []float32, frames: s64)Mixes FRAMES stereo frames of every playing voice into OUTPUT, replacing what it held, then shows them to the tap. The sink's audio thread calls this; a test can call it directly.
AudioLoad :: (bytes: string, stream: bool) -> AudioVoiceA voice of BYTES in the first registered format that recognizes them: decoded whole now, or, for music (`stream`), while it plays. The bytes are copied; slot -1 when no decoder knows them or every voice is in use.
AudioLoadFile :: (path: string, stream: bool) -> AudioVoiceAudioOpenStream :: (rate: s32, channels: s32, frames: s32) -> AudioVoiceA stream of signed 16-bit blocks of FRAMES frames each, at RATE.
AudioStreamWritable :: (voice: AudioVoice) -> boolRoom for another whole block.
AudioStreamSubmit :: (voice: AudioVoice, samples: []s16) -> boolCopies one whole block of interleaved samples; false when it is not exactly one block or there is no room.
AudioPlay :: (voice: AudioVoice) -> boolFrom the start.
AudioStop :: (voice: AudioVoice)AudioPause :: (voice: AudioVoice)AudioResume :: (voice: AudioVoice)AudioState :: (voice: AudioVoice) -> AudioVoiceStateAudioPlaying :: (voice: AudioVoice) -> boolAudioSetGain :: (voice: AudioVoice, gain: float32)0 is silent, 1 as decoded.
AudioSetPitch :: (voice: AudioVoice, pitch: float32)Speed and pitch together: 2 plays an octave up in half the time.
AudioSetLooping :: (voice: AudioVoice, looping: bool)AudioSeek :: (voice: AudioVoice, seconds: float64) -> boolSeeks to seconds within a seekable source. Playing/paused/stopped states are preserved; a finished voice becomes paused, ready to resume there. Live PCM streams and unsupported decoder sources return false unchanged.
AudioPosition :: (voice: AudioVoice) -> float64Seconds played since the start, or since the loop began again.
AudioLength :: (voice: AudioVoice) -> float64Seconds of the whole sound, or -1 when its decoder cannot say.
AudioUnload :: (voice: AudioVoice)