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

Fix #324: Handle degenerate azimuth/elevation calculation #1065

Closed
wants to merge 2 commits into from

Conversation

rtoy
Copy link
Member

@rtoy rtoy commented Nov 8, 2016

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).

Raymond Toy added 2 commits November 8, 2016 10:40
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).
@padenot
Copy link
Member

padenot commented Nov 10, 2016

@karlt, does that sound good ?

@rtoy
Copy link
Member Author

rtoy commented Nov 10, 2016

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).

@joeberkovitz
Copy link
Contributor

@padenot @karlt checking to see if we can expedite this review...

@joeberkovitz
Copy link
Contributor

@padenot to ping @karlt and if no answer, @padenot will resolve.

@joeberkovitz
Copy link
Contributor

@padenot reminder - please resolve this if @karlt isn't going to be involved

@padenot
Copy link
Member

padenot commented Apr 11, 2017

So:

  • When the source to listener vector is zero, then the azimuth will be 0, and the normalized azimuth (in degrees) will be 90, so it's right in the front of the listener, and the gain is equal power, which makes sense. This is the case when the listener and source are the same point, so we should not pan.
  • When it's not zero, but the projected source on the listener plane is zero, then the azimuth will be zero, and the normalized azimuth will be 90, so it's equal power, which makes sense. This is the case where the source and the listener are above or below each other. We should not pan.
  • When going from left to right around the center, I hear or see no discontinuity.

@rtoy, what am I missing ?

@rtoy
Copy link
Member Author

rtoy commented Apr 18, 2017

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 projectedSource = [0,0,0] (using the notation from the algorithm), Then, the azimuth is basically acos(0) which is 90 deg.

frontBack will be 0 because projectedSource is the zero vector. Thus, the rest of the steps leave the azimuth as 90.

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.)

@rtoy
Copy link
Member Author

rtoy commented Jun 21, 2017

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.

@rtoy rtoy closed this Jun 21, 2017
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

Successfully merging this pull request may close these issues.

None yet

3 participants