PannerNode: distanceModel property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2021.

The distanceModel property of the PannerNode interface is an enumerated value determining which algorithm to use to reduce the volume of the audio source as it moves away from the listener.

The possible values are:

  • linear: A linear distance model calculating the gain induced by the distance according to: 1 - rolloffFactor * (distance - refDistance) / (maxDistance - refDistance)
  • inverse: An inverse distance model calculating the gain induced by the distance according to: refDistance / (refDistance + rolloffFactor * (Math.max(distance, refDistance) - refDistance))
  • exponential: An exponential distance model calculating the gain induced by the distance according to: pow((Math.max(distance, refDistance) / refDistance, -rolloffFactor).

inverse is the default value of distanceModel.

Value

An enum — see DistanceModelType.

Examples

See BaseAudioContext.createPanner() for example code.

Specifications

Specification
Web Audio API
# dom-pannernode-distancemodel

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
distanceModel

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also