Skip to main content

getGlobalVolume

Read the master volume, for example to set the position of a volume slider.

getGlobalVolume(): number;

Parameters​

This method takes no parameters.

Returns​

number: the master volume from 0 to 1, rounded to two decimals. While the hub is globally muted you get 0.

Example​

import { SoundHub } from 'soundhub';

const soundHub = new SoundHub();

soundHub.setGlobalVolume(0.7);
soundHub.getGlobalVolume(); // 0.7

soundHub.muteAllSounds();
soundHub.getGlobalVolume(); // 0

Good to know​

  • It reads the master gain as it is now, so during fadeGlobalIn or fadeGlobalOut you get the value part way through the fade.
  • While muted it returns 0 even though the volume to come back to is still stored. That value is not available through a getter.
  • It is the master volume only. For one sound, use getSoundVolume.

See also​