class

Raudio::Music

Inherits Reference < Object

Music represents a streaming audio source Use this for long audio tracks (background music, etc.) Music is streamed in chunks to save memory

Constructors

from_memory(file_type : String, data : Bytes) : self

Load music stream from memory data

Source
load(filename : String | Path) : self

Load music stream from file Supported formats: WAV, OGG, MP3, FLAC, XM, MOD, QOA

Source

Class methods

load(filename : String | Path, &)
Source
ready?(handle : LibRaudio::Music) : Bool

Check if music stream is ready

Source

Instance methods

channels

Get number of channels

Source
close
Source
context_type

Get music context type

Source
finalize
Source
frame_count

Get frame count

Source
length

Get music time length in seconds

Source
looping=(value : Bool)

Set whether the music should loop when it reaches the end

Note: Changes take effect when play is called. To change looping for already playing music, stop and restart it.

Source
looping?

Check if music looping is enabled

Source
pan=(pan : Float32)

Set pan for music (0.5 is center)

Source
pause

Pause music playing

Source
pitch=(pitch : Float32)

Set pitch for music (1.0 is base level)

Source
play

Start music playing

Source
playing?

Check if music is playing

Source
ready?

Check if this music is ready

Source
release
Source
released?
Source
resume

Resume paused music playing

Source
sample_rate

Get sample rate

Source
sample_size

Get sample size

Source
seek(position : Float32)

Seek music to a position in seconds

Source
stop

Stop music playing

Source
time_played

Get current music time played in seconds

Source
to_unsafe

Get the underlying C struct

Source
update

Update music buffer with new stream data Call this regularly (every frame) when playing music

Source
volume=(volume : Float32)

Set volume for music (1.0 is max level)

Source