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

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

Issue 565643003: Move utility functions for sample rate to AudioUtilities. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
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
Index: Source/platform/audio/HRTFPanner.cpp
diff --git a/Source/platform/audio/HRTFPanner.cpp b/Source/platform/audio/HRTFPanner.cpp
index 851410a61a04a0459d6627280bdf565679a45b5d..bef6ed00290673d2b83e557a6755fd9a87b7c362 100644
--- a/Source/platform/audio/HRTFPanner.cpp
+++ b/Source/platform/audio/HRTFPanner.cpp
@@ -54,10 +54,10 @@ HRTFPanner::HRTFPanner(float sampleRate, HRTFDatabaseLoader* databaseLoader)
, m_elevation2(0)
, m_crossfadeX(0)
, m_crossfadeIncr(0)
- , m_convolverL1(fftSizeForSampleRate(sampleRate))
- , m_convolverR1(fftSizeForSampleRate(sampleRate))
- , m_convolverL2(fftSizeForSampleRate(sampleRate))
- , m_convolverR2(fftSizeForSampleRate(sampleRate))
+ , m_convolverL1(AudioUtilities::fftSizeForSampleRate(sampleRate))
+ , m_convolverR1(AudioUtilities::fftSizeForSampleRate(sampleRate))
+ , m_convolverL2(AudioUtilities::fftSizeForSampleRate(sampleRate))
+ , m_convolverR2(AudioUtilities::fftSizeForSampleRate(sampleRate))
, m_delayLineL(MaxDelayTimeSeconds, sampleRate)
, m_delayLineR(MaxDelayTimeSeconds, sampleRate)
, m_tempL1(RenderingQuantum)
@@ -72,25 +72,6 @@ HRTFPanner::~HRTFPanner()
{
}
-size_t HRTFPanner::fftSizeForSampleRate(float sampleRate)
-{
- // The HRTF impulse responses (loaded as audio resources) are 512 sample-frames @44.1KHz.
- // Currently, we truncate the impulse responses to half this size,
- // but an FFT-size of twice impulse response size is needed (for convolution).
- // So for sample rates around 44.1KHz an FFT size of 512 is good.
- // For different sample rates, the truncated response is resampled.
- // The resampled length is used to compute the FFT size by choosing a power of two that is
- // greater than or equal the resampled length. This power of two is doubled to get the actual FFT size.
-
- ASSERT(sampleRate >= 3000 && sampleRate <= 192000);
-
- int truncatedImpulseLength = 256;
- double sampleRateRatio = sampleRate / 44100;
- double resampledLength = truncatedImpulseLength * sampleRateRatio;
-
- return 2 * (1 << static_cast<unsigned>(log2(resampledLength)));
-}
-
void HRTFPanner::reset()
{
m_convolverL1.reset();
« Source/platform/audio/AudioUtilities.cpp ('K') | « Source/platform/audio/HRTFPanner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698