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

Unified Diff: Source/core/platform/audio/HRTFPanner.cpp

Issue 14636011: Support multiple HRTFDatabases for different sample-rates (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 7 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
Index: Source/core/platform/audio/HRTFPanner.cpp
diff --git a/Source/core/platform/audio/HRTFPanner.cpp b/Source/core/platform/audio/HRTFPanner.cpp
index 44c859842a5d1b8e21aeeaa5c0711acc641f2ca0..fbe61210c68eb703185602947151ef8437d9b45f 100644
--- a/Source/core/platform/audio/HRTFPanner.cpp
+++ b/Source/core/platform/audio/HRTFPanner.cpp
@@ -47,8 +47,9 @@ const double MaxDelayTimeSeconds = 0.002;
const int UninitializedAzimuth = -1;
const unsigned RenderingQuantum = 128;
-HRTFPanner::HRTFPanner(float sampleRate)
+HRTFPanner::HRTFPanner(float sampleRate, HRTFDatabase* database)
: Panner(PanningModelHRTF)
+ , m_database(database)
, m_sampleRate(sampleRate)
, m_crossfadeSelection(CrossfadeSelection1)
, m_azimuthIndex1(UninitializedAzimuth)
@@ -68,6 +69,7 @@ HRTFPanner::HRTFPanner(float sampleRate)
, m_tempL2(RenderingQuantum)
, m_tempR2(RenderingQuantum)
{
+ ASSERT(database);
}
HRTFPanner::~HRTFPanner()
@@ -100,10 +102,7 @@ int HRTFPanner::calculateDesiredAzimuthIndexAndBlend(double azimuth, double& azi
if (azimuth < 0)
azimuth += 360.0;
- HRTFDatabase* database = HRTFDatabaseLoader::defaultHRTFDatabase();
- ASSERT(database);
-
- int numberOfAzimuths = database->numberOfAzimuths();
+ int numberOfAzimuths = m_database->numberOfAzimuths();
const double angleBetweenAzimuths = 360.0 / numberOfAzimuths;
// Calculate the azimuth index and the blend (0 -> 1) for interpolation.
@@ -134,14 +133,6 @@ void HRTFPanner::pan(double desiredAzimuth, double elevation, const AudioBus* in
return;
}
- // This code only runs as long as the context is alive and after database has been loaded.
- HRTFDatabase* database = HRTFDatabaseLoader::defaultHRTFDatabase();
- ASSERT(database);
- if (!database) {
- outputBus->zero();
- return;
- }
-
// IRCAM HRTF azimuths values from the loaded database is reversed from the panner's notion of azimuth.
double azimuth = -desiredAzimuth;
@@ -216,8 +207,8 @@ void HRTFPanner::pan(double desiredAzimuth, double elevation, const AudioBus* in
double frameDelayR1;
double frameDelayL2;
double frameDelayR2;
- database->getKernelsFromAzimuthElevation(azimuthBlend, m_azimuthIndex1, m_elevation1, kernelL1, kernelR1, frameDelayL1, frameDelayR1);
- database->getKernelsFromAzimuthElevation(azimuthBlend, m_azimuthIndex2, m_elevation2, kernelL2, kernelR2, frameDelayL2, frameDelayR2);
+ m_database->getKernelsFromAzimuthElevation(azimuthBlend, m_azimuthIndex1, m_elevation1, kernelL1, kernelR1, frameDelayL1, frameDelayR1);
+ m_database->getKernelsFromAzimuthElevation(azimuthBlend, m_azimuthIndex2, m_elevation2, kernelL2, kernelR2, frameDelayL2, frameDelayR2);
bool areKernelsGood = kernelL1 && kernelR1 && kernelL2 && kernelR2;
ASSERT(areKernelsGood);

Powered by Google App Engine
This is Rietveld 408576698