dot big bang

Developer API
Menu

Class Audio

All
  • Public
  • Public/Protected
  • All

Hierarchy

  • Audio

Index

Accessors

masterGain

  • get masterGain(): number
  • set masterGain(value: number): void
  • A gain multiplier in the range [0,1] applied to all sounds playing in the Game.

    Returns number

  • A gain multiplier in the range [0,1] applied to all sounds playing in the Game.

    Parameters

    • value: number

    Returns void

Methods

play

  • play(sound: Sound, gain?: number, pitch?: number, offset?: number, looping?: boolean, loopStart?: number, loopEnd?: number): null | SoundPlayback
  • Play a Sound at the end of this frame.

    Parameters

    • sound: Sound

      The Sound resource to play.

    • Optional gain: number

      How loudly to play the sound. In the range [0,1]. Default value: 1.0

    • Optional pitch: number

      A playback speed multiplier in the range (0,8]. Default value: 1.0

    • Optional offset: number

      An offset in seconds to start playback at in the sound. Default value: 0.0

    • Optional looping: boolean

      Whether the Sound should loop continuously or not. Default value: false

    • Optional loopStart: number

      How many seconds into the sound to jump to after a loop finishes.

    • Optional loopEnd: number

      How many seconds into the sound to play before looping back to loopStart.

    Returns null | SoundPlayback

playFromEntity

  • Play a Sound at the end of this frame. The Sound will emanate from the specified Entity.

    Parameters

    • sound: Sound

      The Sound resource to play.

    • entity: Entity

      Which Entity the playing Sound should emanate from.

    • Optional whenEntityRemoved: SoundStopPolicy

      Specifies what to do if the Entity is removed while the Sound is playing. Default value: SoundStopPolicy.Immediate

    • Optional gain: number

      How loudly to play the sound. In the range [0,1]. Default value: 1.0

    • Optional pitch: number

      A playback speed multiplier in the range (0,8]. Default value: 1.0

    • Optional offset: number

      An offset in seconds to start playback at in the sound. Default value: 0.0

    • Optional looping: boolean

      Whether the Sound should loop continuously or not. Default value: false

    • Optional loopStart: number

      Where in seconds playback should return to when the Sound loops. Default value: 0.0

    • Optional loopEnd: number

      Where in seconds playback should loop. A value of zero means the sound will loop at the end. Default value: 0.0

    • Optional rolloffFactor: number

      Describes how quickly gain should be reduced when moving away from the listener. Its range depends on the distanceModel used (negative values are not allowed).

      • SoundDistanceModel.Linear: The range is 0 to 1.
      • SoundDistanceModel.Inverse: The range is 0 to Infinity.
      • SoundDistanceModel.Exponential: The range is 0 to Infinity. Default value: 1.0
    • Optional refDistance: number

      The distance from position within which the sound will be at normal gain. Must be a non-negative number. Default value: 300

    • Optional maxDistance: number

      Represents the maximum distance between the audio source and the listener, outside which the gain is not reduced any further. This property is only used when using SoundDistanceModel.Linear for distanceModel. Must be a positive non-zero number. Default value: 800

    • Optional distanceModel: SoundDistanceModel

      Specifies how the Sound's gain should change based on its distance from the audio listener. Default value: SoundDistanceModel.Linear

    Returns null | SoundPositionalPlayback

playFromLocation

  • playFromLocation(sound: Sound, world: Vector3, gain?: number, pitch?: number, offset?: number, looping?: boolean, loopStart?: number, loopEnd?: number, rolloffFactor?: number, refDistance?: number, maxDistance?: number, distanceModel?: SoundDistanceModel): null | SoundPositionalPlayback
  • Play a Sound at the end of this frame. The Sound will emanate from the specified location in world space.

    Parameters

    • sound: Sound

      The Sound resource to play.

    • world: Vector3

      The coordinate in world space where the Sound should emanate from.

    • Optional gain: number

      How loudly to play the sound. In the range [0,1]. Default value: 1.0

    • Optional pitch: number

      A playback speed multiplier in the range (0,8]. Default value: 1.0

    • Optional offset: number

      An offset in seconds to start playback at in the sound. Default value: 0.0

    • Optional looping: boolean

      Whether the Sound should loop continuously or not. Default value: false

    • Optional loopStart: number

      Where in seconds playback should return to when the Sound loops. Default value: 0.0

    • Optional loopEnd: number

      Where in seconds playback should loop. A value of zero means the sound will loop at the end. Default value: 0.0

    • Optional rolloffFactor: number

      Describes how quickly gain should be reduced when moving away from the listener. Its range depends on the distanceModel used (negative values are not allowed).

      • SoundDistanceModel.Linear: The range is 0 to 1.
      • SoundDistanceModel.Inverse: The range is 0 to Infinity.
      • SoundDistanceModel.Exponential: The range is 0 to Infinity. Default value: 1.0
    • Optional refDistance: number

      The distance from position within which the sound will be at normal gain. Must be a non-negative number. Default value: 300

    • Optional maxDistance: number

      Represents the maximum distance between the audio source and the listener, outside which the gain is not reduced any further. This property is only used when using SoundDistanceModel.Linear for distanceModel. Must be a positive non-zero number. Default value: 800

    • Optional distanceModel: SoundDistanceModel

      Specifies how the Sound's gain should change based on its distance from the audio listener. Default value: SoundDistanceModel.Linear

    Returns null | SoundPositionalPlayback

setListenerOrientation

  • Set the direction in 3D space the audio listener is facing.

    Parameters

    • forward: Vector3

      The forward facing normal vector of the audio listener.

    • up: Vector3

      The up normal vector of the audio listener.

    Returns void

setListenerPosition

  • setListenerPosition(world: Vector3): void
  • Set the location of the audio listener in world space.

    Parameters

    • world: Vector3

      The coordinate to set.

    Returns void