Skip to main content

fadeIn

fadeIn(id: string, duration: number, startVolume?: number, endVolume?: number, skipDispatchEvent?: boolean): void;

Fade a playing sound's volume from startVolume to endVolume over duration seconds. Use this to smoothly introduce a sound that is already playing.

ParameterTypeDefaultDescription
idstringID of the sound to fade in
durationnumberFade duration in seconds
startVolumenumber0Volume to start from
endVolumenumber1Volume to reach
skipDispatchEventbooleanfalseWhen true, suppresses the fade event
tip

You can also trigger a fade-in directly from play() via PlayOptions.fadeInDuration — no need to call fadeIn separately.


Example

await soundManager.loadSounds([{ id: 'tokyo-train', url: 'tokyo-train-melody.mp3' }]);

// Start silent
soundManager.play('tokyo-train', { volume: 0, loop: true });

// Fade from 0 → 1 over 3 seconds
soundManager.fadeIn('tokyo-train', 3);

// Or fade from 0.2 → 0.8 over 2 seconds
soundManager.fadeIn('tokyo-train', 2, 0.2, 0.8);
⏱ Fade Duration3s
0.5s8s
Try it: Adjust the duration and click Fade In to hear the sound gradually rise to full volume.