I have the following code:
[java]
echoBeep = new AudioNode(assetManager, “Sounds/robot.ogg”);
echoBeep.setLooping(true);
echoBeep.setPositional(true);
echoBeep.setReverbEnabled(false);
echoBeep.setVolume(1f);
echoBeep.setRefDistance(1f);
echoBeep.setMaxDistance(5f);
subNode.attachChild(echoBeep);
[/java]
the subNode is changing it’s position and even at distances > 60 I still hear the sound just fine. And yes I have this in my main update loop:
[java]
getListener().setLocation(getCamera().getLocation());
getListener().setRotation(getCamera().getRotation());
[/java]
I also made sure that echoBeep’s position and the listener’s position is really that far away from each other. So what am I doing wrong here? Or is this expected behaviour because the volume is scaled logarithmically and therefore never reaches zero? If so, is there a way to stop the sound completely after the echoBeep is outside the max distance range of the listener?
You have misunderstood the purpose of setMaxDistance(). Please read the javadoc for this method.
@pspeed said:
You have misunderstood the purpose of setMaxDistance(). Please read the javadoc for this method.
Thanks - I just read the javadoc - so this setting is just to control at what distance the sound is not "losing volume" anymore, am I correct?
@entrusc said:
Thanks - I just read the javadoc - so this setting is just to control at what distance the sound is not "losing volume" anymore, am I correct?
Yeah, that's basically what it says: "Max distance sets where this fall-off stops and the sound will never get any quieter than at that distance."
Right after that it even has advice for when you want your sound to lose volume quickly.