-
Notifications
You must be signed in to change notification settings - Fork 166
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
Fix #324: Handle degenerate azimuth/elevation calculation #1065
Conversation
In the current code, if the source to listener vector is zero, the algorithm immediately returns azimuth = 0 and elevation = 0. This causes a discontinuity. Instead, remove the early exit and let the source-listener vector propagate through. This removes this discontinuity, but in general there is still the discontinuity when the source and listener positions are the same. This is unavoidable. Also add a short note on what normalize() does in general and when the vector is the 0 vector. (Does nothing).
@karlt, does that sound good ? |
An alternative would be to keep the algorithm as is, but change the values when the source and listener are the same. I think if you follow through, azimuth = 90 (not 0), and elevation = 90, (not 0). |
So:
@rtoy, what am I missing ? |
Ok. I think I remember the issue now. If you go through the computations, but skip the early exit for the case when the source and listener are the same, and also ignore the fact that you can't normalize a zero vector (leave it unchanged). you'll find that you end up with
But I'm no longer able to reason about any of these clearly anymore. The spec is just too confusing now (and even before?). See #1208. I don't know how to compute the equal-power panner output anymore. (I could look at what Chrome and Firefox do, but that's cheating.) |
Irrelevant now that we decided that when the source and listener are at the same location, audio should be heard from both left and right, as Firefox does today. |
In the current code, if the source to listener vector is zero, the
algorithm immediately returns azimuth = 0 and elevation = 0. This
causes a discontinuity.
Instead, remove the early exit and let the source-listener vector
propagate through. This removes this discontinuity, but in general
there is still the discontinuity when the source and listener
positions are the same. This is unavoidable.
Also add a short note on what normalize() does in general and when the
vector is the 0 vector. (Does nothing).