resetPan
Put a sound back in the centre of the stereo field. Called without an id, it centres the master pan instead.
resetPan(id?: string): void;
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
id | string | optional | ID of a loaded sound. Leave it out to reset the master pan. |
Returns
Nothing.
Example
import { SoundHub } from 'soundhub';
const soundHub = new SoundHub();
await soundHub.loadSound('rain', '/audio/rain.mp3');
soundHub.play('rain', { pan: -0.7 });
soundHub.resetPan('rain'); // this sound back in the centre
soundHub.resetPan(); // the master pan back in the centre
Good to know
- With an id, this is
setPanwith0, without thepan_changedevent. It dispatchesSoundEventsEnum.PAN_RESET('pan_reset') withisMaster: falseinstead. - The stereo panner stays on the sound, set to
0, soisStereoPanActivestill returnstrue. UseremovePanto take it off. - Like
setPan, it removes a 3D panner if the sound had one. - Without an id it calls
resetGlobalPan, which also removes the 3D panner from every sound. - Only buffered sounds are handled by id. 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.resetGlobalPan: what the call without an id does.removePan: remove the panner instead of centring it.