AudioEmitter Class
AudioEmitter is a Object3D used to play audio inside the scene.
Item Index
Methods
Properties
Attributes
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
NumberIndex of the filter.
Returns:
Filter.
getFilters
()
Array
Get Array with all the filters applied to this audio emitter.
Returns:
Filters in this audio emitter.
getLoop
()
Boolean
Get loop mode.
Returns:
Loop mode.
getOutput
()
Object
Get output audio node.
Returns:
Output audio node.
getPlaybackRate
()
Number
Get the playback speed.
Returns:
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
Stops audio playback and resets time to 0.
Returns:
Self pointer for chaining.
setAudio
-
audio
Change audio resource.
If changed after initialization the audio buffer will be disconnected and reintialized.
Parameters:
-
audio
AudioAudio resource.
setBuffer
-
audioBuffer
Set audio buffer to be used by this emitter.
Parameters:
-
audioBuffer
AudioBufferAudio buffer to be used.
Returns:
Self pointer for chaining.
setDetune
-
value
Set detune value.
Parameters:
-
value
Number
Returns:
Self pointer for chaining.
setFilter
-
filter
Set a filter to the filters array.
Parameters:
-
filter
Object
setFilters
-
value
Set the entire filters array.
Parameters:
-
value
Array
Returns:
Self pointer for chaining.
setLoop
-
loop
Set loop mode. If loop set to True the audio repeats after ending.
Parameters:
-
loop
Boolean
Returns:
Self pointer for chaining.
setNodeSource
-
node
Change the source audio node.
Parameters:
-
node
Object
Returns:
Self pointer for chaining.
setPlaybackRate
-
speed
Set playback speed.
Parameters:
-
speed
Number
Returns:
Self pointer for chaining.
setVolume
-
value
Set audio emitter volume.
Parameters:
-
value
NumberAudio volume
Returns:
Self pointer for chaining.
Properties
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.
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