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.
| Parameter | Type | Description |
|---|---|---|
id | string | ID of the sound to pan |
value | number | Pan value between -1 (left) and 1 (right) |
skipDispatchEvent | boolean (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
CenterLCR
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.