Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listener orientation affects EAXReverb gain and overall mix #1077

Open
SuperDevbot opened this issue Dec 3, 2024 · 11 comments
Open

Listener orientation affects EAXReverb gain and overall mix #1077

SuperDevbot opened this issue Dec 3, 2024 · 11 comments

Comments

@SuperDevbot
Copy link
Contributor

It appears that EAXReverb changes drastically based on listener orientation in relation to the source position. I encountered this issue in one game engine, then tried to repro in another engine using an older build of OpenAL Soft, getting the same results.

While I do not currently have access to Creative hardware with hardware EAX support to compare results with, I think the results of the following test case speak for themselves:

  1. Create a looping source that has a steady and identifiable loop
  2. Create an AL_EFFECT_EAXREVERB using the following preset: { 0.7000f, 1.000f, 0.9462f, 0.9981f, 1.0f, 0.1000f, 0.9400f, 1.3100f, 2.9079f, 0.0210f, { 0.0000f, 0.0000f, 0.0000f }, 0.0179f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.2440f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 155.3000f, 0.0005f, 0x1 }
  3. Create an AL_FILTER_LOWPASS with AL_LOWPASS_GAIN of 0.1 or lower (AL_LOWPASS_GAINHF may be very low too, but it does not seem to matter for this test case)
  4. Use the filter as a direct filter for the looping source
  5. AL_AUXILIARY_SEND_FILTER to the effect slot from step 2
  6. Move the listener about 2 units from the source and begin changing orientation

In my test cases, this would result in very quiet reverb when just facing away from the source, especially when looking slightly up. It also appears to have an EQ-like effect in some tests I've done, but that is purely subjective and I did not make any effort to confirm this. Of course, if that seems important, I can do some spectrum analysis to confirm this.

As far as I understand EAXReverb, using this preset there should not be any significant difference when looking around. The results are even worse with HRTF enabled.

This problem causes difficulties with the mix, as being surrounded by various sources will sound one way when looking one direction and then completely different when just looking into any other direction. I apologize if there's clearly something about the effect I'm misunderstanding.

The overall mix stays perfectly consistent the moment the aux send is removed, but then obviously there is no reverb effect.

An example of the output of this test can be heard here (headphone warning!):

Spaghetti++.A5rvxnfdxu.mp4

