Audio environment affecting global sounds

Hello again,



I’m having yet another problem with sounds. To put it simply I have an AudioNode that is positional and any environment set (let’s say cave).

So far everything works fine, but if I decide to set the AudioNode as non positional the environment still affects it. The sound isn’t positional anymore, though. But I can still hear the echoes/reverberation linked to the environment.



I also tried setting ReverbEnabled to false when setting it as non positional but it didn’t help.



Is that normal behavior or is there a way to fix it ?

I think the environmental effects are global… though I’d have at least expected turning reverb off to nuke them for that sound.



I half remember running into this same issue a year ago and just not using the environment. You definitely only get one environment set so it wasn’t useful for me… and I sort of remember setting a reverb filter to remove reverb from some sounds and I don’t know why I’d have done that except for the same reasons.

Well, from what I read (and observed) the environments should not impact non positional AudioNodes.

And that actually works, my background musics aren’t affected by the environment, as long as the node as never been positional.

If I turn it into a positional node and then back to non positional, the environment still affects it. That’s why I found it strange.



I might actually end up not needing environments but if I do it’d be nice to know what to do if this happens.

If you enable reverb on a sound then I think it picks up the environment also. It doesn’t have to be positional for reverb.

Yeah that seems logical, but it should also stop when I disable reverb.

Thanks anyway, i’ll see what I can do, but if I have to put a reverb filter on each sound that’s gonna get old quickly.

@marvinssdf said:
Yeah that seems logical, but it should also stop when I disable reverb.
Thanks anyway, i'll see what I can do, but if I have to put a reverb filter on each sound that's gonna get old quickly.


Well, and to me it seems lame anyway since that means it's still doing the calculations for reverb and just not using them. Yuck.

What version of JME are you running, by the way?

Yeah, that sucks too.

I’m using one of the nightly builds from 2/3 weeks ago.

Before using reverb filters it’s probably just better to create another AudioNode when you want a non-reverby one. Just swap it out and let the old one go away.

Yeah, I could do that too. But there would still be a problem though. If it’s just a quick sound effect it’s good, but if it’s longer, like a music, it could be stopped right in the middle of it.

Mmmm… I didn’t realize you were trying to change the reverb of already playing sounds. That might not work anyway.

Oh, I forgot to mention that indeed. My bad.

But, well yeah, it’s one of the possibilities anyway. You see, we’re actually working on a graphical tool/IDE that will be used by other teams to develop games, apps, etc. So pretty much everything can happen, even turning a sound positional and back to non positional without stopping it first.



I was just going through the issues I could find and found this. If it can’t be done then too bad, they will be warned in the docs and that will be that.

I agree that all of these things “should” work… I’m just not sure they do. :slight_smile:



You can check in AudioRenderer (http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/lwjgl/com/jme3/audio/lwjgl/LwjglAudioRenderer.java) to see if you spot any issues. Or do a little debug sleuthing if you are really ambitious.



That’s not one of my favorite classes to play with as it’s kind of fragile… but maybe you can spot the issue.

I should have done that before, it’s actually quite easy to spot:

[java]case ReverbEnabled:

if (!supportEfx || !src.isPositional())

return;



if (src.isReverbEnabled()){

updateSourceParam(src, AudioParam.ReverbFilter);

}else{

AL11.alSource3i(id, EFX10.AL_AUXILIARY_SEND_FILTER, 0, 0, EFX10.AL_FILTER_NULL);

}

break;

case IsPositional:

if (!src.isPositional()){

// play in headspace

alSourcei(id, AL_SOURCE_RELATIVE, AL_TRUE);

alSource3f(id, AL_POSITION, 0,0,0);

alSource3f(id, AL_VELOCITY, 0,0,0);

}else{

alSourcei(id, AL_SOURCE_RELATIVE, AL_FALSE);

updateSourceParam(src, AudioParam.Position);

updateSourceParam(src, AudioParam.Velocity);

updateSourceParam(src, AudioParam.MaxDistance);

updateSourceParam(src, AudioParam.RefDistance);

updateSourceParam(src, AudioParam.ReverbEnabled);

}[/java]



When I set it as non positional, the code does try to update the reverbEnabled parameter, but this parameter won’t be updated if the sound isn’t positional.

If I set reverbEnabled to false before setting the sound as non positional it works so i’ll keep it like that for now.

It seems like you just need to check if reverb is enabled in setPositional() and set it to false if it isn’t

A fix is now in SVN. I did only minimal testing though.

@Momoko_Fan said:
A fix is now in SVN. I did only minimal testing though.

Okay, thanks, I'll check it out.