Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
|
tkent
2016/01/13 03:28:28
2016
Raymond Toy
2016/01/13 18:30:53
Done.
| |
| 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 "modules/webaudio/IIRDSPKernel.h" | |
| 6 | |
| 7 #include "platform/FloatConversion.h" | |
| 8 | |
| 9 namespace blink { | |
| 10 | |
| 11 void IIRDSPKernel::process(const float* source, float* destination, size_t frame sToProcess) | |
| 12 { | |
| 13 ASSERT(source); | |
| 14 ASSERT(destination); | |
| 15 | |
| 16 m_iir.process(source, destination, framesToProcess); | |
| 17 } | |
| 18 | |
| 19 void IIRDSPKernel::getFrequencyResponse(int nFrequencies, const float* frequency Hz, float* magResponse, float* phaseResponse) | |
| 20 { | |
| 21 bool isGood = nFrequencies > 0 && frequencyHz && magResponse && phaseRespons e; | |
| 22 ASSERT(isGood); | |
| 23 if (!isGood) | |
| 24 return; | |
| 25 | |
| 26 Vector<float> frequency(nFrequencies); | |
| 27 | |
| 28 double nyquist = this->nyquist(); | |
| 29 | |
| 30 // Convert from frequency in Hz to normalized frequency (0 -> 1), | |
| 31 // with 1 equal to the Nyquist frequency. | |
| 32 for (int k = 0; k < nFrequencies; ++k) | |
| 33 frequency[k] = narrowPrecisionToFloat(frequencyHz[k] / nyquist); | |
| 34 | |
| 35 m_iir.getFrequencyResponse(nFrequencies, frequency.data(), magResponse, phas eResponse); | |
| 36 } | |
| 37 | |
| 38 double IIRDSPKernel::tailTime() const | |
| 39 { | |
| 40 // TODO(rtoy): This is true mathematically (infinite impulse response), but perhaps it should be | |
| 41 // limited to a smaller value, possibly based on the actual filter coefficie nts. To do that, we | |
| 42 // would probably need to find the pole, r, with largest magnitude and selec t some threshold, | |
| 43 // eps, such that |r|^n < eps for all n >= N. N is then the tailTime for th e filter. If the | |
| 44 // the magnitude of r is greater than or equal to 1, the infinity is the rig ht answer. (There is | |
| 45 // no constraint on the IIR filter that it be stable.) | |
| 46 return std::numeric_limits<double>::infinity(); | |
| 47 } | |
| 48 | |
| 49 double IIRDSPKernel::latencyTime() const | |
| 50 { | |
| 51 return 0; | |
| 52 } | |
| 53 | |
| 54 } // blink | |
|
tkent
2016/01/13 03:28:28
nit: blink -> namespace blink
Raymond Toy
2016/01/13 18:30:53
Done.
| |
| OLD | NEW |