Audio

Audio device, Wave, Sound, Music, AudioStream — every raudio.c binding.

Audio reference

Every raudio.c binding — audio device, Wave (CPU), Sound (short GPU one-shot), Music (streaming BGM), AudioStream (low-level).

Audio device

Audio.init() / Audio.close() / Audio.is_ready() -> Bool

Category: Device · raylib: InitAudioDevice / CloseAudioDevice / IsAudioDeviceReady

Open/close the audio device. Required before any Sound/Music/Wave call.

Audio.init()
-- ... audio calls ...
Audio.close()

raylib cheatsheet · Iron source · Test usage

Audio.set_master_volume(volume: Float32) / get_master_volume() -> Float32

Category: Device · raylib: SetMasterVolume / GetMasterVolume

Global output volume in [0, 1].

Audio.set_master_volume(Float32(0.5))

raylib cheatsheet · Iron source · Test usage

Wave

Wave.load_from_memory(fileType: String, data: [UInt8], dataSize: Int32) -> Wave

Category: Wave · raylib: LoadWaveFromMemory

Load Wave from in-memory byte buffer (first live [UInt8] FFI consumer).

val w = Wave.load_from_memory(".wav", bytes, Int32(bytes.length))

raylib cheatsheet · Iron source · Test usage

Wave.is_valid(wave) -> Bool / Wave.unload(wave)

Category: Wave · raylib: IsWaveValid / UnloadWave

Validity guard + release sample buffer.

if Wave.is_valid(w) { Wave.unload(w) }

raylib cheatsheet · Iron source · Test usage

Wave.copy(wave) -> Wave / crop(wave, initFrame, finalFrame) / format(wave, sampleRate, sampleSize, channels)

Category: Wave · raylib: WaveCopy / Crop / Format

Deep copy; frame-range crop; sample-rate / bit-depth / channel conversion.

val short = Wave.crop(w, Int32(0), Int32(22050))

raylib cheatsheet · Iron source · Test usage

Wave.load_samples(wave) -> [Float32]

Category: Wave · raylib: LoadWaveSamples

Read PCM samples into a Float32 array for inspection/DSP.

val samples = Wave.load_samples(w)

raylib cheatsheet · Iron source · Test usage

Wave.export(wave, filePath) -> Bool / Wave.export_as_code(wave, filePath) -> Bool

Category: Wave · raylib: ExportWave / ExportWaveAsCode

Write Wave to disk as WAV; emit as C source.

Wave.export(w, "bounce.wav")

raylib cheatsheet · Iron source · Test usage

Wave.to_sound(wave) -> Sound

Category: Wave · raylib: LoadSoundFromWave

Upload Wave → GPU Sound for playback. The Wave itself is still owned by you.

val s = Wave.to_sound(w)

raylib cheatsheet · Iron source · Test usage

Sound

Sound.load(filePath: String) -> Sound

Category: Sound · raylib: LoadSound

Load sound file directly (internally = LoadWave + LoadSoundFromWave).

val bounce = Sound.load("tests/assets/bounce.wav")

raylib cheatsheet · Iron source · Test usage

Sound.from_wave(wave) / alias(source) / unload_alias(alias)

Category: Sound · raylib: LoadSoundFromWave / LoadSoundAlias / UnloadSoundAlias

Aliases share sample buffer — cheap way to play overlapping copies of the same one-shot.

val copy = Sound.alias(bounce)
Sound.play(copy)
Sound.unload_alias(copy)

raylib cheatsheet · Iron source · Test usage

Sound.play / stop / pause / resume(sound) / is_playing(sound) -> Bool

Category: Sound · raylib: PlaySound / StopSound / PauseSound / ResumeSound / IsSoundPlaying

Playback controls for one-shots.

if Rectangle.collides(paddle, ball) {
    Sound.play(bounce)
}

raylib cheatsheet · Iron source · Test usage

Sound.set_volume / set_pitch / set_pan(sound, value: Float32)

Category: Sound · raylib: SetSoundVolume / Pitch / Pan

Per-sound volume [0..1], pitch multiplier (1.0 = normal), pan [0..1] (0.5 = center).

Sound.set_volume(bounce, Float32(0.8))

raylib cheatsheet · Iron source · Test usage

Sound.update(sound, data: [Float32], sampleCount: Int32)

Category: Sound · raylib: UpdateSound

Overwrite the sample buffer with new data. Useful for generated sounds.

Sound.update(s, samples, Int32(samples.length))

raylib cheatsheet · Iron source · Test usage

Music

Music.load(filePath: String) -> Music / Music.load_from_memory(fileType, data: [UInt8], dataSize)

Category: Music · raylib: LoadMusicStream / LoadMusicStreamFromMemory

Streaming long audio from file or memory.

val bgm = Music.load("tests/assets/loop.ogg")

raylib cheatsheet · Iron source · Test usage

Music.play / is_playing / update / stop / pause / resume(music)

Category: Music · raylib: PlayMusicStream / IsMusicStreamPlaying / UpdateMusicStream / StopMusicStream / PauseMusicStream / ResumeMusicStream

Call Music.update(m) every frame to feed the decoder's circular buffer.

Music.play(bgm)
while not Window.should_close() {
    Music.update(bgm)
}

raylib cheatsheet · Iron source · Test usage

Music.seek(music, position: Float32) / get_time_length(music) / get_time_played(music) -> Float32

Category: Music · raylib: SeekMusicStream / GetMusicTimeLength / GetMusicTimePlayed

Seconds-based transport controls.

val t = Music.get_time_played(bgm)
Music.seek(bgm, Float32(30.0))

raylib cheatsheet · Iron source · Test usage

Music.set_volume / set_pitch / set_pan / set_looping(music, value)

Category: Music · raylib: SetMusicVolume / Pitch / Pan + SetMusicStreamLooping

Per-track mixer parameters plus loop flag. set_looping returns the updated Music value.

var bgm2 = Music.set_looping(bgm, true)

raylib cheatsheet · Iron source · Test usage

AudioStream

AudioStream.load(sampleRate: UInt32, sampleSize: UInt32, channels: UInt32) -> AudioStream

Category: AudioStream · raylib: LoadAudioStream

Low-level PCM stream you feed manually. Used internally by Music and exposed for synthesis.

val st = AudioStream.load(UInt32(44100), UInt32(16), UInt32(2))

raylib cheatsheet · Iron source · Test usage

AudioStream.update(stream, data: [Float32], frameCount: Int32) / is_processed(stream) -> Bool

Category: AudioStream · raylib: UpdateAudioStream / IsAudioStreamProcessed

Supply new PCM data when is_processed says the next buffer is free.

if AudioStream.is_processed(st) {
    AudioStream.update(st, samples, Int32(samples.length))
}

raylib cheatsheet · Iron source · Test usage

AudioStream.play / pause / resume / stop / is_playing(stream)

Category: AudioStream · raylib: PlayAudioStream / PauseAudioStream / ResumeAudioStream / StopAudioStream / IsAudioStreamPlaying

Playback transport.

AudioStream.play(st)

raylib cheatsheet · Iron source · Test usage

AudioStream.set_buffer_size_default(size: Int32)

Category: AudioStream · raylib: SetAudioStreamBufferSizeDefault

Tweak the default frame-size for newly-loaded streams (affects latency / CPU).

AudioStream.set_buffer_size_default(Int32(4096))

raylib cheatsheet · Iron source · Test usage

Audio callbacks

Declared, but not yet usable

The following callback-based audio APIs are declared in raylib.iron, but they are not usable from Iron yet. The missing piece is compiler support for passing Iron closures through this FFI callback shape. Until that lands, use AudioStream.update in the main loop instead.

AudioStream.set_callback(stream, cb: func(Int, UInt32)) (currently unavailable)

Category: Callbacks · raylib: SetAudioStreamCallback

Per-stream audio-thread callback. This API is documented for completeness, but it is not usable from Iron yet; use the update pattern instead.

-- Not yet available from Iron.

raylib cheatsheet · Iron source · Test usage

AudioStream.attach_processor(stream, cb) / detach_processor(stream) (currently unavailable)

Category: Callbacks · raylib: AttachAudioStreamProcessor / Detach

Add or remove a per-stream DSP processor. This API is not usable from Iron yet for the same callback-FFI reason.

-- Not yet available from Iron.

raylib cheatsheet · Iron source · Test usage

Audio.attach_mixed_processor(cb) / detach_mixed_processor() (currently unavailable)

Category: Callbacks · raylib: AttachAudioMixedProcessor / DetachAudioMixedProcessor

Master-bus DSP processor applied to every stream. This API is not usable from Iron yet.

-- Not yet available from Iron.

raylib cheatsheet · Iron source · Test usage

See also