Unfortunately I lack the competence to look into the EAXReverb myself in an attempt to understand what would be the cause of this (I've tried though!) so I'm hoping this issue is seen by someone who might already have an idea.

@kcat
Copy link
Owner

kcat commented Dec 4, 2024

More generally, it seems to be an issue relating to the given sound's relative position, and becomes more noticeable with shorter decay times. There might be an easy fix I can do, though it'll have an effect on the apparent volume reverb (which is necessarily must, if different directions are erroneously being too quiet compared to others), which may or may not need additional correction.

@kcat
Copy link
Owner

kcat commented Dec 4, 2024

This should be fixed/work better with commit 723b852.

@SuperDevbot
Copy link
Contributor Author

It appears commit 723b852 improves the behaviour, but does not fully resolve the issue.
However, now the relative position required for the greatest effect is more clearly defined as just being behind the listener, rather than seemingly random positions. When behind the listener, the source appears much less direct. When infront of the listener, what sounds like the direct signal is much louder compared to the rest:

Spaghetti++.8L9fomcxtk.mp4

This is a big step in the right direction and I appreciate the very quick response!

@kcat
Copy link
Owner

kcat commented Dec 4, 2024

It is normal for sounds behind to be a bit quieter compared to the sides or front, even for plain stereo OpenAL Soft gives a slight "boost" when a sound pans in front (both to make sound volume more consistent as it pans across in front, and also simulate a bit of head occlusion when it's behind, giving the front a slight focus).

The difference should only be about 3dB or so, however since the early reflections are aligned with the sound's original direction, and the early reflections gain is boosted to 2.9079 with a very short delay of 0.02 seconds, so the difference may be much stronger than normal.

@SuperDevbot
Copy link
Contributor Author

That would explain it very well. Would there be any point in an attempt to avoid the effect this would have on the early reflections? I can see how this effect makes sense for the direct path in many (but not all) scenarios, but at least in all use cases I've been trying to use reverb for, this may have a negative effect, especially the use case this particular preset was originally designed for. Maybe even a way to turn off that behaviour outright could make sense?

To explain what it is trying to accomplish: This is used to simulate the interior of a race car in VR, where there are lots of slightly reflective surfaces with next to no acoustic treatment, a loud engine that's either infront, right behind or far behind the driver depending on the vehicle and then a rather unusual reverb effect to simulate transmission of the engine through the whole chassis in the process. The effect this has on the reverb makes looking around quite confusing, even if I understand the intentions behind it.

The scenario described features a person wearing a helmet, while basically sitting inside what can be best described as a resonance chamber, and with all that considered I wouldn't expect head occlusion to have any effect in a real scenario like this at all, so if that can be turned off, it may solve the problems I have. Presently, the effect this 3dB difference has on the reverb is quite obvious.

With this information in mind, I attempted to turn down the early reflections gain considerably, but the issue remained present. In fact with a stereo pan it is also surprisingly obvious without any reverb at all and I'm not sure how I've never noticed it.

That said, unless you agree that head occlusion should not affect early reflections, the original bug is fixed with this commit!

@kcat
Copy link
Owner

kcat commented Dec 5, 2024

It's not possible to turn it off for just early reflections. It's not applied until basically the last step for output; essentially, OpenAL Soft mixes to a 3D virtual soundfield buffer, which holds a sound mix that retains full 3D positioning information. Each effect takes in and puts out such buffers itself too, which are mixed all together to generate a full 3D audio scene in a speaker-agnostic way. Once it's all together, it then transforms that completed 3D soundfield buffer to play back on the output speaker configuration, and that's when the front focus for plain stereo gets applied.

It would be possible to add an option to disable it outright, though it may have adverse effects on front-center sound levels. And as noted, it's simulating a natural head occlusion effect, so people using surround sound or HRTF will still hear sounds and reflections from the back be more attenuated than the front. I can see about tweaking the focus strength, if it's too strong compared to HRTF and the like, but the louder a sound is, the more pronounced the difference is going to be regardless.

All that said, there are some other options to consider. One is to use UHJ instead of plain stereo. That uses a different technique for generating stereo output, which has more in common with Dolby Surround for encoding surround information into stereo, and in fact is an option I suggest people give a try in general for stereo; the main reason it's not the default is it doesn't give a stereo pass-through (that is, when playing a stereo sound with plain stereo output, the left channel goes exclusively to the left output, and the right goes exclusively to the right). Stereo sounds play just fine with UHJ output and retain stereo separation, but you can hear a little channel bleeding if you listen for it.

Another thing to try is add a forward focus to the early reflections themselves (the AL_EAXREVERB_REFLECTIONS_PAN property, setting to {0.0f, 0.0f, 0.5f}). That won't affect the dry/direct path being subjected to the head occlusion effect, but it will move the early reflects to the front to avoid it. People with surround sound or HRTF may be able to notice the early reflections aren't coming from behind, but the sound energy that would be coming from behind and attenuated will be moved toward the front instead.

@SuperDevbot
Copy link
Contributor Author

SuperDevbot commented Dec 9, 2024

Thank you for suggesting UHJ output. I will default to this now as there is no use case that requires plain stereo output here.

I'm not completely convinced there's no more problem after trying UHJ and HRTF. Here is a recording of HRTF, simply looking left and right a few times, downmixed to mono, using the builtin HRTF:

reaper_zbtKgTLUlE.mp4

I realise the HRTF might cause some of that but I wouldn't expect it to be quite that asymmetric. Though without the reverb there's a little asymmetry to it as well. It just seems to be boosted significantly when the effect is active. A similar behaviour can be observed with UHJ in my test case too which is a bit surprising. In both cases, looking left yields far quieter results than looking right.

With UHJ, results are even more extreme:

reaper_wP3KyIB2jh.mp4

Admittedly with a reflections gain of around 1 this problem is far less obvious and barely worse than not having an effect at all but that makes me wonder why reflections gain goes up to +10dB.

I think your assessment of the situation is correct and I appreciate all the effort and help, as I believe the lower reflections gain combined with the fix is good enough for my use case at least. I suppose jacking up the source gain and just filtering the direct path works around this problem too? If you have any ideas how reflections gain >1.0 can be improved further, I'd be happy to try, otherwise feel free to close this!

@kcat
Copy link
Owner

kcat commented Dec 9, 2024

It's possible the second set of early reflections are suffering from some directional attenuation. The secondary reflections still have line-dependent attenuation, though since they are the second bounces that went through some diffusion processing, the thought is it should be more affected by the room over more time. But it could be there's still enough coherency after reflecting that there's still a subtle difference based on the initial direction. I can look into making similar adjustments I did for the primary reflections.

With UHJ, results are even more extreme:

I'm not sure what direction corresponds to what level, but when downmixed to mono, UHJ will have a bit of attenuation in the back (left-right panning levels should be the same, for dry sounds). That happens because sounds in the back get a larger phase shift between the left and right outputs (this is how it "encodes" the front-back position within a stereo sound), which creates a slight amount of destructive phase interference when they're added together to mono. Incidentally, this phase difference also causes a 'beyond the speakers' effect when a sound pans enough to the side.

I suppose jacking up the source gain and just filtering the direct path works around this problem too?

It may have an effect, but the louder a sound is, the more apparent any change in apparent volume will be (whether it's the dry and wet sounds mixing together, or just the wet sound being made louder; mixing the same sound together with itself just creates a louder version of the sound, though the slight time differences with the reflections may cause a comb filtering effect).

@SuperDevbot
Copy link
Contributor Author

Apologies for not specifying what you're hearing in those two examples. In both cases, we start off with the source playing about 1 unit away, looking directly at it, before looking about 90° to the left, then 90° to the right, before repeating it once.
In the UHJ example, movement is a bit erratic. I could've recorded a cleaner example here.

So you should be hearing a sharp decrease in perceived loudness initially, before it peaks and immediately drops back down slightly (so looking left, then moving to look right).

I tried my best to find an example here that should be unaffected by the head occlusion, and made sure to set markers so I would look into both directions equally. No panning of the effect is involved here. I'm surprised I didn't notice this in my initial test setup but going back to it to test, it is exactly the same behaviour there. Looking at the isolated stereo mix, the right channel definitely is a lot quieter when looking left than the left channel when looking right

@kcat
Copy link
Owner

kcat commented Dec 10, 2024

Commit 41dcefb tries to normalize the line levels in the secondary reflections. Let me know if it helps.

Regarding UHJ, if that has a level differences between left- and right-panned sounds even on the dry path (no reverb/effect, and at the same angle from the center just on different sides), that will need to additional investigation. The only differences there should be (aside from the gain itself being swapped between channels) is it should have the opposite phase shift, though the same relative difference, which wouldn't have an audible difference. They should have the same level and sound the same. This is a single mono sound, right? Or is it something else?

@SuperDevbot
Copy link
Contributor Author

This is a single mono sound indeed!
I have tried the latest commit and I think that did the trick. Trying the original worst case of just stereo panning I perceive no obvious differences anymore between the dry and the wet signal and a quick recording revealed both 90° left and 90° right have very similar loudness within margin of error. Looking away from the source doesn't have nearly as much of an effect as before either, sounding much more natural.
The same results go for UHJ so I'm not sure why the dry source behaved the way it did on a previous build. HRTF sounds perfect too. I think it is safe to assume that was an error with my audio setup.

There is a sense of directionality now, no need to use any panning workarounds and everything appears to sound right even with high reflections gain.

In any case I'm quite convinced this is fixed now. If I find any more issues with the UHJ level differences I ran into, I'd put that into a new issue. Thanks for fixing the issue so quickly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants