class

MinAudio::Sound

Inherits Reference < Object

Constructors

new(engine : Engine, path : String, *, stream : Bool = false, async : Bool = false, group : SoundGroup | Nil = nil, fence : Pointer(Void) = Pointer(Void).null)

Internal: allocate + ma_sound_init_from_file. Raises MinAudio::Error when the file cannot be opened or decoded.

Source
new(engine : Engine, existing : Sound, *, group : SoundGroup | Nil = nil)

Internal: copy of an existing sound (shares the underlying data).

Source
new(engine : Engine, buffer : AudioBuffer, *, group : SoundGroup | Nil = nil)

Internal: sound over a decoded in-memory AudioBuffer (no file I/O, no re-decode — every sound shares the buffer's PCM). The buffer must outlive this sound; it is kept referenced via @buffer.

Source

Instance methods

at_end?

At the end of its data (a looping sound never is).

Source
close

Uninit the underlying ma_sound. Safe to call twice; further port calls on this object raise.

Source
closed?
Source
cursor

Current position in seconds.

Source
dup

An independent copy sharing this sound's decoded data.

Source
engine

The engine this sound belongs to (kept for #close bookkeeping).

Source
fade(from : Float32, to : Float32, fade_ms : Int) : Nil

Fade volume from from to to over fade_ms. from/to of -1 mean "the current volume" (miniaudio convention).

Source
finalize
Source
length

Total duration in seconds (0 when unknown, e.g. a stream).

Source
looping=(loop : Bool) : Bool
Source
looping?
Source
pan

-1.0 left .. +1.0 right.

Source
pan=(pan : Float32) : Float32
Source
pitch

1.0 = original, 2.0 = one octave up, 0.5 = one octave down.

Source
pitch=(pitch : Float32) : Float32
Source
playing?
Source
position=(pos : Tuple(Float32, Float32, Float32)) : Nil

3D position (spatialization needs engine config flags upstream of this API; harmless without them).

Source
seek(seconds : Float32) : self

Seek to an absolute position in seconds.

Source
start

Start (or restart after #stop) playback. Idempotent while playing.

Source
stop(fade_ms : Int) : self

Stop with a fade-out over fade_ms milliseconds.

Source
stop

Stop playback (keeps the sound — #start replays from the cursor).

Source
to_unsafe
Source
volume
Source
volume=(volume : Float32) : Float32
Source