OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "config.h" | |
6 | |
7 #include "modules/webaudio/IIRDSPKernel.h" | |
8 | |
9 #include "platform/FloatConversion.h" | |
10 | |
11 namespace blink { | |
12 | |
13 void IIRDSPKernel::process(const float* source, float* destination, size_t frame sToProcess) | |
14 { | |
15 ASSERT(source); | |
16 ASSERT(destination); | |
17 | |
18 m_iir.process(source, destination, framesToProcess); | |
19 } | |
20 | |
21 void IIRDSPKernel::getFrequencyResponse(int nFrequencies, const float* frequency Hz, float* magResponse, float* phaseResponse) | |
22 { | |
23 bool isGood = nFrequencies > 0 && frequencyHz && magResponse && phaseRespons e; | |
24 ASSERT(isGood); | |
25 if (!isGood) | |
26 return; | |
27 | |
28 Vector<float> frequency(nFrequencies); | |
29 | |
30 double nyquist = this->nyquist(); | |
31 | |
32 // Convert from frequency in Hz to normalized frequency (0 -> 1), | |
33 // with 1 equal to the Nyquist frequency. | |
34 for (int k = 0; k < nFrequencies; ++k) | |
35 frequency[k] = narrowPrecisionToFloat(frequencyHz[k] / nyquist); | |
36 | |
37 m_iir.getFrequencyResponse(nFrequencies, frequency.data(), magResponse, phas eResponse); | |
38 } | |
39 | |
40 double IIRDSPKernel::tailTime() const | |
41 { | |
42 // This is true mathematically (infinite impulse response), but perhaps it s hould 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.
| |
43 // a smaller value, possibly based on the actual filter coefficients. To do that, we would | |
44 // probably need to find the pole, r, with largest magnitude and select some threshold, eps, | |
45 // such that |r|^n < eps for all n >= N. N is then the tailTime for the fil ter. | |
46 return std::numeric_limits<double>::infinity(); | |
47 } | |
48 | |
49 double IIRDSPKernel::latencyTime() const | |
50 { | |
51 return 0; | |
52 } | |
53 | |
54 } // blink | |
OLD | NEW |