Index: third_party/WebKit/Source/modules/webaudio/IIRDSPKernel.cpp |
diff --git a/third_party/WebKit/Source/modules/webaudio/IIRDSPKernel.cpp b/third_party/WebKit/Source/modules/webaudio/IIRDSPKernel.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..001182857cea7f9a75cd2ae6957b6e42d812f99f |
--- /dev/null |
+++ b/third_party/WebKit/Source/modules/webaudio/IIRDSPKernel.cpp |
@@ -0,0 +1,54 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "config.h" |
+ |
+#include "modules/webaudio/IIRDSPKernel.h" |
+ |
+#include "platform/FloatConversion.h" |
+ |
+namespace blink { |
+ |
+void IIRDSPKernel::process(const float* source, float* destination, size_t framesToProcess) |
+{ |
+ ASSERT(source); |
+ ASSERT(destination); |
+ |
+ m_iir.process(source, destination, framesToProcess); |
+} |
+ |
+void IIRDSPKernel::getFrequencyResponse(int nFrequencies, const float* frequencyHz, float* magResponse, float* phaseResponse) |
+{ |
+ bool isGood = nFrequencies > 0 && frequencyHz && magResponse && phaseResponse; |
+ ASSERT(isGood); |
+ if (!isGood) |
+ return; |
+ |
+ Vector<float> frequency(nFrequencies); |
+ |
+ double nyquist = this->nyquist(); |
+ |
+ // Convert from frequency in Hz to normalized frequency (0 -> 1), |
+ // with 1 equal to the Nyquist frequency. |
+ for (int k = 0; k < nFrequencies; ++k) |
+ frequency[k] = narrowPrecisionToFloat(frequencyHz[k] / nyquist); |
+ |
+ m_iir.getFrequencyResponse(nFrequencies, frequency.data(), magResponse, phaseResponse); |
+} |
+ |
+double IIRDSPKernel::tailTime() const |
+{ |
+ // This is true mathematically (infinite impulse response), but perhaps it should be limited to |
hongchan
2015/10/09 18:10:00
The comment sounds like a TODO, and it needs to be
Raymond Toy
2015/10/09 19:41:15
Done.
|
+ // a smaller value, possibly based on the actual filter coefficients. To do that, we would |
+ // probably need to find the pole, r, with largest magnitude and select some threshold, eps, |
+ // such that |r|^n < eps for all n >= N. N is then the tailTime for the filter. |
+ return std::numeric_limits<double>::infinity(); |
+} |
+ |
+double IIRDSPKernel::latencyTime() const |
+{ |
+ return 0; |
+} |
+ |
+} // blink |