distanceModel
Summary
Determines which algorithm will be used to reduce the volume of an audio source as it moves away from the listener. See below for the available choices. The default is INVERSE_DISTANCE.
Property of apis/webaudio/PannerNodeapis/webaudio/PannerNode
Syntax
var result = PannerNode.distanceModel;
PannerNode.distanceModel = value;
Return Value
Returns an object of type unsigned shortunsigned short
Uses one of the following constant values:
- LINEAR (0), a linear distance model which calculates distanceGain as 1 - rolloffFactor * (distance - refDistance) / (maxDistance - refDistance);
- INVERSE (1) (default), an inverse distance model which calculates distanceGain as refDistance / (refDistance + rolloffFactor * (distance - refDistance));
- EXPONENTIAL (2), an exponential distance model which calculates distanceGain as pow(distance / refDistance, -rolloffFactor).
Examples
var audioCtx = new AudioContext();
var panner = audioCtx.createPanner();
panner.distanceModel = 'inverse';
Related specifications
- W3C Web Audio API
- W3C Editor’s Draft