From f40d030e2ef3c3f85673cf9382e3d579269fc3a4 Mon Sep 17 00:00:00 2001 From: f4exb Date: Wed, 15 Mar 2017 15:37:51 +0100 Subject: [PATCH] FFT filter: SSB filter leave DC component by default in both USB and LSB. Option to remove DC in both --- sdrbase/dsp/fftfilt.cxx | 15 +++++++++++---- sdrbase/dsp/fftfilt.h | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/sdrbase/dsp/fftfilt.cxx b/sdrbase/dsp/fftfilt.cxx index 5a7ea33ac..f11776b53 100644 --- a/sdrbase/dsp/fftfilt.cxx +++ b/sdrbase/dsp/fftfilt.cxx @@ -199,7 +199,7 @@ int fftfilt::runFilt(const cmplx & in, cmplx **out) } // Second version for single sideband -int fftfilt::runSSB(const cmplx & in, cmplx **out, bool usb) +int fftfilt::runSSB(const cmplx & in, cmplx **out, bool usb, bool getDC) { data[inptr++] = in; if (inptr < flen2) @@ -208,17 +208,24 @@ int fftfilt::runSSB(const cmplx & in, cmplx **out, bool usb) fft->ComplexFFT(data); + // get or reject DC component + data[0] = getDC ? data[0]*filter[0] : 0; + // Discard frequencies for ssb - if ( usb ) - for (int i = 0; i < flen2; i++) { + if (usb) + { + for (int i = 1; i < flen2; i++) { data[i] *= filter[i]; data[flen2 + i] = 0; } + } else - for (int i = 0; i < flen2; i++) { + { + for (int i = 1; i < flen2; i++) { data[i] = 0; data[flen2 + i] *= filter[flen2 + i]; } + } // in-place FFT: freqdata overwritten with filtered timedata fft->InverseComplexFFT(data); diff --git a/sdrbase/dsp/fftfilt.h b/sdrbase/dsp/fftfilt.h index 4af4613fb..903bb5b46 100644 --- a/sdrbase/dsp/fftfilt.h +++ b/sdrbase/dsp/fftfilt.h @@ -26,7 +26,7 @@ public: int noFilt(const cmplx& in, cmplx **out); int runFilt(const cmplx& in, cmplx **out); - int runSSB(const cmplx& in, cmplx **out, bool usb); + int runSSB(const cmplx& in, cmplx **out, bool usb, bool getDC = true); int runDSB(const cmplx& in, cmplx **out); protected: