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
fadeGlobalInorfadeGlobalOutyou get the value part way through the fade. - While muted it returns
0even 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
setGlobalVolume: set the master volume.muteAllSounds: silence everything.getSoundVolume: the volume of one sound.