AudioEmitter Class

Extends Audio
Module: Audio

AudioEmitter is a Object3D used to play audio inside the scene.

Constructor

AudioEmitter

(
  • audio
)

Parameters:

  • audio Audio

    Audio used by this emitter

Methods

dispose

()

Dispose audio object, stops the playback and disconnects audio node.

getFilter

(
  • index
)

Get a filter to the filters array.

Parameters:

  • index Number

    Index of the filter.

Returns:

Filter.

getFilters

() Array

Get Array with all the filters applied to this audio emitter.

Returns:

Array:

Filters in this audio emitter.

getLoop

() Boolean

Get loop mode.

Returns:

Boolean:

Loop mode.

getOutput

() Object

Get output audio node.

Returns:

Object:

Output audio node.

getPlaybackRate

() Number

Get the playback speed.

Returns:

Number:

Playback speed.

getVolume

(
  • volume
)

Get audio emitter volume.

Parameters:

  • volume Number

initialize

()

Initialize audio object, loads audio data decodes it and starts playback if autoplay is set to True.

pause

() AudioEmitter

Pauses audio playback.

Returns:

AudioEmitter:

Self pointer for chaining

pause

() AudioEmitter

Stops audio playback and resets time to 0.

Returns:

AudioEmitter:

Self pointer for chaining

play

() AudioEmitter

Play audio.

Returns:

AudioEmitter:

Self pointer for chaining

setAudio

(
  • audio
)

Change audio resource.

If changed after initialization the audio buffer will be disconnected and reintialized.

Parameters:

  • audio Audio

    Audio resource.

setBuffer

(
  • audioBuffer
)
AudioEmitter

Set audio buffer to be used by this emitter.

Parameters:

  • audioBuffer AudioBuffer

    Audio buffer to be used.

Returns:

AudioEmitter:

Self pointer for chaining.

setFilter

(
  • filter
)

Set a filter to the filters array.

Parameters:

  • filter Object

setFilters

(
  • value
)
AudioEmitter

Set the entire filters array.

Parameters:

  • value Array

Returns:

AudioEmitter:

Self pointer for chaining

setLoop

(
  • loop
)
AudioEmitter

Set loop mode. If loop set to True the audio repeats after ending.

Parameters:

  • loop Boolean

Returns:

AudioEmitter:

Self pointer for chaining

setNodeSource

(
  • node
)
AudioEmitter

Change the source audio node.

Parameters:

  • node Object

Returns:

AudioEmitter:

Self pointer for chaining

setPlaybackRate

(
  • speed
)
AudioEmitter

Set playback speed.

Parameters:

  • speed Number

Returns:

AudioEmitter:

Self pointer for chaining

setVolume

(
  • value
)
AudioEmitter

Set audio emitter volume.

Parameters:

  • value Number

    Audio volume

Returns:

AudioEmitter:

Self pointer for chaining

toJSON

(
  • meta
)
Object

Serialize object to JSON.

Parameters:

  • meta Object

Returns:

Object:

JSON descrition

Properties

autoplay

Boolean

If true the playback starts automatically.

Default: true

listener

AudioListener

AudioListener used by this emmiter.

Every AudioEmitter has a different WebAudio AudioListener.

loop

Boolean

If true the audio plays in loop.

Default: true

playbackRate

Number

Start time in seconds.

Default: 1.0

sourceType

String

Audio source type, can have the following values:

  • empty
  • buffer
  • audioNode

Default: {"empty"}

startTime

Number

Start time in seconds.

Default: 0.0

volume

Number

Audio volume.

Default: 1.0