AudioEmitter Class

Extends Audio
Module: Audio

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

Methods

connect

()

Connect the audio source.

Used internally on initialisation and when setting / removing

disconnect

()

Disconnect the audio source.

Used internally when setting / removing filters.

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 ifautoplay is set to True.

onEnded

()

Method called when the audio playback stopped.

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.

setDetune

(
  • value
)
AudioEmitter

Set detune value.

Parameters:

  • value Number

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.

Properties

audio

Audio

Audio source resource.

autoplay

Boolean

If true the playback starts automatically.

Default: true

detune

Number

Modify pitch, measured in cents. +/- 100 is a semitone. +/- 1200 is an octave.

gain

GainNode

WebAudio gain node, used to control the volume.

https:// developer.mozilla.org/en-US/docs/Web/API/GainNode

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

Attributes

SOURCE

Object static

Possible source types for the audio emitter.