AudioObject
Summary
This class defines an audio object that can be positioned in space and can be rendered
spatially.⚠️
Do not instantiate an AudioObject yourself.
Properties
name
Optional name of the audio object.
Can be used to identify the audio object.
Type
stringAccessors
isConnected
Returns true if an input node is currently connected to this audio object.
Type
booleanMethods
connect
Connects the input node to the audio object.
Signature
connect()Returns
voiddelete
Deletes this audio object object instance from the scene.
Signature
delete()Returns
voidRemarks
This call will disconnect the input node from the renderer (if connected),
and free this object's used slot.⚠️
Do not use this instance after you've called delete on in.
disconnect
Disconnects this object from its input.
Signature
disconnect()Returns
voidgetDirectPathGainDecibels
Returns the currently set direct-path gain in decibels.
Signature
getDirectPathGainDecibels()Returns
number The current direct-path gain in decibels.💡
The effective direct-path gain will be the product of this value and the
distance-dependent value of this object's distance model.
getDirectPathGainLinear
Returns the currently set direct-path gain as a linear value.
Signature
getDirectPathGainLinear()Returns
number The current linear direct-path gain.💡
The effective direct-path gain will be the product of this value and the
distance-dependent value of this object's distance model.
getDistanceModel
Returns the currently used DistanceModel for the direct gain.
Signature
getDistanceModel()Returns
DistanceModelgetGainDecibels
Returns the currently set gain in decibels.
Signature
getGainDecibels()Returns
number The current gain in decibels.getGainLinear
Returns the currently set gain as a linear value.
Signature
getGainLinear()Returns
number The current linear gain.getInput
Returns the currently set input node.
Signature
getInput()Returns
AudioNode The current input AudioNode.getOcclusion
Returns the current occlusion value.
Signature
getOcclusion()Returns
number The occlusion value.getPosition
Returns the current position in cartesian coordinates.
Signature
getPosition()Returns
Vector3D The position object with the current coordinates.getPositionMode
getRenderingMode
Gets the current rendering mode.
Signature
getRenderingMode()Returns
RenderingMode The rendering mode.getReverbDistanceModel
Returns the used DistanceModel for the reverb send.
Signature
getReverbDistanceModel()getReverbSendDecibels
Returns the currently set reverb gain in decibels.
Signature
getReverbSendDecibels()Returns
number The current reverb send gain in decibels.getReverbSendLinear
Returns the currently set reverb send gain as a linear value.
Signature
getReverbSendLinear()Returns
number The current linear reverb send gain.removeInput
Removes the previously set audio input.
Signature
removeInput()Returns
voidsetDirectPathGainDecibels
Sets the direct-path gain in decibels.
Signature
setDirectPathGainDecibels(gainInDecibels: number)| Name | Type | Description |
|---|---|---|
gainInDecibels | number | The gain in decibels to apply to this object's direct path. |
Returns
void💡
The effective direct-path gain will be the product of this value and the
distance-dependent value of this object's distance model.
setDirectPathGainLinear
Sets the direct-path gain from a linear value.
Signature
setDirectPathGainLinear(gain: number)| Name | Type | Description |
|---|---|---|
gain | number | The linear gain to apply to this object's direct path. |
Returns
void💡
The effective direct-path gain will be the product of this value and the
distance-dependent value of this object's distance model.
setDistanceModel
Sets the DistanceModel for the direct gain.
Signature
setDistanceModel(distanceModel: DistanceModel)| Name | Type | Description |
|---|---|---|
distanceModel | DistanceModel | The distance model to be used. |
Returns
voidsetGainDecibels
Sets the gain in decibels.
Signature
setGainDecibels(gainInDecibels: number)| Name | Type | Description |
|---|---|---|
gainInDecibels | number | The gain in decibels to apply to this audio object. |
Returns
voidsetGainLinear
Sets the overall gain from a linear value.
Signature
setGainLinear(gain: number)| Name | Type | Description |
|---|---|---|
gain | number | The linear gain to apply to this audio object. |
Returns
voidsetInput
Sets the audio input for this audio object.
Signature
setInput(input: AudioNode, outputIndex?: number, connect?: boolean)| Name | Type | Description |
|---|---|---|
input | AudioNode | The WebAudioAPI AudioNode that should be used for this object. |
outputIndex optional | number | The output index of the audio input to use. |
connect optional | boolean | Whether the input should be connected or disconnected. |
Returns
voidsetInputFromMediaStreamTrack
Sets the audio input when using a MediaStreamTrack and not an AudioNode.
Signature
setInputFromMediaStreamTrack(input: MediaStreamTrack, outputIndex?: number, connect?: boolean)| Name | Type | Description |
|---|---|---|
input | MediaStreamTrack | The WebAudioAPI MediaStreamTrack that should be used for this audio object. |
outputIndex optional | number | The output index of the audio input to use. |
connect optional | boolean | Whether the input should be connected or disconnected. |
Returns
voidsetOcclusion
Sets the occlusion value.
Signature
setOcclusion(occlusion: number)| Name | Type | Description |
|---|---|---|
occlusion | number | The occlusion value to apply. Can range from 0.0 to 1.0. |
Returns
voidRemarks
Turning occlusion up will make the audio object quieter as well as filtering out the top
end of the spectrum.setPosition
Sets the position using cartesian coordinates.
Signature
setPosition(x: number, y: number, z: number)| Name | Type | Description |
|---|---|---|
x | number | The new x coordinate. |
y | number | The new y coordinate. |
z | number | The new z coordinate. |
Returns
voidsetPositionMode
Sets the position mode.
Signature
setPositionMode(mode: PositionMode)| Name | Type | Description |
|---|---|---|
mode | PositionMode | The position mode to apply. |
Returns
voidsetRenderingMode
Sets the rendering mode.
Signature
setRenderingMode(mode: RenderingMode)| Name | Type | Description |
|---|---|---|
mode | RenderingMode |
Returns
voidsetReverbDistanceModel
Sets a DistanceModel for the reverb send.
Signature
setReverbDistanceModel(distanceModel: undefined | DistanceModel)| Name | Type | Description |
|---|---|---|
distanceModel | undefined | DistanceModel | the DistanceModel to set |
Returns
void💡
If null is passed, the distance model will be unset.
setReverbSendDecibels
Sets the gain in decibels that is applied to the reverb send.
Signature
setReverbSendDecibels(gainInDecibels: number)| Name | Type | Description |
|---|---|---|
gainInDecibels | number | The gain in decibels to apply to the reverb send. |
Returns
voidsetReverbSendLinear
Sets the linear gain that is applied to the reverb send.
Signature
setReverbSendLinear(gain: number)| Name | Type | Description |
|---|---|---|
gain | number | The linear gain to apply to the reverb send. |
Returns
void