]> git.sesse.net Git - nageru/commitdiff
Update loop filter to take into account ratio; based on email from Fons Adriaensen.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 11 Oct 2015 10:39:26 +0000 (12:39 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 11 Oct 2015 10:39:26 +0000 (12:39 +0200)
resampler.cpp

index 573146541c98cfd646138889acfb636fce18faaa..efa0f178da950680fa55a5c2594b95abc754841c 100644 (file)
@@ -90,14 +90,11 @@ void Resampler::get_output_samples(double pts, float *samples, ssize_t num_sampl
        // The loop bandwidth starts at 1.0 Hz, then goes down to 0.05 Hz after four seconds.
        double loop_bandwidth_hz = (k_a0 < 4 * freq_in) ? 1.0 : 0.05;
 
-       // Set first filter much wider than the first one (20x as wide).
-       double w = (2.0 * M_PI) * 20.0 * loop_bandwidth_hz * num_samples / freq_out;
-       double w0 = 1.0 - exp(-w);
-
-       // Set second filter.
-       w = (2.0 * M_PI) * loop_bandwidth_hz * ratio / freq_out;
-       double w1 = w * 1.6;
-       double w2 = w * num_samples / 1.6;
+       // Set filters. The first filter much wider than the first one (20x as wide).
+       double w = (2.0 * M_PI) * loop_bandwidth_hz * num_samples / freq_out;
+       double w0 = 1.0 - exp(-20.0 * w);
+       double w1 = w * 1.5 / num_samples / ratio;
+       double w2 = w / 1.5;
 
        // Filter <err> through the loop filter to find the correction ratio.
        z1 += w0 * (w1 * err - z1);