Skip to main content

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​

ParameterTypeDefaultDescription
idstringrequiredID 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 setPan stays in the sound's play options, so the next play() puts the panner back at that value. Use resetPan or play with pan: 0 if 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 error event.

See also​