Fix an off-by-two in the filter cutoff.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 13 Mar 2015 21:47:17 +0000 (22:47 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 13 Mar 2015 21:47:17 +0000 (22:47 +0100)
decode.cpp
level.cpp

index d1b291f..ef8630d 100644 (file)
@@ -342,7 +342,7 @@ std::vector<float> do_rc_filter(const std::vector<float>& pcm, float freq, int s
 {
        std::vector<float> filtered_pcm;
        filtered_pcm.resize(pcm.size());
 {
        std::vector<float> filtered_pcm;
        filtered_pcm.resize(pcm.size());
-       Filter filter = Filter::hpf(M_PI * freq / sample_rate);
+       Filter filter = Filter::hpf(2.0 * M_PI * freq / sample_rate);
        for (unsigned i = 0; i < pcm.size(); ++i) {
                filtered_pcm[i] = filter.update(pcm[i]);
        }
        for (unsigned i = 0; i < pcm.size(); ++i) {
                filtered_pcm[i] = filter.update(pcm[i]);
        }
index 6e63d26..46a494f 100644 (file)
--- a/level.cpp
+++ b/level.cpp
@@ -28,7 +28,7 @@ std::vector<float> level_samples(const std::vector<float> &pcm, float min_level,
        refiltered_samples.resize(pcm.size());
        leveled_samples.resize(pcm.size());
 
        refiltered_samples.resize(pcm.size());
        leveled_samples.resize(pcm.size());
 
-       Filter filter = Filter::lpf(M_PI * LPFILTER_FREQ / sample_rate);
+       Filter filter = Filter::lpf(2.0 * M_PI * LPFILTER_FREQ / sample_rate);
        for (unsigned i = 0; i < pcm.size(); ++i) {
                filtered_samples[i] = filter.update(fabs(pcm[i]));
        }
        for (unsigned i = 0; i < pcm.size(); ++i) {
                filtered_samples[i] = filter.update(fabs(pcm[i]));
        }