Warning
PlayMusic
is being modified and PlayCDTrack
is being removed.
PlayMusic%(File$, Mode% = 0)
->PlayMusic%(File$, Volume# = 1.0)
PlayCDTrack%(Track%, Mode% = 1)
-> RemovedLoad3DSound%(File$)
<=>LoadSound%(File$)
SoundLoop(sound_variable)
->SoundLoop(sound_variable, Loop% = True)
-
Init volume by
SoundVolume
orPlayMusic
instead ofChannelVolume
- Bad
Local Sound = LoadSound("MySound.ogg") Local Channel = PlaySound(Sound) ChannelVolume(Channel, 0.5)
Local Channel = PlayMusic("MySound.ogg") ChannelVolume(Channel, 0.5)
- Optimized
Local Sound = LoadSound("MySound.ogg") SoundVolume(Sound, 0.5) Local Channel = PlaySound(Sound)
Local Channel = PlayMusic("MySound.ogg", 0.5)
-
Remember to free the sounds and channels.
LoadMySounds() ; User defined function Repeat If KeyDown(1) FreeAllSounds() StopAllChannels() End() EndIf Forever
-
Stop unused channels.
Function AutoReleaseSounds() Local Channel% For i = CountChannels() - 1 To 0 Step -1 Channel = GetChannel(i) If Not ChannelPlaying(Channel) StopChannel(Channel) EndIf Next End Function
ChannelLoop(channel_variable, loop% = True)
GetChannelPause%(channel_variable)
GetChannelPitch#(channel_variable)
GetChannelVolume#(channel_variable)
GetChannelPan#(channel_variable)
GetChannelLoop%(channel_variable)
GetChannelSampleRate%(channel_variable)
CountSounds%()
CountChannels%()
GetSound%(index%)
GetChannel%(index%)
FreeAllSounds()
StopAllChannels()
VerifySound%(sound_variable)
VerifyChannel%(channel_variable)
VerifyChannel
will only check if the channel exists in the channel registry, not if the channel is playing.
ChannelPlaying
has the same functionality as VerifyChannel
, but checks to see if the audio is playing.
Example:
Local Channel = PlayMusic("MyMusic.ogg")
;Wait for the music to end.
While(ChannelPlaying(Channel))
Delay(50)
Wend
Print(VerifyChannel(Channel)) ;Print "1"(True)
Print(ChannelPlaying(Channel)) ;Print "0"(False)