class

Tryst::SDL::AudioSource

Inherits Reference < Object

Audio loaded into a mixer. Shared between Sound and Music, which are the same kind of thing underneath and differ only in how they are loaded and how they are played.

The one real choice is whether to decode the file up front or stream it, which is what predecode below is.

Constructors

new(path : String, mixer : Mixer, predecode : Bool)

predecode decodes the whole file to PCM at load time. Right for a short effect played over and over, wrong for a several-minute music track, where it would mean holding the entire decoded song in memory for no benefit.

Source

Instance methods

destroy

Frees the decoded audio. Anything still playing it stops.

Source
destroyed?
Source
duration_ms

How long the audio runs, or nil when the decoder cannot say - true of some streaming formats, where the length is not known without decoding the whole thing.

Source
format

The format the audio decodes to, which is not necessarily the mixer's - conversion happens during mixing.

Source
mixer
Source
path
Source
to_unsafe

@api private - lets an AudioSource be passed straight to a MIX_ call that wants a MIX_Audio*.

Source