# Fade in and out streaming audio

**URL:** <https://forum.babylonjs.com/t/fade-in-and-out-streaming-audio/57936>\
**Category:** Questions\
**Tags:** audio, audioengine\
**Created:** [April 19, 2025, 9:00pm UTC](https://forum.babylonjs.com/t/fade-in-and-out-streaming-audio/57936 "2025-04-19T21:00:54Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Panuchka](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/panuchka/32/12054_2.png) [@Panuchka](https://forum.babylonjs.com/u/Panuchka)\
**Post date:** [April 19, 2025, 9:00pm UTC](https://forum.babylonjs.com/t/fade-in-and-out-streaming-audio/57936/1 "2025-04-19T21:00:54Z")

</div>

Hi everyone!

Quick question about the new audioengine now that I’m kind of tackling music stuff… Is there a recommended way to have a fade in/out with the streaming audio? I’m beginning to implement a “jukebox” kind of functionality of changing songs in my game and I wonder if I have to manually just up/lower the volume in the main loop or is there any other way? Thanks in advance \<3

Pinging @docEdub a bit 🙂

---

<div class="post-metadata">

**Author:** ![georgie](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/georgie/32/46049_2.png) [@georgie](https://forum.babylonjs.com/u/georgie)\
**Post date:** [April 21, 2025, 3:45pm UTC](https://forum.babylonjs.com/t/fade-in-and-out-streaming-audio/57936/2 "2025-04-21T15:45:02Z")

</div>

Assigned @docEdub on April 21, 2025, 3:45pm UTC



---

<div class="post-metadata">

**Author:** ![docEdub](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/docedub/32/14525_2.png) [@docEdub](https://forum.babylonjs.com/u/docEdub)\
**Post date:** [April 21, 2025, 4:35pm UTC](https://forum.babylonjs.com/t/fade-in-and-out-streaming-audio/57936/3 "2025-04-21T16:35:36Z")

</div>

This is a good question. Yes, using the main loop is the way to do that right now, but it would be better to do fades at the audio rate, instead. This would be a good feature to add.

---

<div class="post-metadata">

**Author:** ![Panuchka](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/panuchka/32/12054_2.png) [@Panuchka](https://forum.babylonjs.com/u/Panuchka)\
**Post date:** [April 22, 2025, 9:25am UTC](https://forum.babylonjs.com/t/fade-in-and-out-streaming-audio/57936/4 "2025-04-22T09:25:40Z")

</div>

Would be a cool feature no doubt!

I would imagine using it like:

```ts
sound.fadeIn(1000, options)
sound.fadeOut(1000, options)

```

To get a cross fade…

---

<div class="post-metadata">

**Author:** ![Dad72](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dad72/32/13_2.png) [@Dad72](https://forum.babylonjs.com/u/Dad72)\
**Post date:** [May 5, 2025, 5:30pm UTC](https://forum.babylonjs.com/t/fade-in-and-out-streaming-audio/57936/5 "2025-05-05T17:30:21Z")

</div>

@docEdub Is this something that exists at the present time:

```auto
sound.fadeIn(1000, options)
sound.fadeOut(1000, options)

```

It would be great to have that. I’m looking to do that in my behavior scripts right now and I’m wondering what exists at the moment or if there are plans to have this soon.

Thank you in advance.

---

<div class="post-metadata">

**Author:** ![docEdub](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/docedub/32/14525_2.png) [@docEdub](https://forum.babylonjs.com/u/docEdub)\
**Post date:** [May 5, 2025, 5:57pm UTC](https://forum.babylonjs.com/t/fade-in-and-out-streaming-audio/57936/6 "2025-05-05T17:57:41Z")

</div>

No, but soon. I need to do some investigation on what works in different browsers. I know the fade in/out WebAudio functionality is not 100% implemented in Firefox and Chrome on Meta Quest, so I need to go deeper to find the best solution.

---

<div class="post-metadata">

**Author:** ![docEdub](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/docedub/32/14525_2.png) [@docEdub](https://forum.babylonjs.com/u/docEdub)\
**Post date:** [June 25, 2025, 8:13pm UTC](https://forum.babylonjs.com/t/fade-in-and-out-streaming-audio/57936/7 "2025-06-25T20:13:57Z")

</div>

[PR 16781](https://github.com/BabylonJS/Babylon.js/pull/16781) adds a new `setVolume` function to sounds and buses that takes options for `duration` and `shape` type. Fade in and out can be done using this new function.

The important parts are here:

> <https://github.com/BabylonJS/Babylon.js/blob/364a89479a/packages/dev/core/src/AudioV2/abstractAudio/abstractAudioOutNode.ts#L64-L78>

> <https://github.com/BabylonJS/Babylon.js/blob/364a89479a/packages/dev/core/src/AudioV2/audioParameter.ts#L19-L32>

> <https://github.com/BabylonJS/Babylon.js/blob/364a89479a/packages/dev/core/src/AudioV2/audioParameter.ts#L1-L17>

…and the docs will be updated to include `setVolume` soon!

---

<div class="post-metadata">

**Author:** ![docEdub](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/docedub/32/14525_2.png) [@docEdub](https://forum.babylonjs.com/u/docEdub)\
**Post date:** [June 25, 2025, 9:24pm UTC](https://forum.babylonjs.com/t/fade-in-and-out-streaming-audio/57936/9 "2025-06-25T21:24:39Z")

</div>

Unassigned @docEdub on June 25, 2025, 9:24pm UTC



---

<div class="post-metadata">

**Author:** ![Dad72](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dad72/32/13_2.png) [@Dad72](https://forum.babylonjs.com/u/Dad72)\
**Post date:** [June 25, 2025, 10:29pm UTC](https://forum.babylonjs.com/t/fade-in-and-out-streaming-audio/57936/10 "2025-06-25T22:29:05Z")

</div>

Wow, that"s great. Thank you very much for this addition. @docEdub 🙂
