Commit 04bd8fcc authored by crogers@google.com's avatar crogers@google.com
Browse files

BiquadFilterNode must take audio-rate parameter changes into account

https://bugs.webkit.org/show_bug.cgi?id=97369

Reviewed by Kenneth Russell.

BiquadFilterNode is currently ignoring any timeline or audio-rate changes to its parameters.
We now check if any of its parameters have timeline or audio-rate changes and, if so, take
them into account.  Otherwise, we use ordinary parameter smoothing/de-zippering which is
the case when the parameters are adjusted, for example, from a knob or slider in the UI.

* Modules/webaudio/BiquadDSPKernel.cpp:
(WebCore::BiquadDSPKernel::updateCoefficientsIfNecessary):
* Modules/webaudio/BiquadProcessor.cpp:
(WebCore::BiquadProcessor::checkForDirtyCoefficients):
* Modules/webaudio/BiquadProcessor.h:
(WebCore::BiquadProcessor::hasSampleAccurateValues):
(BiquadProcessor):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@129277 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 599dc6c5
2012-09-21 Chris Rogers <crogers@google.com>
BiquadFilterNode must take audio-rate parameter changes into account
https://bugs.webkit.org/show_bug.cgi?id=97369
Reviewed by Kenneth Russell.
BiquadFilterNode is currently ignoring any timeline or audio-rate changes to its parameters.
We now check if any of its parameters have timeline or audio-rate changes and, if so, take
them into account. Otherwise, we use ordinary parameter smoothing/de-zippering which is
the case when the parameters are adjusted, for example, from a knob or slider in the UI.
* Modules/webaudio/BiquadDSPKernel.cpp:
(WebCore::BiquadDSPKernel::updateCoefficientsIfNecessary):
* Modules/webaudio/BiquadProcessor.cpp:
(WebCore::BiquadProcessor::checkForDirtyCoefficients):
* Modules/webaudio/BiquadProcessor.h:
(WebCore::BiquadProcessor::hasSampleAccurateValues):
(BiquadProcessor):
2012-09-21 Brandon Jones <bajones@google.com>
 
Add support for OES_vertex_array_object in chromium
......@@ -47,8 +47,12 @@ void BiquadDSPKernel::updateCoefficientsIfNecessary(bool useSmoothing, bool forc
double value1;
double value2;
double gain;
if (useSmoothing) {
if (biquadProcessor()->hasSampleAccurateValues()) {
value1 = biquadProcessor()->parameter1()->finalValue();
value2 = biquadProcessor()->parameter2()->finalValue();
gain = biquadProcessor()->parameter3()->finalValue();
} else if (useSmoothing) {
value1 = biquadProcessor()->parameter1()->smoothedValue();
value2 = biquadProcessor()->parameter2()->smoothedValue();
gain = biquadProcessor()->parameter3()->smoothedValue();
......
......@@ -68,21 +68,27 @@ void BiquadProcessor::checkForDirtyCoefficients()
// The BiquadDSPKernel objects rely on this value to see if they need to re-compute their internal filter coefficients.
m_filterCoefficientsDirty = false;
m_hasSampleAccurateValues = false;
if (m_hasJustReset) {
// Snap to exact values first time after reset, then smooth for subsequent changes.
m_parameter1->resetSmoothedValue();
m_parameter2->resetSmoothedValue();
m_parameter3->resetSmoothedValue();
if (m_parameter1->hasSampleAccurateValues() || m_parameter2->hasSampleAccurateValues() || m_parameter3->hasSampleAccurateValues()) {
m_filterCoefficientsDirty = true;
m_hasJustReset = false;
m_hasSampleAccurateValues = true;
} else {
// Smooth all of the filter parameters. If they haven't yet converged to their target value then mark coefficients as dirty.
bool isStable1 = m_parameter1->smooth();
bool isStable2 = m_parameter2->smooth();
bool isStable3 = m_parameter3->smooth();
if (!(isStable1 && isStable2 && isStable3))
if (m_hasJustReset) {
// Snap to exact values first time after reset, then smooth for subsequent changes.
m_parameter1->resetSmoothedValue();
m_parameter2->resetSmoothedValue();
m_parameter3->resetSmoothedValue();
m_filterCoefficientsDirty = true;
m_hasJustReset = false;
} else {
// Smooth all of the filter parameters. If they haven't yet converged to their target value then mark coefficients as dirty.
bool isStable1 = m_parameter1->smooth();
bool isStable2 = m_parameter2->smooth();
bool isStable3 = m_parameter3->smooth();
if (!(isStable1 && isStable2 && isStable3))
m_filterCoefficientsDirty = true;
}
}
}
......
......@@ -67,6 +67,7 @@ public:
void checkForDirtyCoefficients();
bool filterCoefficientsDirty() const { return m_filterCoefficientsDirty; }
bool hasSampleAccurateValues() const { return m_hasSampleAccurateValues; }
AudioParam* parameter1() { return m_parameter1.get(); }
AudioParam* parameter2() { return m_parameter2.get(); }
......@@ -84,6 +85,9 @@ private:
// so DSP kernels know when to re-compute coefficients
bool m_filterCoefficientsDirty;
// Set to true if any of the filter parameters are sample-accurate.
bool m_hasSampleAccurateValues;
};
} // namespace WebCore
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment