Would there we a way to setup the spatial sound to play equally in both ears? Basically get rid of all the stereo aspect of it scaling in each ear depending on direction faced.
Adding @docEdub our audio expert
It looks like if you have a spatial sound set up with a custom attenuation function and an attached mesh, you should be able to set Sound.spatialSound to false to disable the sound’s panner node while still keeping the custom attenuation function working on the sound’s gain node.
See https://playground.babylonjs.com/#2AH4YH#85 for an example.
Sorry to necro this, but how would you accomplish this with the v2 audio engine? We are struggling with the new Spatial Audio doing weird things as far as the volume in each ear. Im under the impression with the new system setting the spatialEnabled to false will disable the min/max distances.
Actually… I should have just checked so seems like disabling the spatialAudio still will use the min and max.
Nevermind!
Actually after more testing it was a false positive due to something else. It seems like even when setting spatialEnabled to false I’m still getting panning?
Hey! I am going to look at this. Take into account I don’t know much about the audio side of the engine, so it may take me a little to figure out this one ![]()
This seems to be a gap in WebAudio API, you can’t do exactly what you want on a PannerNode which is what we use internally. But I am still investigating how to enable this in our AudioEngine V2 in a different way.
Id assume there is a way to access the source, the panner node and the volume node for the distance. Then disconnect the panner node from the chain. I’m just not sure how to access them.
That’s basically what I am changing, disconnect the PannerNode and connect a GainNode so you get distance attenuation, but mono sound.
can we just use AudioNode: channelInterpretation property - Web APIs | MDN
?
Testing this. I bet we can set that to mono.
Aw dang maybe not… Ill have to make sure its not getting overridden or something but this seems like the correct route?
UPDATE maybe not I kinda miss understood the param, but at least I know how to get access to the nodes now.
I’m still reading a lot of WebAudio docs
My idea was to swap between a GainNode and a PannerNode inside the spatialWebAudioSubNode. Still working if that is the best approach.
PR is out here:
If you could help doublecheck @Pryme8 appreciated, my audio setup is not great, so I can notice the distance attenuation, but the stereo effect is much harder to notice for me.
Ill take a look can you update the description with the right demo link to the PR? I’m not able to just swap out the id and get it to load for some reason.
The build has completed, the URL is on the PR and you can also try your own playground there. Let me know how it goes!
Yes just tested this, its perfect. I owe you a coffee.
Happy to help! ![]()
