Playing a video clip with 1st order ambisonics audio I noticed that the sounds were coming from the wrong location in the Videoplayer example code. Left and right directions were swapped.
Function updateHeadAndEyeMatrices calls updateOrientation with parameters in order x, y, z, w.
gvrAudioProcessor.updateOrientation((headFromWorld[6] - headFromWorld[9] < 0) != (x < 0) ? -x : x,(headFromWorld[8] - headFromWorld[2] < 0) != (y < 0) ? -y : y,(headFromWorld[1] - headFromWorld[4] < 0) != (z < 0) ? -z : z,w);
However, if you look at the the function definition the order should be w, x, y, z.
public synchronized void updateOrientation(float w, float x, float y, float z)
Making this fix corrects the left and right, however front an back are swapped.
This can be corrected by changing sign when w and y are calculated...
float w = -(float) Math.sqrt(Math.max(0.0f, 1.0 + sx + sy + sz)) * 0.5f;float x = (float) Math.sqrt(Math.max(0.0f, 1.0 + sx - sy - sz)) * 0.5f;float y = -(float) Math.sqrt(Math.max(0.0f, 1.0 - sx + sy - sz)) * 0.5f;float z = (float) Math.sqrt(Math.max(0.0f, 1.0 - sx - sy + sz)) * 0.5f;
Playing a video clip with 1st order ambisonics audio I noticed that the sounds were coming from the wrong location in the Videoplayer example code. Left and right directions were swapped.
Function updateHeadAndEyeMatrices calls updateOrientation with parameters in order x, y, z, w.
gvrAudioProcessor.updateOrientation(
(headFromWorld[6] - headFromWorld[9] < 0) != (x < 0) ? -x : x,
(headFromWorld[8] - headFromWorld[2] < 0) != (y < 0) ? -y : y,
(headFromWorld[1] - headFromWorld[4] < 0) != (z < 0) ? -z : z,
w);
However, if you look at the the function definition the order should be w, x, y, z.
public synchronized void updateOrientation(float w, float x, float y, float z)
Making this fix corrects the left and right, however front an back are swapped. This can be corrected by changing sign when w and y are calculated...
float w = -(float) Math.sqrt(Math.max(0.0f, 1.0 + sx + sy + sz)) * 0.5f;
float x = (float) Math.sqrt(Math.max(0.0f, 1.0 + sx - sy - sz)) * 0.5f;
float y = -(float) Math.sqrt(Math.max(0.0f, 1.0 - sx + sy - sz)) * 0.5f;
float z = (float) Math.sqrt(Math.max(0.0f, 1.0 - sx - sy + sz)) * 0.5f;