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
setGlobalPanit still gave the old value. - Before any call to
setGlobalPanit returns0.defaultPanfrom the hub config pans each sound, not the master. - Per-sound pans from
setPanare not included.
See also
setGlobalPan: change the master pan.getPreviousMasterPan: the value before the last change.