| Index: Source/platform/audio/HRTFElevation.cpp
|
| diff --git a/Source/platform/audio/HRTFElevation.cpp b/Source/platform/audio/HRTFElevation.cpp
|
| index a7a4aac6c2a2da71ba9e209867a2d1e86b239aa7..9abf802f8d2fa41f9dff5296ccaa57baf55598d4 100644
|
| --- a/Source/platform/audio/HRTFElevation.cpp
|
| +++ b/Source/platform/audio/HRTFElevation.cpp
|
| @@ -57,6 +57,15 @@ const size_t ResponseFrameSize = 256;
|
| const float ResponseSampleRate = 44100;
|
|
|
| #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
|
| // local hash table to ensure quick efficient future retrievals.
|
| static PassRefPtr<AudioBus> getConcatenatedImpulseResponsesForSubject(const String& subjectName)
|
| @@ -120,9 +129,20 @@ bool HRTFElevation::calculateKernelsForAzimuthElevation(int azimuth, int elevati
|
| if (!bus)
|
| return false;
|
|
|
| - int elevationIndex = positiveElevation / AzimuthSpacing;
|
| - if (positiveElevation > 90)
|
| - elevationIndex -= AzimuthSpacing;
|
| + // Just sequentially search the table to find the correct index.
|
| + int elevationIndex = -1;
|
| +
|
| + 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 elevations per azimuth, for all azimuths by increasing
|
|
|