# Can't get phaser to play nice with another web audio library

**URL:** <https://phaser.discourse.group/t/cant-get-phaser-to-play-nice-with-another-web-audio-library/7048>\
**Category:** Phaser 3\
**Created:** [July 30, 2020, 1:46pm UTC](https://phaser.discourse.group/t/cant-get-phaser-to-play-nice-with-another-web-audio-library/7048 "2020-07-30T13:46:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabrieldavison](https://avatars.discourse-cdn.com/v4/letter/g/ccd318/32.png) [@gabrieldavison](https://phaser.discourse.group/u/gabrieldavison)\
**Post date:** [July 30, 2020, 1:46pm UTC](https://phaser.discourse.group/t/cant-get-phaser-to-play-nice-with-another-web-audio-library/7048/1 "2020-07-30T13:46:27Z")

</div>

Has anyone had any luck getting phaser 3 to work with another web audio library? I am trying to create a game where the sound effects are synthesized using the [Tone.js library](https://tonejs.github.io/). I’m pretty sure I have everything set up correctly but for some reason I can’t get any audio out of the Tone synthesizer I have created. I haven’t had this problem with any of the projects I have made using Tone.js without Phaser so I am pretty sure it’s caused by some interaction between the two.

I have tried setting disableWebAudio to true and also setting noAudio to true in my config but this hasn’t helped. I think that phaser could still be creating an AudioContext which is conflicting with the one created by Tone.js. Does anyone know how to disable the WebAudio part of phaser completely or see something else that might be causing Tone.js not to work?

[Here’s a link to the code on Repl.it if anyone would like to have a look](https://repl.it/join/fnndgeju-gabrieldavison1)

---

<div class="post-metadata">

**Author:** ![supertommy](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/supertommy/32/2548_2.png) [@supertommy](https://phaser.discourse.group/u/supertommy)\
**Post date:** [July 30, 2020, 3:44pm UTC](https://phaser.discourse.group/t/cant-get-phaser-to-play-nice-with-another-web-audio-library/7048/2 "2020-07-30T15:44:08Z")

</div>

I think your repl.it is missing the `sound` folder but I created a basic project to test this and it worked okay for me.

I just used the basic Hello sound from Tone.js and the default phaser3-parcel-template setup. I also added some music just to see what would happen and it seemed to work.

Here’s the relevant code from the `HelloWorldScene`

```javascript
import Phaser from 'phaser'
import * as Tone from 'tone'

export default class HelloWorldScene extends Phaser.Scene
{
    // constructor...

    preload()
    {
        this.load.image('sky', 'http://labs.phaser.io/assets/skies/space3.png')
        this.load.image('logo', 'http://labs.phaser.io/assets/sprites/phaser3-logo.png')
		this.load.image('red', 'http://labs.phaser.io/assets/particles/red.png')
		
        // extra music
		this.load.audio('music', 'music/menu.wav')
    }

    create()
    {
        // play the music
		const music = this.sound.add('music')
		music.play()

		this.add.image(400, 300, 'sky')
			.setInteractive()
			.on(Phaser.Input.Events.GAMEOBJECT_POINTER_UP, async () => {
					await Tone.start()

					// create a synth and connect it to the main output (your speakers)
					const synth = new Tone.Synth().toDestination();

					// play a middle 'C' for the duration of an 8th note
					synth.triggerAttackRelease("C4", "8n");
			})

        // other code...
    }
}

```

---

<div class="post-metadata">

**Author:** ![gabrieldavison](https://avatars.discourse-cdn.com/v4/letter/g/ccd318/32.png) [@gabrieldavison](https://phaser.discourse.group/u/gabrieldavison)\
**Post date:** [July 30, 2020, 6:42pm UTC](https://phaser.discourse.group/t/cant-get-phaser-to-play-nice-with-another-web-audio-library/7048/3 "2020-07-30T18:42:50Z")

</div>

> [@supertommy](#):
>
> ```javascript
> }
> 
> ```

Thanks for having a look at my code, you’re right I forgot to add the sound folder to the repo. I have managed to get the code working, I was calling

```javascript
synth.triggerAttackRelease("C4", "8n", Tone.now();

```

instead of

```javascript
synth.triggerAttackRelease("C4", "8n");

```

Which was stopping the note from triggering. Thanks for your help!
