Skip to main content

resetMasterSpatialPosition

Undo setMasterSpatialPosition. The master position goes back to 0, 0, 0 and the master panner is removed from the output chain.

resetMasterSpatialPosition(): void;

Parameters​

This method takes no parameters.

Returns​

Nothing.

Example​

import { SoundHub } from 'soundhub';

const soundHub = new SoundHub();
await soundHub.loadSound('music', '/audio/theme.mp3');

soundHub.play('music', { loop: true });
soundHub.setMasterSpatialPosition(6, 0, -3);

// Back to a plain mix
soundHub.resetMasterSpatialPosition();
soundHub.getMasterSpatialPosition(); // { x: 0, y: 0, z: 0 }

Good to know​

  • Only acts when a master panner exists. Without one, the stored position is left alone, which matters after cleanupGlobalPan: that removes the panner but keeps the old position.
  • The master chain is rebuilt with the master stereo panner in place, so setGlobalPan keeps working. Since 6.3.2 this no longer disconnects nodes your app connected to getMasterOutput.
  • The master orientation is not reset. getMasterSpatialOrientation keeps returning the last direction, while a panner made later by setMasterSpatialPosition starts pointing along positive x.
  • Always dispatches SoundEventsEnum.GLOBAL_SPATIAL_POSITION_CHANGED ('global_spatial_position_changed') with position, even when there was no panner to remove.

See also​