# Is there an easy way to fade in/out the audio clips?

**URL:** <https://forum.babylonjs.com/t/is-there-an-easy-way-to-fade-in-out-the-audio-clips/36497>\
**Category:** Questions\
**Tags:** audio\
**Created:** [December 12, 2022, 10:05pm UTC](https://forum.babylonjs.com/t/is-there-an-easy-way-to-fade-in-out-the-audio-clips/36497 "2022-12-12T22:05:10Z")\
**Posts on this page:** 3\
**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:** [December 12, 2022, 10:05pm UTC](https://forum.babylonjs.com/t/is-there-an-easy-way-to-fade-in-out-the-audio-clips/36497/1 "2022-12-12T22:05:10Z")

</div>

Hi everyone!

Short question to ask about the current audio engine. Is there any way to fade in/out the audio clips on play/stop other than maybe manually tuning the volume?

I have a case in my game where I play continuous looping sound from a gadget. However this sound starts from the default volume levels and when I stop it, the sound is instantly gone. Would be really cool to start looping the sound from zero volume and move it to default volume, and on reverse when stopped 🙂

Do you guys have any suggestions how to implement this or is there an easy function available that I am not aware of? Cheers! 🕶 🙏

---

<div class="post-metadata">

**Author:** ![JCPalmer](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jcpalmer/32/42_2.png) [@JCPalmer](https://forum.babylonjs.com/u/JCPalmer)\
**Post date:** [December 13, 2022, 12:26am UTC](https://forum.babylonjs.com/t/is-there-an-easy-way-to-fade-in-out-the-audio-clips/36497/2 "2022-12-13T00:26:01Z")

</div>

There is a setting for the gain. You might transition it to zero to fade out. The Sound class might use the term volume for the gain. Check docs or source file. This can be done.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [December 13, 2022, 9:50am UTC](https://forum.babylonjs.com/t/is-there-an-easy-way-to-fade-in-out-the-audio-clips/36497/3 "2022-12-13T09:50:51Z")

</div>

`setVolume` is what you need:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/e/f/ef8495f43a0e3fcd95748290ff5cdb07d7b86165.png)

Use something like `setVolume(0, 2)` to fade the sound out after 2 seconds.
