removeSpatialEffect
Remove the 3D panner from a sound. The audio goes straight from the source to the sound's gain node again, with no position or distance applied.
removeSpatialEffect(id: string): void;
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
id | string | required | ID of a loaded sound or of one of its instances. |
Returns
Nothing.
Example
import { SoundHub } from 'soundhub';
const soundHub = new SoundHub();
await soundHub.loadSound('rain', '/audio/rain.mp3');
soundHub.play('rain', { loop: true });
soundHub.setSpatialPosition(5, 0, -5, 'rain');
// Back to plain playback
soundHub.removeSpatialEffect('rain');
soundHub.isSpatialAudioActive('rain'); // false
Good to know
- No event is dispatched.
- The sound goes back to stereo for good: its position returns to
0, 0, 0and its pan type toSoundPanType.Stereo, in its play options as well, so the nextplay()does not build a new panner. Before 6.4.0 it did, and the effect came back. - The sound's gain node is disconnected and connected to the master again, even when there was no panner.
setPanandsetGlobalPancall this for you on spatial sounds.- 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
setSpatialPosition: place a sound in 3D.isSpatialAudioActive: check whether a sound has a 3D panner.removePan: the same for the stereo panner.resetSpatialPosition: move a sound to0, 0, 0and keep the panner.