Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
To my eye, the current DOA rotation to compensate head movement is wrong.
Please note that while this now works correctly for me, your mileage may vary depending on your coordinate system. I always assume a spherical coordinate system from from the SOFA standard which has a top-pole on the z-axis, measures elevation to xy-plane and has 0° azimuth on the x-axis with mathematically positive azimuth, i.e. positive azimuth from x-axis to y-axis.
Edit: I just saw there is similar code in
Rotate_DOA.m
where the order seems right but I'm not sure whether you wouldn't want-el_deg
instead ofel_deg
(line 7). But I'm not using DOA alignment, so I can't quite tell how it all fit together.See below my notes from the commit message:
Reasoning
Let
r: DOA in room coordinates
h: DOA in head coordinates
Z: Rotation Matrix around z-axis with azimuth angle of head
Y: Rotation Matrix around y-axis with elevation angle of head
We start with the fact that the DOA in head coordinates can be forward transformed to the room coordinates by
r = ZYh
because the z-direction must only depend on elevation (Y) and not on azimuth (Z). Since the matrix Z does not touch the z-component, this order ensures that.
Invert the formula by multiplying from the left by Y^(-1)Z^(-1):
h = Y^(-1)Z^(-1)r,
yielding the now implemented formula.
Note that the inverse rotation matrix is either the transpose or the rotation matrix with the negative angle. The negative angle variant is now implemented.
Example
Imagine auralizing a source straight above the listener, i.e. at 90° elevation. The listener is looking upwards 45° and and 90° to the left.
By intuition, the source should be heard from the front at 45° upwards elevation.
Imagine first rotating around the y-axis by -45° (downwards), then around the z-axis by -90° (right). This is wrong, as you would hear the source from the right instead of the front.
Instead, imagine first rotating around the y-axis by -90° (right), then the y-axis by -45° (downwards). In the first step, the location of the source is not changed at all, then it is moved to the front. This is as expected.