Jump to content

Disabling audio engine


ozRocker
 Share

Recommended Posts

I recently did some work for a mate using Babylon.js http://www.aarontyler.com.au/blog/strayashrapnel and its basically a Wordpress page which contains iFrames to my 3D pages, so basically there are multiple instances of Babylon.js being loaded.  This worked fine on desktop but started breaking on mobile devices after about the 4th instance.  The problem was having too many audio engines.  I solved this by commenting out some code from the .js file

I removed this:

this._updateAudioParameters();

and this:

            if (this._audioEngine.canUseWebAudio) {
                this._outputAudioNode = this._audioEngine.audioContext.createGain();
                this._outputAudioNode.connect(this._audioEngine.masterGain);
                if (options) {
                    if (options.volume) {
                        this._outputAudioNode.gain.value = options.volume;
                    }
                    if (options.mainTrack) {
                        this._isMainTrack = options.mainTrack;
                    }
                }
            }

I'm wondering if there's a better way to do this.  I couldn't see how it was possible to load Babylon.js and disable the audio engine because the file would stop parsing as soon as it caused an error.
 

Link to comment
Share on other sites

8 hours ago, JCPalmer said:

Something worth trying is running Babylon core.  Web audio is not included there.

interesting...I just noticed that.  Seems to be in the 2.3 version only

http://doc.babylonjs.com/generals/Framework_versions

So I guess I can include the core then include all the other extras that I might be using as well.  Thanks for the heads up bro!

Link to comment
Share on other sites

Interesting. I'm normally creating the audio context only if you're requesting to play a sound via a BABYLON.Sound instancing. Otherwise, I'm never creating an audio context. As far as I remember, I've put that logic starting with v2.2. Which version did you use?

Does the problem occur on iOS or Android (or both)?

You can indeed use also the core version where we've simply removed the audio engine references & code.

 

Link to comment
Share on other sites

16 hours ago, davrous said:

Interesting. I'm normally creating the audio context only if you're requesting to play a sound via a BABYLON.Sound instancing. Otherwise, I'm never creating an audio context. As far as I remember, I've put that logic starting with v2.2. Which version did you use?

Does the problem occur on iOS or Android (or both)?

You can indeed use also the core version where we've simply removed the audio engine references & code.

 

This was with Babylon 2.1.  I was getting problems with iOS.  Didn't test it properly with Android.  It was spitting out errors on the console about too many audio engines.  Was fine on the desktop browsers though.

I switched to using the core now and its working sweet :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...