Title: [88072] trunk/Source/WebCore
Revision
88072
Author
[email protected]
Date
2011-06-03 15:52:41 -0700 (Fri, 03 Jun 2011)

Log Message

2011-06-03  Chris Rogers  <[email protected]>

        Reviewed by Kenneth Russell.

        Biquad filter coefficient naming is incorrect
        https://bugs.webkit.org/show_bug.cgi?id=62053

        No new tests since audio API is not yet implemented.

        * platform/audio/Biquad.cpp:
        (WebCore::Biquad::Biquad):
        (WebCore::Biquad::process):
        (WebCore::Biquad::processFast):
        (WebCore::Biquad::setLowpassParams):
        (WebCore::Biquad::setHighpassParams):
        (WebCore::Biquad::setLowShelfParams):
        (WebCore::Biquad::setZeroPolePairs):
        * platform/audio/Biquad.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (88071 => 88072)


--- trunk/Source/WebCore/ChangeLog	2011-06-03 22:42:58 UTC (rev 88071)
+++ trunk/Source/WebCore/ChangeLog	2011-06-03 22:52:41 UTC (rev 88072)
@@ -1,3 +1,22 @@
+2011-06-03  Chris Rogers  <[email protected]>
+
+        Reviewed by Kenneth Russell.
+
+        Biquad filter coefficient naming is incorrect
+        https://bugs.webkit.org/show_bug.cgi?id=62053
+
+        No new tests since audio API is not yet implemented.
+
+        * platform/audio/Biquad.cpp:
+        (WebCore::Biquad::Biquad):
+        (WebCore::Biquad::process):
+        (WebCore::Biquad::processFast):
+        (WebCore::Biquad::setLowpassParams):
+        (WebCore::Biquad::setHighpassParams):
+        (WebCore::Biquad::setLowShelfParams):
+        (WebCore::Biquad::setZeroPolePairs):
+        * platform/audio/Biquad.h:
+
 2011-06-03  Adam Barth  <[email protected]>
 
         Reviewed by Eric Seidel.

Modified: trunk/Source/WebCore/platform/audio/Biquad.cpp (88071 => 88072)


--- trunk/Source/WebCore/platform/audio/Biquad.cpp	2011-06-03 22:42:58 UTC (rev 88071)
+++ trunk/Source/WebCore/platform/audio/Biquad.cpp	2011-06-03 22:52:41 UTC (rev 88072)
@@ -53,14 +53,12 @@
 #endif
 
     // Initialize as pass-thru (straight-wire, no filter effect)
-    m_a0 = 1.0;
-    m_a1 = 0.0;
-    m_a2 = 0.0;
+    m_b0 = 1.0;
     m_b1 = 0.0;
     m_b2 = 0.0;
+    m_a1 = 0.0;
+    m_a2 = 0.0;
 
-    m_g = 1.0;
-
     reset(); // clear filter memory
 }
 
@@ -78,19 +76,17 @@
     double y1 = m_y1;
     double y2 = m_y2;
 
-    double a0 = m_a0;
-    double a1 = m_a1;
-    double a2 = m_a2;
+    double b0 = m_b0;
     double b1 = m_b1;
     double b2 = m_b2;
+    double a1 = m_a1;
+    double a2 = m_a2;
 
     while (n--) {
         // FIXME: this can be optimized by pipelining the multiply adds...
         float x = *sourceP++;
-        float y = a0*x + a1*x1 + a2*x2 - b1*y1 - b2*y2;
+        float y = b0*x + b1*x1 + b2*x2 - a1*y1 - a2*y2;
 
-        y *= m_g;
-
         *destP++ = y;
 
         // Update state variables
@@ -106,11 +102,11 @@
     m_y1 = y1;
     m_y2 = y2;
 
-    m_a0 = a0;
-    m_a1 = a1;
-    m_a2 = a2;
+    m_b0 = b0;
     m_b1 = b1;
     m_b2 = b2;
+    m_a1 = a1;
+    m_a2 = a2;
 #endif
 }
 
