Skip to main content

getGlobalPan

Get the current stereo pan of the master bus, as set by setGlobalPan.

getGlobalPan(): number;

Parameters​

This method takes no parameters.

Returns​

number: the master pan, from -1 (full left) to 1 (full right). 0 is centre.

Example​

import { SoundHub } from 'soundhub';

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

soundHub.setGlobalPan(0.25);
console.log(soundHub.getGlobalPan()); // 0.25

Good to know​

  • It returns the pan you set, straight away. Before 6.6.0 it read the master panner node, which a browser only updates once the audio thread has run, so right after setGlobalPan it still gave the old value.
  • Before any call to setGlobalPan it returns 0. defaultPan from the hub config pans each sound, not the master.
  • Per-sound pans from setPan are not included.

See also​