Skip to content

Attenuation

class Attenuation : public Asset<AmAttenuationID>

Amplitude Attenuation Asset.

An Attenuation materializes how the sound volume and other distance-based parameters are calculated following the distance of the sound source to the listener.

The Attenuation is a shared object between sound sources. They are used only when the sound need to adjust its volume due to the distance of from the listener, and many other parameters.

Functions

Name Description
GetGain Returns the gain of the sound from the given distance to the listener.
GetGain Returns the gain of the sound from the given distance to the listener.
GetShape Returns the shape object of this Attenuation.
GetGainCurve Returns the gain curve attached to this Attenuation.
GetMaxDistance Returns the maximum distance for a fully attenuated sound
IsAirAbsorptionEnabled Returns whether air absorption is enabled for this Attenuation.
EvaluateAirAbsorption Evaluates the air absorption effect for a specific frequency band.

Function Details

EvaluateAirAbsorption

[[nodiscard]] virtual AmReal32 EvaluateAirAbsorption( const AmVec3& soundLocation, const AmVec3& listenerLocation, AmUInt32 band) const = 0

Evaluates the air absorption effect for a specific frequency band.

This method calculates the attenuation factor due to air absorption at a given frequency band for a sound source located at a specific position and a listener located at another specific position.

Parameter soundLocation
The location of the sound source.
Parameter listenerLocation
The location of the listener which is hearing the sound.
Parameter band
The frequency band for which the air absorption effect is evaluated.
Return
The air absorption attenuation factor in decibels (dB) for the given frequency band.

GetGain

[[nodiscard]] virtual AmReal32 GetGain(const AmVec3& soundLocation, const Listener& listener) const = 0

Returns the gain of the sound from the given distance to the listener.

Parameter soundLocation
The location of the sound source.
Parameter listener
The listener which is hearing the sound.
Return
The computed gain value fom the curve.

[[nodiscard]] virtual AmReal32 GetGain(const Entity& entity, const Listener& listener) const = 0

Returns the gain of the sound from the given distance to the listener.

Parameter entity
The entity which emits the sound.
Parameter listener
The listener which is hearing the sound.
Return
The computed gain value fom the curve.

GetGainCurve

[[nodiscard]] virtual const Curve& GetGainCurve() const = 0

Returns the gain curve attached to this Attenuation.

Return
The attenuation's gain curve.

GetMaxDistance

[[nodiscard]] virtual AmReal64 GetMaxDistance() const = 0

Returns the maximum distance for a fully attenuated sound

Return
The maximum sound attenuation distance.

GetShape

* GetShape() const

Returns the shape object of this Attenuation.

Return
The Attenuation shape.

IsAirAbsorptionEnabled

[[nodiscard]] virtual bool IsAirAbsorptionEnabled() const = 0

Returns whether air absorption is enabled for this Attenuation.

Return
true if air absorption is enabled, false otherwise.