Commit 5c31073f authored by rtoy@chromium.org's avatar rtoy@chromium.org

Use correct HRTF elevation response for negative elevations.

The computed index for negative elevations was off by one. When the
elevation is -45 deg, the selected response corresponded to the entry
for 90 deg, not 315 deg.

To simplify things, we just use a short table to map the index to the
(positive) elevation angle.

No tests for this, but see crbug.com/411191.
BUG=412442

Review URL: https://codereview.chromium.org/565303003

git-svn-id: svn://svn.chromium.org/blink/trunk@181986 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 3a41fc88
...@@ -57,6 +57,15 @@ const size_t ResponseFrameSize = 256; ...@@ -57,6 +57,15 @@ const size_t ResponseFrameSize = 256;
const float ResponseSampleRate = 44100; const float ResponseSampleRate = 44100;
#if USE(CONCATENATED_IMPULSE_RESPONSES) #if USE(CONCATENATED_IMPULSE_RESPONSES)
// This table maps the index into the elevation table with the corresponding angle. See
// https://bugs.webkit.org/show_bug.cgi?id=98294#c9 for the elevation angles and their order in the
// concatenated response.
const int ElevationIndexTableSize = 10;
const int ElevationIndexTable[ElevationIndexTableSize] = {
0, 15, 30, 45, 60, 75, 90, 315, 330, 345
};
// Lazily load a concatenated HRTF database for given subject and store it in a // Lazily load a concatenated HRTF database for given subject and store it in a
// local hash table to ensure quick efficient future retrievals. // local hash table to ensure quick efficient future retrievals.
static PassRefPtr<AudioBus> getConcatenatedImpulseResponsesForSubject(const String& subjectName) static PassRefPtr<AudioBus> getConcatenatedImpulseResponsesForSubject(const String& subjectName)
...@@ -120,9 +129,20 @@ bool HRTFElevation::calculateKernelsForAzimuthElevation(int azimuth, int elevati ...@@ -120,9 +129,20 @@ bool HRTFElevation::calculateKernelsForAzimuthElevation(int azimuth, int elevati
if (!bus) if (!bus)
return false; return false;
int elevationIndex = positiveElevation / AzimuthSpacing; // Just sequentially search the table to find the correct index.
if (positiveElevation > 90) int elevationIndex = -1;
elevationIndex -= AzimuthSpacing;
for (int k = 0; k < ElevationIndexTableSize; ++k) {
if (ElevationIndexTable[k] == positiveElevation) {
elevationIndex = k;
break;
}
}
bool isElevationIndexGood = (elevationIndex >= 0) && (elevationIndex < ElevationIndexTableSize);
ASSERT(isElevationIndexGood);
if (!isElevationIndexGood)
return false;
// The concatenated impulse response is a bus containing all // The concatenated impulse response is a bus containing all
// the elevations per azimuth, for all azimuths by increasing // the elevations per azimuth, for all azimuths by increasing
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment