Attenuation#

Back To Audio

Attenuation refers to how spatial audio falls off/fades as the listener moves away from it.

Formally, attenuation is a mathematical function which maps the distance between the source and listener to a volume value.

Below, we see three different attenuation functions: linear, logarithmic and inverse. Linear gives a proportional falloff as the distance increases while logarithmic and inverse model a more realistic falloff.

Linear attenuation Linear Attenuation
Logarithmic attenuation Logarithmic Attenuation
Inverse attenuation Inverse Attenuation

The x-axis represents distance between the source and listener while the y-axis represents the perceived volume.

In GameKit, these curves can be modelled by implementing the AudioAttenuation interface and its attenuate method.

The attenuate method is called with the following arguments and should return a 0 - 1 ratio of the max volume:

  1. Distance between the audio source and the listener
  2. Minimum possible distance, below which the audio clip should play at max volume
  3. Maximum possible distance, above which the audio clip should be effectively silent

GameKit ships with one (1) attenuation implementation which is LinearAttenuation.

Public Methods#

Method Description
attenuate Returns a value between 0 and 1 representing the falloff based on the distance