Title: [129277] trunk/Source/WebCore
Revision
129277
Author
[email protected]
Date
2012-09-21 16:58:16 -0700 (Fri, 21 Sep 2012)

Log Message

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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (129276 => 129277)


--- trunk/Source/WebCore/ChangeLog	2012-09-21 23:58:05 UTC (rev 129276)
+++ trunk/Source/WebCore/ChangeLog	2012-09-21 23:58:16 UTC (rev 129277)
@@ -1,3 +1,23 @@
+2012-09-21  Chris Rogers  <[email protected]>
+
+        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  <[email protected]>
 
         Add support for OES_vertex_array_object in chromium

Modified: trunk/Source/WebCore/Modules/webaudio/BiquadDSPKernel.cpp (129276 => 129277)


--- trunk/Source/WebCore/Modules/webaudio/BiquadDSPKernel.cpp	2012-09-21 23:58:05 UTC (rev 129276)
+++ trunk/Source/WebCore/Modules/webaudio/BiquadDSPKernel.cpp	2012-09-21 23:58:16 UTC (rev 129277)
@@ -47,8 +47,12 @@
         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();

Modified: trunk/Source/WebCore/Modules/webaudio/BiquadProcessor.cpp (129276 => 129277)


--- trunk/Source/WebCore/Modules/webaudio/BiquadProcessor.cpp	2012-09-21 23:58:05 UTC (rev 129276)
+++ trunk/Source/WebCore/Modules/webaudio/BiquadProcessor.cpp	2012-09-21 23:58:16 UTC (rev 129277)
@@ -68,21 +68,27 @@
 
     // 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;
+        }
     }
 }
 

Modified: trunk/Source/WebCore/Modules/webaudio/BiquadProcessor.h (129276 => 129277)


--- trunk/Source/WebCore/Modules/webaudio/BiquadProcessor.h	2012-09-21 23:58:05 UTC (rev 129276)
+++ trunk/Source/WebCore/Modules/webaudio/BiquadProcessor.h	2012-09-21 23:58:16 UTC (rev 129277)
@@ -67,6 +67,7 @@
     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 @@
 
     // 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
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to