diff --git a/include-gpl/dsp/fftfilt.h b/include-gpl/dsp/fftfilt.h index e135fcdfd..0f76d683a 100644 --- a/include-gpl/dsp/fftfilt.h +++ b/include-gpl/dsp/fftfilt.h @@ -48,7 +48,8 @@ public: void create_filter(float f1, float f2); void rtty_filter(float); - int run(const cmplx& in, cmplx **out, bool usb); + int runFilt(const cmplx& in, cmplx **out); + int runSSB(const cmplx& in, cmplx **out, bool usb); }; #endif diff --git a/plugins/channel/ssb/ssbdemod.cpp b/plugins/channel/ssb/ssbdemod.cpp index 91d2721bd..6b53a33af 100644 --- a/plugins/channel/ssb/ssbdemod.cpp +++ b/plugins/channel/ssb/ssbdemod.cpp @@ -67,7 +67,7 @@ void SSBDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iter c *= m_nco.nextIQ(); if(m_interpolator.interpolate(&m_sampleDistanceRemain, c, &ci)) { - n_out = SSBFilter->run(ci, &sideband, m_usb); + n_out = SSBFilter->runSSB(ci, &sideband, m_usb); m_sampleDistanceRemain += (Real)m_sampleRate / 48000.0; } else n_out = 0; diff --git a/plugins/channel/tcpsrc/tcpsrc.cpp b/plugins/channel/tcpsrc/tcpsrc.cpp index 2240214bb..574663298 100644 --- a/plugins/channel/tcpsrc/tcpsrc.cpp +++ b/plugins/channel/tcpsrc/tcpsrc.cpp @@ -73,7 +73,7 @@ void TCPSrc::feed(SampleVector::const_iterator begin, SampleVector::const_iterat if(m_ssbSockets.count() > 0) { for(SampleVector::const_iterator it = m_sampleBuffer.begin(); it != m_sampleBuffer.end(); ++it) { Complex cj(it->real() / 20000.0, it->imag() / 20000.0); - int n_out = TCPFilter->run(cj, &sideband, true); + int n_out = TCPFilter->runSSB(cj, &sideband, true); if (n_out) { for (int i = 0; i < n_out; i+=2) { Real one = (sideband[i].real() + sideband[i].imag()) * 0.7 * 32000.0; diff --git a/plugins/channel/usb/usbdemod.cpp b/plugins/channel/usb/usbdemod.cpp index 5a7656cc5..0733480f2 100644 --- a/plugins/channel/usb/usbdemod.cpp +++ b/plugins/channel/usb/usbdemod.cpp @@ -89,11 +89,11 @@ void USBDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iter b = it->imag(); c = Complex(a / 65536.0, b / 65536.0); - n_out = USBFilter->run(c, &sideband, true); + n_out = USBFilter->runSSB(c, &sideband, true); if (m_sampleRate <= 72000) - n_out += USBFilter->run(c, &sideband, true); + n_out += USBFilter->runSSB(c, &sideband, true); if (m_sampleRate == 64000) - n_out += USBFilter->run(c, &sideband, true); + n_out += USBFilter->runSSB(c, &sideband, true); for (i = m_i ; i < n_out; i += samplestep) { Real demod = (sideband[i].real() + sideband[i].imag()) * 32768.0; diff --git a/sdrbase/dsp/fftfilt.cxx b/sdrbase/dsp/fftfilt.cxx index 1c4acf9d8..c856ee27d 100644 --- a/sdrbase/dsp/fftfilt.cxx +++ b/sdrbase/dsp/fftfilt.cxx @@ -144,7 +144,31 @@ void fftfilt::create_filter(float f1, float f2) } // Filter with fast convolution (overlap-add algorithm). -int fftfilt::run(const cmplx & in, cmplx **out, bool usb) +int fftfilt::runFilt(const cmplx & in, cmplx **out) +{ + timedata[inptr++] = in; + if (inptr < flen2) + return 0; + inptr = 0; + + memcpy(freqdata, timedata, flen * sizeof(cmplx)); + fft->ComplexFFT(freqdata); + for (int i = 0; i < flen; i++) + freqdata[i] *= filter[i]; + + fft->InverseComplexFFT(freqdata); + + for (int i = 0; i < flen2; i++) { + output[i] = ovlbuf[i] + freqdata[i]; + ovlbuf[i] = freqdata[flen2 + i]; + } + + *out = output; + return flen2; +} + +// Second version for single sideband +int fftfilt::runSSB(const cmplx & in, cmplx **out, bool usb) { timedata[inptr++] = in;