Sound

Hierarchy

  • Sound

Index

Constructors

constructor

  • new Sound(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<function>, options?: any): Sound
  • Create a sound and attach it to a scene

    Parameters

    • name: string

      Name of your sound

    • urlOrArrayBuffer: any

      Url to the sound to load async or ArrayBuffer, it also works with MediaStreams

    • scene: Scene
    • Optional readyToPlayCallback: Nullable<function>

      Provide a callback function if you'd like to load your code once the sound is ready to be played

    • Optional options: any

      Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming

    Returns Sound

Properties

autoplay

autoplay: boolean

directionalConeInnerAngle

directionalConeInnerAngle: number

Gets or sets the inner angle for the directional cone.

directionalConeOuterAngle

directionalConeOuterAngle: number

Gets or sets the outer angle for the directional cone.

distanceModel

distanceModel: string

isPaused

isPaused: boolean

isPlaying

isPlaying: boolean

loop

loop: boolean

maxDistance

maxDistance: number

name

name: string

onEndedObservable

onEndedObservable: Observable<Sound>

Observable event when the current playing sound finishes.

onended

onended: function

Type declaration

    • (): any
    • Returns any

refDistance

refDistance: number

rolloffFactor

rolloffFactor: number

soundTrackId

soundTrackId: number

spatialSound

spatialSound: boolean

useCustomAttenuation

useCustomAttenuation: boolean

Methods

attachToMesh

clone

connectToSoundTrackAudioNode

  • connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void
  • Parameters

    • soundTrackAudioNode: AudioNode

    Returns void

detachFromMesh

  • detachFromMesh(): void
  • Returns void

dispose

  • dispose(): void
  • Returns void

getAudioBuffer

  • getAudioBuffer(): AudioBuffer | null
  • Returns AudioBuffer | null

getVolume

  • getVolume(): number
  • Returns number

isReady

  • isReady(): boolean
  • Returns boolean

pause

  • pause(): void
  • Returns void

play

  • play(time?: number, offset?: number): void
  • Play the sound

    Parameters

    • Optional time: number

      (optional) Start the sound after X seconds. Start immediately (0) by default.

    • Optional offset: number

      (optional) Start the sound setting it at a specific time

    Returns void

serialize

  • serialize(): any
  • Returns any

setAttenuationFunction

  • setAttenuationFunction(callback: function): void
  • Parameters

    • callback: function
        • (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number): number
        • Parameters

          • currentVolume: number
          • currentDistance: number
          • maxDistance: number
          • refDistance: number
          • rolloffFactor: number

          Returns number

    Returns void

setAudioBuffer

  • setAudioBuffer(audioBuffer: AudioBuffer): void
  • Parameters

    • audioBuffer: AudioBuffer

    Returns void

setDirectionalCone

  • setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void
  • Transform this sound into a directional source

    Parameters

    • coneInnerAngle: number

      Size of the inner cone in degree

    • coneOuterAngle: number

      Size of the outer cone in degree

    • coneOuterGain: number

      Volume of the sound outside the outer cone (between 0.0 and 1.0)

    Returns void

setLocalDirectionToMesh

  • setLocalDirectionToMesh(newLocalDirection: Vector3): void
  • Parameters

    Returns void

setPlaybackRate

  • setPlaybackRate(newPlaybackRate: number): void
  • Parameters

    • newPlaybackRate: number

    Returns void

setPosition

  • setPosition(newPosition: Vector3): void
  • Parameters

    Returns void

setVolume

  • setVolume(newVolume: number, time?: number): void
  • Parameters

    • newVolume: number
    • Optional time: number

    Returns void

stop

  • stop(time?: number): void
  • Stop the sound

    Parameters

    • Optional time: number

      (optional) Stop the sound after X seconds. Stop immediately (0) by default.

    Returns void

switchPanningModelToEqualPower

  • switchPanningModelToEqualPower(): void
  • Returns void

switchPanningModelToHRTF

  • switchPanningModelToHRTF(): void
  • Returns void

updateDistanceFromListener

  • updateDistanceFromListener(): void
  • Returns void

updateOptions

  • updateOptions(options: any): void
  • Parameters

    • options: any

    Returns void

Static Parse

  • Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound
  • Parameters

    • parsedSound: any
    • scene: Scene
    • rootUrl: string
    • Optional sourceSound: Sound

    Returns Sound

Generated using TypeDoc