Skip to main content

fadeGlobalIn

fadeGlobalIn(duration?: number, startVolume?: number, endVolume?: number): void;

Fade in the global volume over a specified duration. Optionally, set start and end volumes.

ParameterTypeDefaultDescription
durationnumber1Fade duration in seconds
startVolumenumber0Volume to start from
endVolumenumber1Volume to reach
tip

Use fadeGlobalOut to fade out the global volume.


Example

await soundHub.loadSounds([{ id: 'techno-tune', url: 'techno-tune.mp3' }]);

// Play at zero volume
soundHub.play('techno-tune', { loop: true });

// Option 1: set volume to 0 then fade in
soundHub.setGlobalVolume(0);
soundHub.fadeGlobalIn(3, 0, 1);

// Option 2: fade in from current volume
soundHub.fadeGlobalIn(2, 0.3, 0.8);
Fade type:
⏱ Duration3s
0.5s8s
Try it: Play the techno-tune sound, then use Fade In to gradually raise the global volume or Fade Out to lower it across all sounds.