API Docs for:
Show:

AudioManager Class

Module: gs

Manages the audio playback of the game.

Methods

changeMusic

(
  • music
)

Changes the current music to the specified one.

Parameters:

  • music Object
    • The music to play. If null the current music will stop playing.

disposeMusic

(
  • layer
)

Disposes a music.

Parameters:

  • layer Number
    • The audio layer of the music to dispose.

loadMusic

(
  • name
)

Loads the specified music.

Parameters:

  • name String
    • The name of the music to load.

loadSound

(
  • name
)

Loads the specified sound.

Parameters:

  • name String
    • The name of the sound to load.

play

(
  • path
  • volume
  • rate
  • fadeInTime
)

Plays an audio resource.

Parameters:

  • path String
    • The path to the audio resource.
  • volume Number
    • The volume.
  • rate Number
    • The playback rate.
  • fadeInTime Number
    • The fade-in time in frames.

playMusic

(
  • name
  • volume
  • rate
  • fadeInTime
  • layer
)

Plays a music.

Parameters:

  • name String | Object
    • The music to play. Can be just a name or a music data-object.
  • volume Number
    • The music's volume in percent.
  • rate Number
    • The music's playback rate in percent.
  • fadeInTime Number
    • The fade-in time.
  • layer Number
    • 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:

  • music Object
    • The music to play.
  • fadeTime Number
    • The time for a single fade-in/out in frames.
  • layer Number
    • The audio layer to use.
  • playTime gs.Range
    • Play-Time range like 10s to 30s.
  • playRange gs.Range
    • Play-Range.

playSound

(
  • name
  • volume
  • rate
  • musicEffect
  • voice
)

Plays a sound.

Parameters:

  • name String
    • The name of the sound to play.
  • volume Number
    • The sound's volume.
  • rate Number
    • The sound's playback rate.
  • musicEffect Boolean
    • 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.
  • voice Boolean
    • Indicates if the sound should be handled as a voice.

playVoice

(
  • name
  • volume
  • rate
)

Plays a voice.

Parameters:

  • name String
    • The name of the voice to play.
  • volume Number
    • The voice volume.
  • rate Number
    • The voice playback rate.

prepare

(
  • music
)

Prepares.

Parameters:

  • music Object
    • 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:

  • layers gs.AudioLayerInfo
    • An array of audio layer info objects.

resumeMusic

(
  • fadeInTime
  • layer
)

Resumes a paused music.

Parameters:

  • fadeInTime Number
    • The fade-in time in frames.
  • layer Number
    • The audio layer to resume.

stopAllMusic

(
  • fadeOutTime
)

Stops all music/audio layers.

Parameters:

  • fadeOutTime Number
    • The fade-out time in frames.

stopAllSounds

()

Stops all sounds.

stopAllVoices

()

Stops all voices.

stopMusic

(
  • fadeOutTime
  • layer
)

Stops a music.

Parameters:

  • fadeOutTime Number
    • The fade-out time in frames.
  • layer Number
    • The audio layer to stop.

stopSound

(
  • name
)

Stops a sound and all references of it.

Parameters:

  • name String
    • The name of the sound to stop.

stopVoice

(
  • name
)

Stops a voice.

Parameters:

  • name String
    • 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
)
protected

Updates a randomly played audio buffer.

Parameters:

  • buffer gs.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.