AudioEmitter
AudioEmitter ⟵ Audio ⟵ Object3D
Positional audio source that spatializes against the AudioListener.
This class extends Audio. Attach it to any
object that inherits from Object3D so the
emitter follows that object. Each frame it computes distance attenuation
and stereo pan from the listener transform, then writes left / right
volumes. Several emitters and Audio objects
can play at the same time.
Methods
AudioEmitter(AudioListener* listener)
Constructor bound to the global audio listener
| listener | The global audio listener |
virtual AudioEmitter* clone(bool recursive) const override
Creates a copy of this emitter
| recursive | Whether to clone all child objects as well | true |
virtual void copy(const Object3D& object, bool recursive) override
Copies properties from another object
| object | Source object to copy from | |
| recursive | Whether to copy all child objects as well | true |
virtual void update() override
Updates world transform, distance attenuation, and stereo pan
AudioDistance getDistanceModel() const
Returns the current distance model
AudioEmitter* setDistanceModel(AudioDistance value)
Defines which algorithm reduces volume as the source moves away
| value | The distance model to set |
f32 getRefDistance() const
Returns the current reference distance
AudioEmitter* setRefDistance(f32 value)
Defines the distance at which volume reduction starts taking effect
| value | The reference distance to set |
f32 getMaxDistance() const
Returns the current max distance
AudioEmitter* setMaxDistance(f32 value)
Defines the distance after which linear rolloff no longer reduces volume
| value | The max distance |
f32 getRolloffFactor() const
Returns the current rolloff factor
AudioEmitter* setRolloffFactor(f32 value)
Defines how quickly the volume is reduced as the source moves away
| value | The rolloff factor |
AudioEmitter* setDirectionalCone(f32 coneInnerAngle, f32 coneOuterAngle, f32 coneOuterGain)
Sets the directional cone in which the audio can be listened
| coneInnerAngle | Inner cone angle in degrees (no reduction) | |
| coneOuterAngle | Outer cone angle in degrees | |
| coneOuterGain | Volume scale outside the outer cone (0 = silent) |
virtual void applyVolume() override
Applies distance, cone, and stereo pan to this source
Properties
| isAudioEmitter | bool | Read |
| distanceModel | AudioDistance | Distance attenuation algorithm |
| refDistance | f32 | Distance where rolloff begins |
| maxDistance | f32 | Linear model cutoff distance |
| rolloffFactor | f32 | How quickly volume falls with distance |
| coneInnerAngle | f32 | Inner cone angle in degrees |
| coneOuterAngle | f32 | Outer cone angle in degrees |
| coneOuterGain | f32 | Gain outside the outer cone |