diff --git a/sdrbase/dsp/fftfilt.cpp b/sdrbase/dsp/fftfilt.cpp index 8d2391a13..cfc0141d0 100644 --- a/sdrbase/dsp/fftfilt.cpp +++ b/sdrbase/dsp/fftfilt.cpp @@ -159,46 +159,6 @@ void fftfilt::create_filter(float f1, float f2, FFTWindow::Function wf) } } -void fftfilt::create_filter(const std::vector>& limits, bool pass) -{ - // initialize the filter canvas - std::vector canvas(flen, pass ? 0 : 1); - fftfilt::cmplx* xfilter = new fftfilt::cmplx[flen]; - - for (const auto& fs : limits) - { - const float& f1 = fs.first + 0.5; - const float& w = fs.second > 0.0 ? fs.second : 0.0; - const float& f2 = f1 + w; - - for (int i = 0; i < flen; i++) - { - if (pass) // pass - { - if ((i >= f1*flen) && (i <= f2*flen)) { - canvas[i] = 1; - } - } - else // reject - { - if ((i >= f1*flen) && (i <= f2*flen)) { - canvas[i] = 0; - } - } - } - } - - for (int i = 0; i < flen; i++) { - xfilter[i] = cmplx(canvas[i], 0); - } - - // Rearrange - std::copy(&xfilter[flen2], &xfilter[flen-1], filter); - std::copy(&xfilter[0], &xfilter[flen2-1], &filter[flen2]); - - delete[] xfilter; -} - void fftfilt::create_filter(const std::vector>& limits, bool pass, FFTWindow::Function wf) { std::vector canvasNeg(flen2, pass ? 0 : 1); // initialize the negative frequencies filter canvas @@ -281,6 +241,10 @@ void fftfilt::create_filter(const std::vector>& limits, filter[i] -= fsinc(f1, i, flen2); } } + + if (f2 == 0 && f1 != 0) { + filter[flen2 / 2] += 1; + } } for (const auto& indexes : indexesNegList) @@ -297,6 +261,10 @@ void fftfilt::create_filter(const std::vector>& limits, filterOpp[i] -= fsinc(f1, i, flen2); } } + + if (f2 == 0 && f1 != 0) { + filterOpp[flen2 / 2] += 1; + } } FFTWindow fwin;