зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1265395
- Implement new low pass filter equation; r=padenot
If run against the version of the test using the old equations, 18 of the 26460 values would be larger than the maximum difference threshold, so I updated the test code to use the new equations as well. I also had to make a small increase to the maximum allowable glitch for the tail test. MozReview-Commit-ID: LrB3HufFWpJ --HG-- extra : rebase_source : 5b011653b3c0d8a00c2a96185c703b5457058936
This commit is contained in:
Родитель
b01574924b
Коммит
bdb8a133ee
|
@ -110,22 +110,19 @@ void Biquad::setLowpassParams(double cutoff, double resonance)
|
|||
} else if (cutoff > 0) {
|
||||
// Compute biquad coefficients for lowpass filter
|
||||
resonance = std::max(0.0, resonance); // can't go negative
|
||||
double g = pow(10.0, 0.05 * resonance);
|
||||
double d = sqrt((4 - sqrt(16 - 16 / (g * g))) / 2);
|
||||
double g = pow(10.0, -0.05 * resonance);
|
||||
double w0 = M_PI * cutoff;
|
||||
double cos_w0 = cos(w0);
|
||||
double alpha = 0.5 * sin(w0) * g;
|
||||
|
||||
double theta = M_PI * cutoff;
|
||||
double sn = 0.5 * d * sin(theta);
|
||||
double beta = 0.5 * (1 - sn) / (1 + sn);
|
||||
double gamma = (0.5 + beta) * cos(theta);
|
||||
double alpha = 0.25 * (0.5 + beta - gamma);
|
||||
double b0 = 0.5 * (1.0 - cos_w0);
|
||||
double b1 = 1.0 - cos_w0;
|
||||
double b2 = b0;
|
||||
double a0 = 1.0 + alpha;
|
||||
double a1 = -2.0 * cos_w0;
|
||||
double a2 = 1.0 - alpha;
|
||||
|
||||
double b0 = 2 * alpha;
|
||||
double b1 = 2 * 2 * alpha;
|
||||
double b2 = 2 * alpha;
|
||||
double a1 = 2 * -gamma;
|
||||
double a2 = 2 * beta;
|
||||
|
||||
setNormalizedCoefficients(b0, b1, b2, 1, a1, a2);
|
||||
setNormalizedCoefficients(b0, b1, b2, a0, a1, a2);
|
||||
} else {
|
||||
// When cutoff is zero, nothing gets through the filter, so set
|
||||
// coefficients up correctly.
|
||||
|
|
|
@ -12,6 +12,7 @@ function createLowpassFilter(freq, q, gain) {
|
|||
var b0;
|
||||
var b1;
|
||||
var b2;
|
||||
var a0;
|
||||
var a1;
|
||||
var a2;
|
||||
|
||||
|
@ -21,25 +22,23 @@ function createLowpassFilter(freq, q, gain) {
|
|||
b0 = 1;
|
||||
b1 = 0;
|
||||
b2 = 0;
|
||||
a0 = 1;
|
||||
a1 = 0;
|
||||
a2 = 0;
|
||||
} else {
|
||||
var g = Math.pow(10, q / 20);
|
||||
var d = Math.sqrt((4 - Math.sqrt(16 - 16 / (g * g))) / 2);
|
||||
var theta = Math.PI * freq;
|
||||
var sn = d * Math.sin(theta) / 2;
|
||||
var beta = 0.5 * (1 - sn) / (1 + sn);
|
||||
var gamma = (0.5 + beta) * Math.cos(theta);
|
||||
var alpha = 0.25 * (0.5 + beta - gamma);
|
||||
var w0 = Math.PI * freq;
|
||||
var alpha = 0.5 * Math.sin(w0) / Math.pow(10, q / 20);
|
||||
var cos_w0 = Math.cos(w0);
|
||||
|
||||
b0 = 2 * alpha;
|
||||
b1 = 4 * alpha;
|
||||
b2 = 2 * alpha;
|
||||
a1 = 2 * (-gamma);
|
||||
a2 = 2 * beta;
|
||||
b0 = 0.5 * (1 - cos_w0);
|
||||
b1 = 1 - cos_w0;
|
||||
b2 = b0;
|
||||
a0 = 1 + alpha;
|
||||
a1 = -2.0 * cos_w0;
|
||||
a2 = 1 - alpha;
|
||||
}
|
||||
|
||||
return {b0 : b0, b1 : b1, b2 : b2, a1 : a1, a2 : a2};
|
||||
return normalizeFilterCoefficients(b0, b1, b2, a0, a1, a2);
|
||||
}
|
||||
|
||||
function createHighpassFilter(freq, q, gain) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче