MUSIC
Loads and controls the current music stream through sfxlib.
Syntax
`
result = Music Load(filename)
Music Play
result = Music Play()
result = Music Play(filename)
Music Loop
result = Music Loop()
result = Music Loop(filename)
Music Pause
Music Resume
Music Stop
status = Music Status()
position = Music Position()
`
Description
MUSIC is for longer audio that behaves like a current song or background track. It is different from SFX, which is meant for short reusable sound effects. A program normally has one current music stream at a time.
Music Load reads a file and makes it the current track. Music Play starts the current track, or loads and starts a filename in one step. Music Loop does the same thing but repeats the track. Pause, Resume, and Stop control playback after it has started.
Music Status lets a program ask whether the music is stopped, playing, or paused. Music Position reports the current playback position in frames, which can be useful for diagnostics or simple progress displays.
File playback depends on the decoders and audio backend available on the target. A program should check return values and have a fallback path when a file cannot be opened or decoded.
Example
`
if music play("theme.wav") < 0 then
print "could not play music"
end if
sleep 2000, 1
music pause
sleep 500, 1
music resume
sleep 500, 1
music stop
`
Notes

- Use SFX for short overlapping samples such as clicks, shots, or impacts.
- Use generated commands such as PLAY or NOTE when you do not want to ship an audio file.

See also

- `SFX`
- `DEVICE`
- `Sound Library Reference`