| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/webaudio/IIRDSPKernel.h" | 5 #include "modules/webaudio/IIRDSPKernel.h" |
| 6 | 6 |
| 7 #include "wtf/MathExtras.h" | 7 #include "wtf/MathExtras.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 // Convert from frequency in Hz to normalized frequency (0 -> 1), | 33 // Convert from frequency in Hz to normalized frequency (0 -> 1), |
| 34 // with 1 equal to the Nyquist frequency. | 34 // with 1 equal to the Nyquist frequency. |
| 35 for (int k = 0; k < nFrequencies; ++k) | 35 for (int k = 0; k < nFrequencies; ++k) |
| 36 frequency[k] = clampTo<float>(frequencyHz[k] / nyquist); | 36 frequency[k] = clampTo<float>(frequencyHz[k] / nyquist); |
| 37 | 37 |
| 38 m_iir.getFrequencyResponse(nFrequencies, frequency.data(), magResponse, | 38 m_iir.getFrequencyResponse(nFrequencies, frequency.data(), magResponse, |
| 39 phaseResponse); | 39 phaseResponse); |
| 40 } | 40 } |
| 41 | 41 |
| 42 double IIRDSPKernel::tailTime() const { | 42 double IIRDSPKernel::tailTime() const { |
| 43 // TODO(rtoy): This is true mathematically (infinite impulse response), but pe
rhaps it should be | 43 // TODO(rtoy): This is true mathematically (infinite impulse response), but |
| 44 // limited to a smaller value, possibly based on the actual filter coefficient
s. To do that, we | 44 // perhaps it should be limited to a smaller value, possibly based on the |
| 45 // would probably need to find the pole, r, with largest magnitude and select
some threshold, | 45 // actual filter coefficients. To do that, we would probably need to find the |
| 46 // eps, such that |r|^n < eps for all n >= N. N is then the tailTime for the
filter. If the | 46 // pole, r, with largest magnitude and select some threshold, eps, such that |
| 47 // the magnitude of r is greater than or equal to 1, the infinity is the right
answer. (There is | 47 // |r|^n < eps for all n >= N. N is then the tailTime for the filter. If the |
| 48 // no constraint on the IIR filter that it be stable.) | 48 // the magnitude of r is greater than or equal to 1, the infinity is the right |
| 49 // answer. (There is no constraint on the IIR filter that it be stable.) |
| 49 return std::numeric_limits<double>::infinity(); | 50 return std::numeric_limits<double>::infinity(); |
| 50 } | 51 } |
| 51 | 52 |
| 52 double IIRDSPKernel::latencyTime() const { | 53 double IIRDSPKernel::latencyTime() const { |
| 53 return 0; | 54 return 0; |
| 54 } | 55 } |
| 55 | 56 |
| 56 } // namespace blink | 57 } // namespace blink |
| OLD | NEW |