Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2323)

Unified Diff: Source/platform/audio/HRTFElevation.cpp

Issue 565303003: Use correct HRTF elevation response for negative elevations. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698