From ad68f6a06cf62936f44910610cf54568c4fef0ed Mon Sep 17 00:00:00 2001 From: John Greb Date: Mon, 24 Nov 2014 11:01:07 +0000 Subject: [PATCH] Wider maximum waterfall bandwidth. --- plugins/channel/usb/usbdemod.cpp | 14 +++---- plugins/channel/wfm/wfmdemod.cpp | 6 +-- plugins/samplesource/rtlsdr/rtlsdrgui.cpp | 2 +- plugins/samplesource/rtlsdr/rtlsdrinput.cpp | 10 +++-- plugins/samplesource/rtlsdr/rtlsdrthread.cpp | 39 +++++++------------- 5 files changed, 28 insertions(+), 43 deletions(-) diff --git a/plugins/channel/usb/usbdemod.cpp b/plugins/channel/usb/usbdemod.cpp index e6773c0c3..5a7656cc5 100644 --- a/plugins/channel/usb/usbdemod.cpp +++ b/plugins/channel/usb/usbdemod.cpp @@ -55,8 +55,7 @@ void USBDemod::configure(MessageQueue* messageQueue, Real Bandwidth, Real volume /* Fractional Downsample to 48 kHz. * 192 1:4 (3072 / 16) - * 144 1:3 (2304 / 16) - * 120 2:5 (1920 / 16) + * 144 1:3 (1152 / 8) * 96 1:2 (1536 / 16) * 72 2:3 ( 288 / 4) * 64 3:4 (1024 / 16) @@ -66,8 +65,7 @@ double rerate(int rate) switch (rate) { case 64000 : return (3.0 * 64000); break; - case 72000 : - case 120000: return (2.0 * rate); break; + case 72000 : return (2.0 * 72000); break; case 0 : return (1.0 ) ; break; default : return (1.0 * rate ); break; } @@ -82,11 +80,9 @@ void USBDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iter int samplestep = 2; if ((m_sampleRate == 72000)||(m_sampleRate == 144000)) - samplestep = 3; // !! FFT buffer length is a power of two + samplestep = 3; if ((m_sampleRate == 64000)||(m_sampleRate == 192000)) - samplestep = 4; // buffer length should be good - if (m_sampleRate == 120000) - samplestep = 5; + samplestep = 4; for(SampleVector::const_iterator it = begin; it < end; it ++) { a = it->real(); @@ -94,7 +90,7 @@ void USBDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iter c = Complex(a / 65536.0, b / 65536.0); n_out = USBFilter->run(c, &sideband, true); - if ((m_sampleRate <= 72000)||(m_sampleRate == 120000)) + if (m_sampleRate <= 72000) n_out += USBFilter->run(c, &sideband, true); if (m_sampleRate == 64000) n_out += USBFilter->run(c, &sideband, true); diff --git a/plugins/channel/wfm/wfmdemod.cpp b/plugins/channel/wfm/wfmdemod.cpp index c1b1703a2..13bbe66c9 100644 --- a/plugins/channel/wfm/wfmdemod.cpp +++ b/plugins/channel/wfm/wfmdemod.cpp @@ -60,12 +60,12 @@ void WFMDemod::feed(SampleVector::const_iterator begin, SampleVector::const_iter Complex c(it->real() , it->imag()); Complex d = c * conj(m_lastSample); m_lastSample = c; - demod = atan2(d.imag(), d.real()) * (1 /M_PI); - Complex e(demod, 0); + demod = atan2(d.imag(), d.real()); + Complex e(demod * 3000 / M_PI, 0); consumed = false; if(m_interpolator.interpolate(&m_sampleDistanceRemain, e, &consumed, &ci)) { - sample = (qint16)(3000.0 * ci.real() * m_volume); + sample = (qint16)(ci.real() * m_volume); m_sampleBuffer.push_back(Sample(sample, sample)); m_audioBuffer[m_audioBufferFill].l = sample; m_audioBuffer[m_audioBufferFill].r = sample; diff --git a/plugins/samplesource/rtlsdr/rtlsdrgui.cpp b/plugins/samplesource/rtlsdr/rtlsdrgui.cpp index d1bfde6ab..dc06e6697 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrgui.cpp +++ b/plugins/samplesource/rtlsdr/rtlsdrgui.cpp @@ -141,7 +141,7 @@ void RTLSDRGui::on_gain_valueChanged(int value) void RTLSDRGui::on_samplerate_valueChanged(int value) { - int Rates[] = {288, 1024, 1536, 2048, 2304, 2500 }; + int Rates[] = {288, 1024, 1536, 1152, 2048, 2500 }; int newrate = Rates[value]; ui->samplerateText->setText(tr("%1k").arg(newrate)); m_settings.m_samplerate = newrate * 1000; diff --git a/plugins/samplesource/rtlsdr/rtlsdrinput.cpp b/plugins/samplesource/rtlsdr/rtlsdrinput.cpp index d079ede77..601d8b4f1 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrinput.cpp +++ b/plugins/samplesource/rtlsdr/rtlsdrinput.cpp @@ -182,10 +182,12 @@ const QString& RTLSDRInput::getDeviceDescription() const int RTLSDRInput::getSampleRate() const { - int rate = m_settings.m_samplerate / 4; - if (rate < 200000) - return rate; - return (rate / 4); + int rate = m_settings.m_samplerate; + if (rate < 800000) + return (rate / 4); + if ((rate == 1152000) || (rate == 2048000)) + return (rate / 8); + return (rate / 16); } quint64 RTLSDRInput::getCenterFrequency() const diff --git a/plugins/samplesource/rtlsdr/rtlsdrthread.cpp b/plugins/samplesource/rtlsdr/rtlsdrthread.cpp index 0560a74b8..039abe6e4 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrthread.cpp +++ b/plugins/samplesource/rtlsdr/rtlsdrthread.cpp @@ -108,12 +108,14 @@ void RTLSDRThread::decimate8(SampleVector::iterator* it, const quint8* buf, qint for (int pos = 0; pos < len - 15; pos += 8) { xreal = buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]; yimag = buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]; + Sample s1( xreal << 3, yimag << 3 ); pos += 8; - xreal += buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]; - yimag += buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]; + xreal = buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]; + yimag = buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]; + Sample s2( xreal << 3, yimag << 3 ); - Sample s( xreal << 3, yimag << 3 ); - **it = s; + m_decimator2.myDecimate(&s1, &s2); + **it = s2; (*it)++; } } @@ -144,33 +146,18 @@ void RTLSDRThread::decimate16(SampleVector::iterator* it, const quint8* buf, qin -// Decimate everything by 16x, except 288kHz +// Decimate everything by 16x, except 288kHz by 4x +// and 1152kHz, 2048kHz by 8x void RTLSDRThread::callback(const quint8* buf, qint32 len) { SampleVector::iterator it = m_convertBuffer.begin(); - int mode = 0; if (m_samplerate < 800000) - mode = 2; - - switch(mode) { - case 0: - decimate16(&it, buf, len); - break; - case 1: - break; - - case 2: - decimate4(&it, buf, len); - break; - - case 3: - break; - - default: - decimate16(&it, buf, len); - break; - } + decimate4(&it, buf, len); + else if ((m_samplerate == 1152000)||(m_samplerate == 2048000)) + decimate8(&it, buf, len); + else + decimate16(&it, buf, len); m_sampleFifo->write(m_convertBuffer.begin(), it);