Skip to main content
Version: Next

AudioListener

The AudioListener interface represents the position and orientation of the person listening to the audio scene. It is used for 3D spatialization: all PannerNode objects spatialize sound in relation to the context's listener.

AudioListener is not an AudioNode — it has no inputs, outputs, or connect()/disconnect() methods. It only exposes nine AudioParam properties.

Every BaseAudioContext exposes a single listener through its read-only listener property — you never construct one yourself.

  • The positionX, positionY and positionZ parameters represent the location of the listener in 3D Cartesian coordinate space.
  • The forwardX, forwardY and forwardZ parameters represent a direction vector in 3D space — which direction the listener's "nose" is pointing.
  • The upX, upY and upZ parameters represent the direction the top of the listener's head is pointing.

The forward and up vectors are expected to be linearly independent.

Example​

import { AudioContext } from 'react-native-audio-api';

const ctx = new AudioContext();
const listener = ctx.listener;

// Move the listener 3 meters along the x axis.
listener.positionX.value = 3;

// Or automate the movement over time.
listener.positionX.linearRampToValueAtTime(10, ctx.currentTime + 2);

Properties​

All properties are AudioParams with minValue/maxValue spanning the full single-precision float range (approximately ±3.4028235e38), a-rate automation.

Look here for more detailed explanation what each property means.

NameTypeDefault valueDescription
positionXAudioParam0x-coordinate of the listener's position.
Read only
positionYAudioParam0y-coordinate of the listener's position.
Read only
positionZAudioParam0z-coordinate of the listener's position.
Read only
forwardXAudioParam0x-component of the listener's forward direction.
Read only
forwardYAudioParam0y-component of the listener's forward direction.
Read only
forwardZAudioParam-1z-component of the listener's forward direction.
Read only
upXAudioParam0x-component of the listener's up direction.
Read only
upYAudioParam1y-component of the listener's up direction.
Read only
upZAudioParam0z-component of the listener's up direction.
Read only

Remarks​

  • Used by PannerNode for 3D spatialization relative to the listener.

We are Software Mansion.