Skip to main content
Version: 0.4.0

Attenuation Curves

Attenuation curves describe how the direct sound of a source is attenuated depending on its distance to the listener. You can create several of them, e.g. one for the narrator, one for effect sounds, one for ambiences...

tip

Sources are assigned to the first (index 0) attenuation curve per default, so it's often handy to treat tis curve as a global one.

Accessing, tweaking, assigning to sources

The AttenuationCurve instances are members of the renderer Renderer.attenuationCurves, that's where you can tweak their parameters. And sources can be assigned to them using Source.setAttenuationCurveIndex()

Check out the AttenuationCurve class for a rough visualization of the parameters (and see the tip below for a even nicer visualization).

// define curve parameters
const attenuationCurves = renderer.attenuationCurves;
attenuationCurves[0].setParameters(0, -2.47, 2.06, -2.75, 19.31, -38.93, 25.36);
attenuationCurves[1].setParameters(2.5, -15.79, 4.66, -13.27, 8.98, -23.16, 41.16);

let narrator: Source
let riverSoundA: Source
let riverSoundB: Source

// init sources ... //
// ...
//

// assign attenuation curves
narrator.setAttenuationCurveIndex(0);
riverSoundA.setAttenuationCurveIndex(1);
riverSoundB.setAttenuationCurveIndex(1);

Making things more fun

Hardcoding new parameters, compiling the source code, testing, changing the values, again ... this is cumbersome. Our thought as well!

That's why we've created the Attenuation Curve Designer dev-tool. It opens as a popup window and displays all attenuation curves and their assigned sources. All parameters can be adjusted in real-time. Once you've nailed things, simply copy the exported code block and paste it into your project!