Skip to main content

setPan

setPan(id: string, value: number, skipDispatchEvent?: boolean): void;

Pan control: Manage stereo panning for individual sounds or globally.

Set the stereo pan of a sound by its ID. The value ranges from -1 (full left) to 1 (full right), with 0 being center. Optionally, skip dispatching the pan change event.

ParameterTypeDescription
idstringID of the sound to pan
valuenumberPan value between -1 (left) and 1 (right)
skipDispatchEventboolean (optional)When true, skips dispatching the pan change event

Example

await soundManager.loadSounds([{ id: 'helicopter', url: 'helicopter.mp3' }]);

soundManager.play('helicopter', { loop: true });

// Pan to the left
soundManager.setPan('helicopter', -0.5);

// Pan to the right
soundManager.setPan('helicopter', 0.8);

// Center
soundManager.setPan('helicopter', 0);
Pan Position
Center
LCR
Try it: Play the helicopter sound and drag the pan slider to hear the sound move from left to right. The pan updates in real time.