0 votes

Hello.

I am using Godot 3.0.6.

I am trying to use AudioStream2D.
And I can not get the volume_db, attenuation and max distance to work.
Pitch scale works perfectly, but those other properties have completely no effect - audio plays with the same volume no matter the position - tho L-R position is correct.

What may be the cause? :/ I googled this but there is no info anywhere.

I want to have positional audio so that the volume gets higher when closer to player character (or center of viewport). At the moment I have positional, but all the same loudness, which is very bad :/

Could anyone give me some clue how to solve this?
Thanks! :D

in Engine by (243 points)

I've digged around this a bit more...

In version 3.1 alpha it works the same way, which means: does not work!

I've checked the GODOT source code, and there are corresponding lines like this:

float dist = global_pos.distance_to(screen_in_global); //distance to screen center
if (dist > max_distance)
        continue; //can't hear this sound in this viewport
float multiplier = Math::pow(1.0f - dist / max_distance, attenuation);
multiplier *= Math::db2linear(volume_db); //also apply player volume!

And this looks all alright - I understand this and it seems it should work as expected.

Though it does not work at all!

I've tested max_distance property values from 1 to 2000 and measured distance from kamera to sound emiter. Sound comes out even if over the max distance value.

I've tested attenuation curves - absolutely no effect on the volume.

Finally I've tried to set the volume_db parameter myself and it also does completely nothing!

Now... Either I am incredibly stupid and do not get something, or this thing does not work as expected!

I've also tried to find an example on AudioStreamPlayer2D usage and there is only the platformer demo, in which it behaves the same way - always plays at max volume. Or at least I did not noticed any difference in volume.

Does anyone have a working case? Or is this really a bug?

I am making progress...

I've managed to run some streams 2D properly with attenuation working as expected.

Though still having issues with one particular node, which plays sound always loud no matter the position.

I'll post again if I find something to report :)

Okay.
Problem resolved.
Everything works fine now.
Fortunately it was a hard to spot bug on my behalf.
:D

I know this was a while ago, but do you mind sharing how you resolved the issue? I'm trying to create enemies that make noise, but I don't want every enemy on the level making noise at once (when they're far away from the player).

Yeah, it was long time ago :/. I do not remember what my mistake was, but definitely I made a bug, that was hard for me to pinpoint. After removing the bug, sound started to sound ok. The bug was something like playing the sound for test purposes on certain node, that was forgotten - or something like that. So it isn't exactly related to Your problem methinks. Good luck tho :).

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.