Tryst::SDL::Music
Inherits Tryst::SDL::AudioSource < Reference < Object
A longer piece of audio - a background track - streamed from disk rather than decoded up front, and played on one Track it owns.
music = Tryst::SDL::Music.new("background.mp3")
music.gain = 0.4
music.play # loops forever by default
music.fade_out(1500)
Nothing here limits playback to one music at a time - a Music is an ordinary audio source on an ordinary track, so several can run at once. Keeping to one is the application's choice, not a rule.
Constructors
Instance methods
Fades out over ms and stops. The same thing as stop(ms),
named for how it reads at the call site.
Setting this to 0 is how an endless music is brought to a
graceful end: the current pass finishes rather than being cut off
mid-sample the way #stop would.
Starts, or restarts, playback. loops counts EXTRA passes, so the default of -1 repeats forever and 0 plays through once.
Playing, paused and stopped are mutually exclusive, so a PAUSED
MUSIC IS NOT PLAYING. To ask "has this been started at all", use
!stopped?.
How far in it has played, or nil if the input cannot say - the number a progress bar wants.
Seeks. Needs a seekable input, which a streamed file normally is.
How much of the current pass is left, or nil if unknown. Looping does not extend it - it is the remainder of this pass.
The track this music plays on, for the things Track can do that Music does not wrap - starting part-way in, say.