# Audio

**URL:** <https://phaser.discourse.group/t/audio/12517>\
**Category:** Phaser 3\
**Created:** [November 7, 2022, 7:40pm UTC](https://phaser.discourse.group/t/audio/12517 "2022-11-07T19:40:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mr-Saba](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/mr-saba/32/6687_2.png) [@Mr-Saba](https://phaser.discourse.group/u/Mr-Saba)\
**Post date:** [November 7, 2022, 7:40pm UTC](https://phaser.discourse.group/t/audio/12517/1 "2022-11-07T19:40:43Z")

</div>

Hi, I have one question about audio: when I use this keyword - this.sound.add(key), it works perfectly, but then I try to use new Phaser.Sound.HTML5AudioSound(scene.sound, key), declared audio plays but isPlaying property remains the same even when the sound completes,

also, it doesn’t trigger a complete event to change isPlaying property manually.

---

<div class="post-metadata">

**Author:** ![Mr-Saba](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/mr-saba/32/6687_2.png) [@Mr-Saba](https://phaser.discourse.group/u/Mr-Saba)\
**Post date:** [November 7, 2022, 7:40pm UTC](https://phaser.discourse.group/t/audio/12517/2 "2022-11-07T19:40:58Z")

</div>

what is the problem?

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [November 8, 2022, 2:44pm UTC](https://phaser.discourse.group/t/audio/12517/3 "2022-11-08T14:44:04Z")

</div>

Sounds need to be added to the manager.

---

<div class="post-metadata">

**Author:** ![GN-c](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/gn-c/32/9310_2.png) [@GN-c](https://phaser.discourse.group/u/GN-c)\
**Post date:** [November 10, 2022, 12:24pm UTC](https://phaser.discourse.group/t/audio/12517/4 "2022-11-10T12:24:52Z")

</div>

![image](https://global.discourse-cdn.com/free1/uploads/phaser1/original/2X/7/788560d15a608d52994ca71f24941f255e4f3e3f.png)  
Sound Manager automatically adds them to list and does other stuff on it.  
do you have specific reason to create Sound object other than Phaser’s native way?

---

<div class="post-metadata">

**Author:** ![Mr-Saba](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/mr-saba/32/6687_2.png) [@Mr-Saba](https://phaser.discourse.group/u/Mr-Saba)\
**Post date:** [November 10, 2022, 1:25pm UTC](https://phaser.discourse.group/t/audio/12517/5 "2022-11-10T13:25:43Z")

</div>

yes, I want to create custom properties for sound class.  
this structure works fine but I cant change the volume by this way  
 ![image](https://global.discourse-cdn.com/free1/uploads/phaser1/original/2X/3/38b7e0b176603703faee1241c709f21ba8ef5169.png)

---

<div class="post-metadata">

**Author:** ![GN-c](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/gn-c/32/9310_2.png) [@GN-c](https://phaser.discourse.group/u/GN-c)\
**Post date:** [November 10, 2022, 3:06pm UTC](https://phaser.discourse.group/t/audio/12517/6 "2022-11-10T15:06:47Z")

</div>

I think `BaseSound` class is not used directly, so it’s better to extend either `WebAudioSound` or `HTML5AudioSound`.  
Downside of this approach is that it pops out of Phaser’s environment and you have to create each sound “manually”.  
because of the way it’s implemented in library, we can’t simply swap out Sound class in Sound Manager.  
Therefore I’m thinking it’s best to extend SoundManager class, override `.add` method - create instance of the sound object you’ve created instead of regular one.  
replace default SoundManager class with new manager before creating Phaser.Game instance.  
also you can update global declarations if you’re using TS.

also aside from that: simple linear fading isn’t the most natural way for fading sound because of how humans perceive sound. more details here: [sound - What's the exact curve for natural audio fading? - Sound Design Stack Exchange](https://sound.stackexchange.com/questions/22783/whats-the-exact-curve-for-natural-audio-fading)

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [November 10, 2022, 3:59pm UTC](https://phaser.discourse.group/t/audio/12517/7 "2022-11-10T15:59:18Z")

</div>

You can add sounds to the manager manually, if you follow the manager code.

But I have to say that `Test` class looks very wrong. `playSound()` is adding a **second** sound which isn’t the instance.

It really looks like all you need is

```nohighlight
function fadeIn(scene, sound, fadeDuration, toVolume) {
  // …
}

```
