diff --git a/plugins/channelrx/chanalyzer/chanalyzergui.cpp b/plugins/channelrx/chanalyzer/chanalyzergui.cpp index d68e7b01e..cb3d7ef23 100644 --- a/plugins/channelrx/chanalyzer/chanalyzergui.cpp +++ b/plugins/channelrx/chanalyzer/chanalyzergui.cpp @@ -338,8 +338,8 @@ ChannelAnalyzerGUI::ChannelAnalyzerGUI(PluginAPI* pluginAPI, DeviceUISet *device setAttribute(Qt::WA_DeleteOnClose, true); connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool))); - m_spectrumVis = new SpectrumVis(ui->glSpectrum); - m_scopeVis = new ScopeVis(ui->glScope); + m_spectrumVis = new SpectrumVis(SDR_RX_SCALEF, ui->glSpectrum); + m_scopeVis = new ScopeVis(SDR_RX_SCALEF, ui->glScope); m_spectrumScopeComboVis = new SpectrumScopeComboVis(m_spectrumVis, m_scopeVis); m_channelAnalyzer = (ChannelAnalyzer*) rxChannel; //new ChannelAnalyzer(m_deviceUISet->m_deviceSourceAPI); m_channelAnalyzer->setSampleSink(m_spectrumScopeComboVis); diff --git a/plugins/channelrx/chanalyzerng/chanalyzernggui.cpp b/plugins/channelrx/chanalyzerng/chanalyzernggui.cpp index b290020ef..3441cb265 100644 --- a/plugins/channelrx/chanalyzerng/chanalyzernggui.cpp +++ b/plugins/channelrx/chanalyzerng/chanalyzernggui.cpp @@ -395,7 +395,7 @@ ChannelAnalyzerNGGUI::ChannelAnalyzerNGGUI(PluginAPI* pluginAPI, DeviceUISet *de setAttribute(Qt::WA_DeleteOnClose, true); connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool))); - m_spectrumVis = new SpectrumVis(ui->glSpectrum); + m_spectrumVis = new SpectrumVis(SDR_RX_SCALEF, ui->glSpectrum); m_scopeVis = new ScopeVisNG(ui->glScope); m_spectrumScopeComboVis = new SpectrumScopeNGComboVis(m_spectrumVis, m_scopeVis); m_channelAnalyzer = (ChannelAnalyzerNG*) rxChannel; //new ChannelAnalyzerNG(m_deviceUISet->m_deviceSourceAPI); diff --git a/plugins/channelrx/demodbfm/bfmdemodgui.cpp b/plugins/channelrx/demodbfm/bfmdemodgui.cpp index 0a298aa90..fdce5b17d 100644 --- a/plugins/channelrx/demodbfm/bfmdemodgui.cpp +++ b/plugins/channelrx/demodbfm/bfmdemodgui.cpp @@ -344,7 +344,7 @@ BFMDemodGUI::BFMDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &))); connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages())); - m_spectrumVis = new SpectrumVis(ui->glSpectrum); + m_spectrumVis = new SpectrumVis(SDR_RX_SCALEF, ui->glSpectrum); m_bfmDemod = (BFMDemod*) rxChannel; //new BFMDemod(m_deviceUISet->m_deviceSourceAPI); m_bfmDemod->setMessageQueueToGUI(getInputMessageQueue()); m_bfmDemod->setSampleSink(m_spectrumVis); diff --git a/plugins/channelrx/demoddsd/dsddemodgui.cpp b/plugins/channelrx/demoddsd/dsddemodgui.cpp index bff4ce0a8..863a7ff6b 100644 --- a/plugins/channelrx/demoddsd/dsddemodgui.cpp +++ b/plugins/channelrx/demoddsd/dsddemodgui.cpp @@ -269,7 +269,7 @@ DSDDemodGUI::DSDDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool))); connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &))); - m_scopeVis = new ScopeVis(ui->glScope); + m_scopeVis = new ScopeVis(SDR_RX_SCALEF, ui->glScope); m_dsdDemod = (DSDDemod*) rxChannel; //new DSDDemod(m_deviceUISet->m_deviceSourceAPI); m_dsdDemod->setScopeSink(m_scopeVis); m_dsdDemod->setMessageQueueToGUI(getInputMessageQueue()); diff --git a/plugins/channelrx/demodlora/lorademodgui.cpp b/plugins/channelrx/demodlora/lorademodgui.cpp index 82dfa464d..f70abc72c 100644 --- a/plugins/channelrx/demodlora/lorademodgui.cpp +++ b/plugins/channelrx/demodlora/lorademodgui.cpp @@ -117,7 +117,7 @@ LoRaDemodGUI::LoRaDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseb setAttribute(Qt::WA_DeleteOnClose, true); connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool))); - m_spectrumVis = new SpectrumVis(ui->glSpectrum); + m_spectrumVis = new SpectrumVis(SDR_RX_SCALEF, ui->glSpectrum); m_LoRaDemod = (LoRaDemod*) rxChannel; //new LoRaDemod(m_deviceUISet->m_deviceSourceAPI); m_LoRaDemod->setSpectrumSink(m_spectrumVis); diff --git a/plugins/channelrx/demodssb/ssbdemodgui.cpp b/plugins/channelrx/demodssb/ssbdemodgui.cpp index 9a26e88a2..e967bad44 100644 --- a/plugins/channelrx/demodssb/ssbdemodgui.cpp +++ b/plugins/channelrx/demodssb/ssbdemodgui.cpp @@ -244,7 +244,7 @@ SSBDemodGUI::SSBDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool))); connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &))); - m_spectrumVis = new SpectrumVis(ui->glSpectrum); + m_spectrumVis = new SpectrumVis(SDR_RX_SCALEF, ui->glSpectrum); m_ssbDemod = (SSBDemod*) rxChannel; //new SSBDemod(m_deviceUISet->m_deviceSourceAPI); m_ssbDemod->setMessageQueueToGUI(getInputMessageQueue()); m_ssbDemod->setSampleSink(m_spectrumVis); diff --git a/plugins/channelrx/tcpsrc/tcpsrcgui.cpp b/plugins/channelrx/tcpsrc/tcpsrcgui.cpp index 0f2b5fad9..5e0cc50eb 100644 --- a/plugins/channelrx/tcpsrc/tcpsrcgui.cpp +++ b/plugins/channelrx/tcpsrc/tcpsrcgui.cpp @@ -132,7 +132,7 @@ TCPSrcGUI::TCPSrcGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSam connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool))); setAttribute(Qt::WA_DeleteOnClose, true); - m_spectrumVis = new SpectrumVis(ui->glSpectrum); + m_spectrumVis = new SpectrumVis(SDR_RX_SCALEF, ui->glSpectrum); m_tcpSrc = (TCPSrc*) rxChannel; //new TCPSrc(m_deviceUISet->m_deviceSourceAPI); m_tcpSrc->setSpectrum(m_spectrumVis); diff --git a/plugins/channelrx/udpsrc/udpsrcgui.cpp b/plugins/channelrx/udpsrc/udpsrcgui.cpp index 48918ad19..2ec35bc8d 100644 --- a/plugins/channelrx/udpsrc/udpsrcgui.cpp +++ b/plugins/channelrx/udpsrc/udpsrcgui.cpp @@ -147,7 +147,7 @@ UDPSrcGUI::UDPSrcGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSam connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &))); setAttribute(Qt::WA_DeleteOnClose, true); - m_spectrumVis = new SpectrumVis(ui->glSpectrum); + m_spectrumVis = new SpectrumVis(SDR_RX_SCALEF, ui->glSpectrum); m_udpSrc = (UDPSrc*) rxChannel; //new UDPSrc(m_deviceUISet->m_deviceSourceAPI); m_udpSrc->setSpectrum(m_spectrumVis); diff --git a/plugins/channeltx/modssb/ssbmodgui.cpp b/plugins/channeltx/modssb/ssbmodgui.cpp index 2ba54f94c..3f093e40e 100644 --- a/plugins/channeltx/modssb/ssbmodgui.cpp +++ b/plugins/channeltx/modssb/ssbmodgui.cpp @@ -364,7 +364,7 @@ SSBModGUI::SSBModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSam setAttribute(Qt::WA_DeleteOnClose, true); connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool))); - m_spectrumVis = new SpectrumVis(ui->glSpectrum); + m_spectrumVis = new SpectrumVis(SDR_TX_SCALEF, ui->glSpectrum); m_ssbMod = (SSBMod*) channelTx; //new SSBMod(m_deviceUISet->m_deviceSinkAPI); m_ssbMod->setSpectrumSampleSink(m_spectrumVis); m_ssbMod->setMessageQueueToGUI(getInputMessageQueue()); diff --git a/plugins/channeltx/udpsink/udpsinkgui.cpp b/plugins/channeltx/udpsink/udpsinkgui.cpp index d408c0b9b..36ef4dbbf 100644 --- a/plugins/channeltx/udpsink/udpsinkgui.cpp +++ b/plugins/channeltx/udpsink/udpsinkgui.cpp @@ -119,7 +119,7 @@ UDPSinkGUI::UDPSinkGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandS connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &))); setAttribute(Qt::WA_DeleteOnClose, true); - m_spectrumVis = new SpectrumVis(ui->glSpectrum); + m_spectrumVis = new SpectrumVis(SDR_TX_SCALEF, ui->glSpectrum); m_udpSink = (UDPSink*) channelTx; //new UDPSink(m_deviceUISet->m_deviceSinkAPI); m_udpSink->setSpectrumSink(m_spectrumVis); m_udpSink->setMessageQueueToGUI(getInputMessageQueue()); diff --git a/sdrgui/device/deviceuiset.cpp b/sdrgui/device/deviceuiset.cpp index 708e92408..d34d7a74a 100644 --- a/sdrgui/device/deviceuiset.cpp +++ b/sdrgui/device/deviceuiset.cpp @@ -35,7 +35,11 @@ DeviceUISet::DeviceUISet(int tabIndex, bool rxElseTx, QTimer& timer) { m_spectrum = new GLSpectrum; - m_spectrumVis = new SpectrumVis(m_spectrum); + if (rxElseTx) { + m_spectrumVis = new SpectrumVis(SDR_RX_SCALEF, m_spectrum); + } else { + m_spectrumVis = new SpectrumVis(SDR_TX_SCALEF, m_spectrum); + } m_spectrum->connectTimer(timer); m_spectrumGUI = new GLSpectrumGUI; m_spectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, m_spectrum); diff --git a/sdrgui/dsp/scopevis.cpp b/sdrgui/dsp/scopevis.cpp index 1ee974efe..0fd0426e5 100644 --- a/sdrgui/dsp/scopevis.cpp +++ b/sdrgui/dsp/scopevis.cpp @@ -17,8 +17,9 @@ MESSAGE_CLASS_DEFINITION(ScopeVis::MsgConfigureScopeVis, Message) const uint ScopeVis::m_traceChunkSize = 4800; -ScopeVis::ScopeVis(GLScope* glScope) : +ScopeVis::ScopeVis(Real scalef, GLScope* glScope) : m_glScope(glScope), + m_scalef(scalef), m_tracebackCount(0), m_fill(0), m_triggerState(Untriggered), @@ -111,7 +112,7 @@ void ScopeVis::feed(const SampleVector::const_iterator& cbegin, const SampleVect for(int i = 0; i < count; ++i) { - *it++ = Complex(begin->real() / SDR_RX_SCALEF, begin->imag() / SDR_RX_SCALEF); + *it++ = Complex(begin->real() / m_scalef, begin->imag() / m_scalef); ++begin; } @@ -234,7 +235,7 @@ void ScopeVis::feed(const SampleVector::const_iterator& cbegin, const SampleVect for(int i = 0; i < count; ++i) { - *it++ = Complex(begin->real() / SDR_RX_SCALEF, begin->imag() / SDR_RX_SCALEF); + *it++ = Complex(begin->real() / m_scalef, begin->imag() / m_scalef); ++begin; } @@ -341,7 +342,7 @@ void ScopeVis::setSampleRate(int sampleRate) bool ScopeVis::triggerCondition(SampleVector::const_iterator& it) { - Complex c(it->real()/SDR_RX_SCALEF, it->imag()/SDR_RX_SCALEF); + Complex c(it->real()/m_scalef, it->imag()/m_scalef); m_traceback.push_back(c); // store into trace memory FIFO if (m_tracebackCount < m_traceback.size()) diff --git a/sdrgui/dsp/scopevis.h b/sdrgui/dsp/scopevis.h index 8cdfe9232..311642984 100644 --- a/sdrgui/dsp/scopevis.h +++ b/sdrgui/dsp/scopevis.h @@ -24,7 +24,7 @@ public: static const uint m_traceChunkSize; static const uint m_nbTriggers = 10; - ScopeVis(GLScope* glScope = NULL); + ScopeVis(Real scalef, GLScope* glScope = 0); virtual ~ScopeVis(); void configure(MessageQueue* msgQueue, @@ -140,6 +140,7 @@ private: }; GLScope* m_glScope; + Real m_scalef; //!< Sample scale factor from [-1,+1] to integer sample size range std::vector m_trace; //!< Raw trace to be used by GLScope boost::circular_buffer m_traceback; //!< FIFO for samples prior to triggering point to support pre-trigger (when in triggered mode) uint m_tracebackCount; //!< Count of samples stored into trace memory since triggering is active up to trace memory size diff --git a/sdrgui/dsp/scopevismulti.h b/sdrgui/dsp/scopevismulti.h index 3ae2a5e7f..a2f5af8de 100644 --- a/sdrgui/dsp/scopevismulti.h +++ b/sdrgui/dsp/scopevismulti.h @@ -560,14 +560,18 @@ private: break; case ProjectionMagLin: { - uint32_t magsq = s.m_real*s.m_real + s.m_imag*s.m_imag; - v = std::sqrt(magsq/1073741824.0f); + Real re = s.m_real / SDR_RX_SCALEF; + Real im = s.m_imag / SDR_RX_SCALEF; + Real magsq = re*re + im*im; + v = std::sqrt(magsq); } break; case ProjectionMagDB: { - uint32_t magsq = s.m_real*s.m_real + s.m_imag*s.m_imag; - v = log10f(magsq/1073741824.0f) * 10.0f; + Real re = s.m_real / SDR_RX_SCALEF; + Real im = s.m_imag / SDR_RX_SCALEF; + Real magsq = re*re + im*im; + v = log10f(magsq) * 10.0f; } break; case ProjectionPhase: diff --git a/sdrgui/dsp/scopevisng.h b/sdrgui/dsp/scopevisng.h index d31b8ce9a..c31435fc8 100644 --- a/sdrgui/dsp/scopevisng.h +++ b/sdrgui/dsp/scopevisng.h @@ -549,14 +549,18 @@ private: break; case ProjectionMagLin: { - uint32_t magsq = s.m_real*s.m_real + s.m_imag*s.m_imag; - v = std::sqrt(magsq/1073741824.0f); + Real re = s.m_real / SDR_RX_SCALEF; + Real im = s.m_imag / SDR_RX_SCALEF; + Real magsq = re*re + im*im; + v = std::sqrt(magsq); } break; case ProjectionMagDB: { - uint32_t magsq = s.m_real*s.m_real + s.m_imag*s.m_imag; - v = log10f(magsq/1073741824.0f) * 10.0f; + Real re = s.m_real / SDR_RX_SCALEF; + Real im = s.m_imag / SDR_RX_SCALEF; + Real magsq = re*re + im*im; + v = log10f(magsq) * 10.0f; } break; case ProjectionPhase: diff --git a/sdrgui/dsp/spectrumvis.cpp b/sdrgui/dsp/spectrumvis.cpp index ff1f569a1..0dc92f0d5 100644 --- a/sdrgui/dsp/spectrumvis.cpp +++ b/sdrgui/dsp/spectrumvis.cpp @@ -14,13 +14,14 @@ inline double log2f(double n) MESSAGE_CLASS_DEFINITION(SpectrumVis::MsgConfigureSpectrumVis, Message) -SpectrumVis::SpectrumVis(GLSpectrum* glSpectrum) : +SpectrumVis::SpectrumVis(Real scalef, GLSpectrum* glSpectrum) : BasebandSampleSink(), m_fft(FFTEngine::create()), m_fftBuffer(MAX_FFT_SIZE), m_logPowerSpectrum(MAX_FFT_SIZE), m_fftBufferFill(0), m_needMoreSamples(false), + m_scalef(scalef), m_glSpectrum(glSpectrum), m_mutex(QMutex::Recursive) { @@ -85,7 +86,7 @@ void SpectrumVis::feed(const SampleVector::const_iterator& cbegin, const SampleV for (std::size_t i = 0; i < samplesNeeded; ++i, ++begin) { - *it++ = Complex(begin->real() / SDR_RX_SCALEF, begin->imag() / SDR_RX_SCALEF); + *it++ = Complex(begin->real() / m_scalef, begin->imag() / m_scalef); } // apply fft window (and copy from m_fftBuffer to m_fftIn) @@ -144,7 +145,7 @@ void SpectrumVis::feed(const SampleVector::const_iterator& cbegin, const SampleV // not enough samples for FFT - just fill in new data and return for(std::vector::iterator it = m_fftBuffer.begin() + m_fftBufferFill; begin < end; ++begin) { - *it++ = Complex(begin->real() / SDR_RX_SCALEF, begin->imag() / SDR_RX_SCALEF); + *it++ = Complex(begin->real() / m_scalef, begin->imag() / m_scalef); } m_fftBufferFill += todo; diff --git a/sdrgui/dsp/spectrumvis.h b/sdrgui/dsp/spectrumvis.h index b411956a0..3f3f58ff4 100644 --- a/sdrgui/dsp/spectrumvis.h +++ b/sdrgui/dsp/spectrumvis.h @@ -35,7 +35,7 @@ public: FFTWindow::Function m_window; }; - SpectrumVis(GLSpectrum* glSpectrum = NULL); + SpectrumVis(Real scalef, GLSpectrum* glSpectrum = 0); virtual ~SpectrumVis(); void configure(MessageQueue* msgQueue, int fftSize, int overlapPercent, FFTWindow::Function window); @@ -60,6 +60,7 @@ private: std::size_t m_fftBufferFill; bool m_needMoreSamples; + Real m_scalef; GLSpectrum* m_glSpectrum; QMutex m_mutex;