removePan
Remove the stereo panner from a sound. The audio goes straight from the source to the sound's gain node again, as if it had never been panned.
removePan(id: string): void;
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
id | string | required | ID of a loaded sound. |
Returns
Nothing.
Example
import { SoundHub } from 'soundhub';
const soundHub = new SoundHub();
await soundHub.loadSound('music', '/audio/theme.mp3');
soundHub.play('music');
soundHub.setPan('music', -1);
// Later: drop the panner altogether
soundHub.removePan('music');
soundHub.isStereoPanActive('music'); // false
Good to know
- No event is dispatched.
- Does nothing when the sound has no stereo panner.
- The pan value written by
setPanstays in the sound's play options, so the nextplay()puts the panner back at that value. UseresetPanor play withpan: 0if you want it centred from then on. - Only buffered sounds are handled. For a stream or an id that is not loaded, the error is logged and dispatched as an
errorevent.
See also
setPan: pan a sound left or right.resetPan: centre a sound and keep the panner.isStereoPanActive: check whether a sound has a stereo panner.