AudioManager Class
Manages the audio playback of the game.
Item Index
Methods
Methods
changeMusic
-
music
Changes the current music to the specified one.
Parameters:
-
musicObject- The music to play. If null the current music will stop playing.
disposeMusic
-
layer
Disposes a music.
Parameters:
-
layerNumber- The audio layer of the music to dispose.
loadMusic
-
name
Loads the specified music.
Parameters:
-
nameString- The name of the music to load.
loadSound
-
name
Loads the specified sound.
Parameters:
-
nameString- The name of the sound to load.
play
-
path -
volume -
rate -
fadeInTime
Plays an audio resource.
Parameters:
-
pathString- The path to the audio resource.
-
volumeNumber- The volume.
-
rateNumber- The playback rate.
-
fadeInTimeNumber- The fade-in time in frames.
playMusic
-
name -
volume -
rate -
fadeInTime -
layer
Plays a music.
Parameters:
-
nameString | Object- The music to play. Can be just a name or a music data-object.
-
volumeNumber- The music's volume in percent.
-
rateNumber- The music's playback rate in percent.
-
fadeInTimeNumber- The fade-in time.
-
layerNumber- The layer to play the music on.
playMusicRandom
-
music -
fadeTime -
layer -
playTime -
playRange
Plays a music as a random music. A random music will fade-in and fade-out at random times. That can be combined with other audio-layers to create a much better looping of an audio track.
Parameters:
-
musicObject- The music to play.
-
fadeTimeNumber- The time for a single fade-in/out in frames.
-
layerNumber- The audio layer to use.
-
playTimegs.Range- Play-Time range like 10s to 30s.
-
playRangegs.Range- Play-Range.
playSound
-
name -
volume -
rate -
musicEffect -
voice
Plays a sound.
Parameters:
-
nameString- The name of the sound to play.
-
volumeNumber- The sound's volume.
-
rateNumber- The sound's playback rate.
-
musicEffectBoolean- Indicates if the sound should be played as a music effect. In that case, the current music at audio-layer will be paused until the sound finishes playing.
-
voiceBoolean- Indicates if the sound should be handled as a voice.
playVoice
-
name -
volume -
rate
Plays a voice.
Parameters:
-
nameString- The name of the voice to play.
-
volumeNumber- The voice volume.
-
rateNumber- The voice playback rate.
prepare
-
music
Prepares.
Parameters:
-
musicObject- The music to play. If null the current music will stop playing.
restore
-
layers
Restores audio-playback from a specified array of audio layers.
Parameters:
-
layersgs.AudioLayerInfo- An array of audio layer info objects.
resumeMusic
-
fadeInTime -
layer
Resumes a paused music.
Parameters:
-
fadeInTimeNumber- The fade-in time in frames.
-
layerNumber- The audio layer to resume.
stopAllMusic
-
fadeOutTime
Stops all music/audio layers.
Parameters:
-
fadeOutTimeNumber- The fade-out time in frames.
stopAllSounds
()
Stops all sounds.
stopAllVoices
()
Stops all voices.
stopMusic
-
fadeOutTime -
layer
Stops a music.
Parameters:
-
fadeOutTimeNumber- The fade-out time in frames.
-
layerNumber- The audio layer to stop.
stopSound
-
name
Stops a sound and all references of it.
Parameters:
-
nameString- The name of the sound to stop.
stopVoice
-
name
Stops a voice.
Parameters:
-
nameString- The name of the voice to stop.
update
()
Updates the audio-playback.
updateAudioBuffers
()
protected
Updates all audio-buffers depending on the play-type.
updateAudioBuffers
()
protected
Updates all audio-buffers depending on the play-type.
updateRandomAudio
-
buffer
Updates a randomly played audio buffer.
Parameters:
-
buffergs.AudioBuffer- The audio buffer to update.
Properties
audioLayers
gs.AudioLayerInfo
protected
Stores audio layer info-data for each layer.
buffers
gs.AudioBuffer
protected
Stores all audio buffers.
buffers
gs.AudioBuffer
protected
Stores all audio buffers by layer.
generalMusicVolume
Number
protected
General music volume
generalSoundVolume
Number
protected
General sound volume
generalVoiceVolume
Number
protected
General voice volume
music
Object
protected
Current Music (Layer 0)
musicVolume
Number
protected
Current music volume.
soundReferences
gs.AudioBufferReference
protected
Stores all audio buffer references for sounds.
soundVolume
Number
protected
Current sound volume.
voiceVolume
Number
protected
Current voice volume.