@@ -120,13 +116,12 @@
 
 void Biquad::processFast(const float* sourceP, float* destP, size_t framesToProcess)
 {
-    // Filter coefficients
-    double B[5];
-    B[0] = m_a0;
-    B[1] = m_a1;
-    B[2] = m_a2;
-    B[3] = m_b1;
-    B[4] = m_b2;
+    double filterCoefficients[5];
+    filterCoefficients[0] = m_b0;
+    filterCoefficients[1] = m_b1;
+    filterCoefficients[2] = m_b2;
+    filterCoefficients[3] = m_a1;
+    filterCoefficients[4] = m_a2;
 
     double* inputP = m_inputBuffer.data();
     double* outputP = m_outputBuffer.data();
@@ -145,7 +140,7 @@
         for (int i = 0; i < framesThisTime; ++i)
             input2P[i] = *sourceP++;
 
-        processSliceFast(inputP, outputP, B, framesThisTime);
+        processSliceFast(inputP, outputP, filterCoefficients, framesThisTime);
 
         // Copy output buffer to output (converts float -> double).
         for (int i = 0; i < framesThisTime; ++i)
@@ -202,11 +197,11 @@
     double gamma = (0.5 + beta) * cos(theta);
     double alpha = 0.25 * (0.5 + beta - gamma);
 
-    m_a0 = 2.0 * alpha;
-    m_a1 = 2.0 * 2.0*alpha;
-    m_a2 = 2.0 * alpha;
-    m_b1 = 2.0 * -gamma;
-    m_b2 = 2.0 * beta;
+    m_b0 = 2.0 * alpha;
+    m_b1 = 2.0 * 2.0*alpha;
+    m_b2 = 2.0 * alpha;
+    m_a1 = 2.0 * -gamma;
+    m_a2 = 2.0 * beta;
 }
 
 void Biquad::setHighpassParams(double cutoff, double resonance)
@@ -223,11 +218,11 @@
     double gamma = (0.5 + beta) * cos(theta);
     double alpha = 0.25 * (0.5 + beta + gamma);
 
-    m_a0 = 2.0 * alpha;
-    m_a1 = 2.0 * -2.0*alpha;
-    m_a2 = 2.0 * alpha;
-    m_b1 = 2.0 * -gamma;
-    m_b2 = 2.0 * beta;
+    m_b0 = 2.0 * alpha;
+    m_b1 = 2.0 * -2.0*alpha;
+    m_b2 = 2.0 * alpha;
+    m_a1 = 2.0 * -gamma;
+    m_a2 = 2.0 * beta;
 }
 
 void Biquad::setLowShelfParams(double cutoff, double dbGain)
@@ -250,25 +245,25 @@
 
     double a0Inverse = 1.0 / a0;
     
-    m_a0 = b0 * a0Inverse;
-    m_a1 = b1 * a0Inverse;
-    m_a2 = b2 * a0Inverse;
-    m_b1 = a1 * a0Inverse;
-    m_b2 = a2 * a0Inverse;
+    m_b0 = b0 * a0Inverse;
+    m_b1 = b1 * a0Inverse;
+    m_b2 = b2 * a0Inverse;
+    m_a1 = a1 * a0Inverse;
+    m_a2 = a2 * a0Inverse;
 }
 
 void Biquad::setZeroPolePairs(const Complex &zero, const Complex &pole)
 {
-    m_a0 = 1.0;
-    m_a1 = -2.0 * zero.real();
+    m_b0 = 1.0;
+    m_b1 = -2.0 * zero.real();
 
     double zeroMag = abs(zero);
-    m_a2 = zeroMag * zeroMag;
+    m_b2 = zeroMag * zeroMag;
 
-    m_b1 = -2.0 * pole.real();
+    m_a1 = -2.0 * pole.real();
 
     double poleMag = abs(pole);
-    m_b2 = poleMag * poleMag;
+    m_a2 = poleMag * poleMag;
 }
 
 void Biquad::setAllpassPole(const Complex &pole)

Modified: trunk/Source/WebCore/platform/audio/Biquad.h (88071 => 88072)


--- trunk/Source/WebCore/platform/audio/Biquad.h	2011-06-03 22:42:58 UTC (rev 88071)
+++ trunk/Source/WebCore/platform/audio/Biquad.h	2011-06-03 22:52:41 UTC (rev 88072)
@@ -71,14 +71,12 @@
 
 private:
     // Filter coefficients
-    double m_a0;
-    double m_a1;
-    double m_a2;
+    double m_b0;
     double m_b1;
     double m_b2;
+    double m_a1;
+    double m_a2;
 
-    double m_g;
-
     // Filter memory
     double m_x1; // input delayed by 1 sample
     double m_x2; // input delayed by 2 samples
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to