class Raudio::Music

Overview

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

Defined in:

raudio/music.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.from_memory(file_type : String, data : Bytes) : self #

Load music stream from memory data


[View source]
def self.load(filename : String | Path) : self #

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


[View source]

Class Method Detail

def self.load(filename : String | Path, &) #

[View source]
def self.ready?(handle : LibRaudio::Music) : Bool #

Check if music stream is ready


[View source]

Instance Method Detail

def channels : UInt32 #

Get number of channels


[View source]
def close #

[View source]
def context_type : Int32 #

Get music context type


[View source]
def finalize #

[View source]
def frame_count : UInt32 #

Get frame count


[View source]
def length : Float32 #

Get music time length in seconds


[View source]
def 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.


[View source]
def looping? : Bool #

Check if music looping is enabled


[View source]
def pan=(pan : Float32) #

Set pan for music (0.5 is center)


[View source]
def pause #

Pause music playing


[View source]
def pitch=(pitch : Float32) #

Set pitch for music (1.0 is base level)


[View source]
def play #

Start music playing


[View source]
def playing? : Bool #

Check if music is playing


[View source]
def ready? : Bool #

Check if this music is ready


[View source]
def release #

[View source]
def released? : Bool #

[View source]
def resume #

Resume paused music playing


[View source]
def sample_rate : UInt32 #

Get sample rate


[View source]
def sample_size : UInt32 #

Get sample size


[View source]
def seek(position : Float32) #

Seek music to a position in seconds


[View source]
def stop #

Stop music playing


[View source]
def time_played : Float32 #

Get current music time played in seconds


[View source]
def to_unsafe : Raudio::LibRaudio::Music #

Get the underlying C struct


[View source]
def update #

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


[View source]
def volume=(volume : Float32) #

Set volume for music (1.0 is max level)


[View source]