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)
-
Stop unused channels.
Function AutoReleaseChannels() 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%)
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)
Sound
refers to an audio resource. It contains properties such as volume, but it is not involved in playback and is only referenced as an audio resource.
Channel
refers to an instance that is being played using the Sound resource. When it starts playing, it uses the Sound's properties such as volume, but it also has its own properties, which you can set with functions such as ChannelVolume
. Each Channel is independent of each other, but the Sound they reference is the same.
Note: After calling FreeSound, Sound will be recycled, and playback will stop for all Channels due to the loss of audio resources, but that doesn't mean the Channel's resources have been recycled, you still need to call StopChannel to recycle the Channel's resources.