From bbe6d4505da371d18be2b0bb545af9a34c0b554b Mon Sep 17 00:00:00 2001 From: John Greb Date: Tue, 10 Jun 2014 12:24:52 +0100 Subject: [PATCH] Waterfall brightness/overlap. --- plugins/samplesource/rtlsdr/rtlsdrthread.cpp | 15 ++++++++------- sdrbase/dsp/spectrumvis.cpp | 2 +- sdrbase/gui/glspectrum.cpp | 4 +--- sdrbase/gui/glspectrumgui.cpp | 6 +++--- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/plugins/samplesource/rtlsdr/rtlsdrthread.cpp b/plugins/samplesource/rtlsdr/rtlsdrthread.cpp index ec5a60873..e81ee10ec 100644 --- a/plugins/samplesource/rtlsdr/rtlsdrthread.cpp +++ b/plugins/samplesource/rtlsdr/rtlsdrthread.cpp @@ -80,12 +80,12 @@ void RTLSDRThread::decimate2(SampleVector::iterator* it, const quint8* buf, qint for (int pos = 0; pos < len + 7; pos += 8) { xreal = buf[pos+0] - buf[pos+3]; yimag = buf[pos+1] + buf[pos+2] - 255; - Sample s( xreal << 6, yimag << 6 ); + Sample s( xreal << 3, yimag << 3 ); **it = s; (*it)++; xreal = buf[pos+7] - buf[pos+4]; yimag = 255 - buf[pos+5] - buf[pos+6]; - Sample t( xreal << 6, yimag << 6 ); + Sample t( xreal << 3, yimag << 3 ); **it = t; (*it)++; } @@ -96,7 +96,7 @@ void RTLSDRThread::decimate4(SampleVector::iterator* it, const quint8* buf, qint for (int pos = 0; pos < len + 7; 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 s( xreal << 5, yimag << 5 ); + Sample s( xreal << 3, yimag << 3 ); **it = s; (*it)++; } @@ -112,7 +112,7 @@ void RTLSDRThread::decimate8(SampleVector::iterator* it, const quint8* buf, qint 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 s( xreal << 4, yimag << 4 ); + Sample s( xreal << 3, yimag << 3 ); **it = s; (*it)++; } @@ -140,8 +140,9 @@ void RTLSDRThread::callback(const quint8* buf, qint32 len) { qint16 xreal, yimag, phase; SampleVector::iterator it = m_convertBuffer.begin(); + int decimationFactor[] = {16, 8, 4, 2, 1, 0}; - if (++localdecimation < (1 << (4 - m_decimation))) return; + if (++localdecimation < decimationFactor[m_decimation]) return; localdecimation = 0; switch(m_decimation) { @@ -152,10 +153,10 @@ void RTLSDRThread::callback(const quint8* buf, qint32 len) phase *= -1; xreal = phase * (buf[pos+0] - 127); yimag = phase * (buf[pos+1] - 127); - *it++ = Sample( xreal<<7,yimag<<7); + *it++ = Sample( xreal<<3,yimag<<3); xreal = phase * (127 - buf[pos+3]); yimag = phase * (buf[pos+2] - 127); - *it++ = Sample( xreal<<7,yimag<<7); + *it++ = Sample( xreal<<3,yimag<<3); } break; case 1: // 1:2 diff --git a/sdrbase/dsp/spectrumvis.cpp b/sdrbase/dsp/spectrumvis.cpp index 01c7dbe31..102ad3855 100644 --- a/sdrbase/dsp/spectrumvis.cpp +++ b/sdrbase/dsp/spectrumvis.cpp @@ -20,7 +20,7 @@ SpectrumVis::SpectrumVis(GLSpectrum* glSpectrum) : m_fftBufferFill(0), m_glSpectrum(glSpectrum) { - handleConfigure(1024, 10, FFTWindow::BlackmanHarris); + handleConfigure(1024, 0, FFTWindow::BlackmanHarris); } SpectrumVis::~SpectrumVis() diff --git a/sdrbase/gui/glspectrum.cpp b/sdrbase/gui/glspectrum.cpp index 560f33cf7..ce99a3919 100644 --- a/sdrbase/gui/glspectrum.cpp +++ b/sdrbase/gui/glspectrum.cpp @@ -270,9 +270,7 @@ void GLSpectrum::updateWaterfall(const std::vector& spectrum) quint32* pix = (quint32*)m_waterfallBuffer->scanLine(m_waterfallBufferPos); for(int i = 0; i < m_fftSize; i++) { - Real vr = (int)((spectrum[i] - m_referenceLevel) * 2.4 * 100.0 / m_powerRange + 240.0); - int v = (int)vr; - + int v = (int)((spectrum[i] - m_referenceLevel) * 2.4 * 100.0 / m_powerRange + 240.0); if(v > 239) v = 239; else if(v < 0) diff --git a/sdrbase/gui/glspectrumgui.cpp b/sdrbase/gui/glspectrumgui.cpp index 1fbaaf2ee..089e6225e 100644 --- a/sdrbase/gui/glspectrumgui.cpp +++ b/sdrbase/gui/glspectrumgui.cpp @@ -12,7 +12,7 @@ GLSpectrumGUI::GLSpectrumGUI(QWidget* parent) : m_spectrumVis(NULL), m_glSpectrum(NULL), m_fftSize(1024), - m_fftOverlap(10), + m_fftOverlap(0), m_fftWindow(FFTWindow::Hamming), m_refLevel(0), m_powerRange(100), @@ -47,7 +47,7 @@ void GLSpectrumGUI::setBuddies(MessageQueue* messageQueue, SpectrumVis* spectrum void GLSpectrumGUI::resetToDefaults() { m_fftSize = 1024; - m_fftOverlap = 10; + m_fftOverlap = 0; m_fftWindow = FFTWindow::Hamming; m_refLevel = 0; m_powerRange = 100; @@ -90,7 +90,7 @@ bool GLSpectrumGUI::deserialize(const QByteArray& data) if(d.getVersion() == 1) { d.readS32(1, &m_fftSize, 1024); - d.readS32(2, &m_fftOverlap, 10); + d.readS32(2, &m_fftOverlap, 0); d.readS32(3, &m_fftWindow, FFTWindow::Hamming); d.readReal(4, &m_refLevel, 0); d.readReal(5, &m_powerRange, 100);