OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010, Google Inc. All rights reserved. | 2 * Copyright (C) 2010, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "modules/webaudio/BiquadDSPKernel.h" | 29 #include "modules/webaudio/BiquadDSPKernel.h" |
30 | 30 |
31 #include "core/platform/FloatConversion.h" | 31 #include "core/platform/FloatConversion.h" |
32 #include "modules/webaudio/BiquadProcessor.h" | 32 #include "modules/webaudio/BiquadProcessor.h" |
33 #include <limits.h> | 33 #include <limits.h> |
34 #include "wtf/Vector.h" | 34 #include "wtf/Vector.h" |
35 | 35 |
36 namespace WebCore { | 36 namespace WebCore { |
37 | 37 |
38 // FIXME: As a recursive linear filter, depending on its parameters, a biquad fi
lter can have | 38 // FIXME: As a recursive linear filter, depending on its parameters, a biquad fi
lter can have |
39 // an infinite tailTime. In practice, Biquad filters do not usually (except for
very high resonance values) | 39 // an infinite tailTime. In practice, Biquad filters do not usually (except for
very high resonance values) |
40 // have a tailTime of longer than approx. 200ms. This value could possibly be ca
lculated based on the | 40 // have a tailTime of longer than approx. 200ms. This value could possibly be ca
lculated based on the |
41 // settings of the Biquad. | 41 // settings of the Biquad. |
42 static const double MaxBiquadDelayTime = 0.2; | 42 static const double MaxBiquadDelayTime = 0.2; |
43 | 43 |
44 void BiquadDSPKernel::updateCoefficientsIfNecessary(bool useSmoothing, bool forc
eUpdate) | 44 void BiquadDSPKernel::updateCoefficientsIfNecessary(bool useSmoothing, bool forc
eUpdate) |
45 { | 45 { |
46 if (forceUpdate || biquadProcessor()->filterCoefficientsDirty()) { | 46 if (forceUpdate || biquadProcessor()->filterCoefficientsDirty()) { |
47 double value1; | 47 double value1; |
48 double value2; | 48 double value2; |
49 double gain; | 49 double gain; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 case BiquadProcessor::Allpass: | 107 case BiquadProcessor::Allpass: |
108 m_biquad.setAllpassParams(normalizedFrequency, value2); | 108 m_biquad.setAllpassParams(normalizedFrequency, value2); |
109 break; | 109 break; |
110 } | 110 } |
111 } | 111 } |
112 } | 112 } |
113 | 113 |
114 void BiquadDSPKernel::process(const float* source, float* destination, size_t fr
amesToProcess) | 114 void BiquadDSPKernel::process(const float* source, float* destination, size_t fr
amesToProcess) |
115 { | 115 { |
116 ASSERT(source && destination && biquadProcessor()); | 116 ASSERT(source && destination && biquadProcessor()); |
117 | 117 |
118 // Recompute filter coefficients if any of the parameters have changed. | 118 // Recompute filter coefficients if any of the parameters have changed. |
119 // FIXME: as an optimization, implement a way that a Biquad object can simpl
y copy its internal filter coefficients from another Biquad object. | 119 // FIXME: as an optimization, implement a way that a Biquad object can simpl
y copy its internal filter coefficients from another Biquad object. |
120 // Then re-factor this code to only run for the first BiquadDSPKernel of eac
h BiquadProcessor. | 120 // Then re-factor this code to only run for the first BiquadDSPKernel of eac
h BiquadProcessor. |
121 | 121 |
122 updateCoefficientsIfNecessary(true, false); | 122 updateCoefficientsIfNecessary(true, false); |
123 | 123 |
124 m_biquad.process(source, destination, framesToProcess); | 124 m_biquad.process(source, destination, framesToProcess); |
125 } | 125 } |
126 | 126 |
127 void BiquadDSPKernel::getFrequencyResponse(int nFrequencies, | 127 void BiquadDSPKernel::getFrequencyResponse(int nFrequencies, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 } | 159 } |
160 | 160 |
161 double BiquadDSPKernel::latencyTime() const | 161 double BiquadDSPKernel::latencyTime() const |
162 { | 162 { |
163 return 0; | 163 return 0; |
164 } | 164 } |
165 | 165 |
166 } // namespace WebCore | 166 } // namespace WebCore |
167 | 167 |
168 #endif // ENABLE(WEB_AUDIO) | 168 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |