Have trouble using Web Audio in the BabylonJS framework

I have an app here that uses WebAudioFont with the BabylonJS framework … The mobile and tablet devices won’t play sound. Desktop / Laptop plays fine. I remember this is an issue with Web Audio and SpeechSynthesis API in general.

What line of code would I need to add (perhaps a simple tap) to make the other devices play sound? It has to be a user-generated interaction which I already have in my BabylonJS app.

1 Like

It looks like the problem is in WebAudioFont and not Babylon here ? You could try to check with them as I am not sure a lot of ppl here are familiar with this framework.

In general you need to call resume on the audioContext from a user interaction like a click for instance.

I tried this from my iPad. I got the usual little Icon to un-mute. This just the way it is for mobile.

I got the little icon to un-mute too, that’s for BabylonJS Sound. However, when you click Drop/Stop the Needle, can you hear any music (through WebAudioFont?)

I’m using hybrid here…So only BabylonJS Sound comes through, not WebAudio (through Drop/Stop the Needle Button)

well, I’m sticking with all BabylonJS Sound at the moment, and it seems to work! www.findbach.com/4d

I only did the individual keys, but if as @sebavan said, that button works on a context basis. You can just use BJS’s context, instead of instancing your own.

let audioContext = BABYLON.Engine.audioEngine.audioContext;

I think that did the trick. Thanks!

1 Like

Thanks for everyone who helped out. The verdict is in: I’m keeping BabylonJS to handle all the sounds for now. The quality of the WebAudioFont is just too far away from the sounds I’m intending to use. And it did manage to stop the sounds here. The trick was to make an array of timeout, and then clear each timeout upon stop.

1 Like

See this

iPhone has trigger at the side. Try to switch it. This trigger mutes speaker for Web Audio API sounds but other sounds (audio from Youtube for example) works despite the trigger state. Also Web Audio still plays via earphones.

This is very strange behaviour of iPhone.

1 Like