From 7163cd13f2e8ae2dd5bee7cd382dc7470d919a76 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Wed, 9 Sep 2015 17:31:55 -0400 Subject: [PATCH] Spectrum panel init fixes, more FFT distributor tweaks --- src/panel/SpectrumPanel.cpp | 21 ++++++++++++++++----- src/process/FFTDataDistributor.cpp | 4 ++-- src/visual/ScopeCanvas.cpp | 6 +++--- src/visual/SpectrumCanvas.cpp | 6 +++--- src/visual/WaterfallCanvas.cpp | 4 ++-- 5 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/panel/SpectrumPanel.cpp b/src/panel/SpectrumPanel.cpp index 034d3c5..ac2ac3e 100644 --- a/src/panel/SpectrumPanel.cpp +++ b/src/panel/SpectrumPanel.cpp @@ -4,8 +4,16 @@ #include #include #include "ColorTheme.h" +#include "CubicSDRDefs.h" -SpectrumPanel::SpectrumPanel() : floorValue(0), ceilValue(1), showDb(false), fftSize(2048) { +SpectrumPanel::SpectrumPanel() { + floorValue = 0; + ceilValue = 1; + showDb = false; + fftSize = DEFAULT_FFT_SIZE; + bandwidth = DEFAULT_DEMOD_BW; + freq = 0; + setFill(GLPANEL_FILL_GRAD_Y); setFillColor(ThemeMgr::mgr.currentTheme->fftBackground * 2.0, ThemeMgr::mgr.currentTheme->fftBackground); @@ -233,15 +241,18 @@ void SpectrumPanel::drawPanelContents() { float dbPanelHeight = (1.0/viewHeight)*14.0; - std::stringstream ssLabel; - ssLabel << std::fixed << std::setprecision(1) << (20.0 * log10(2.0*(getCeilValue())/(double)fftSize)) << "dB"; - + std::stringstream ssLabel(""); + if (getCeilValue() != getFloorValue() && fftSize) { + ssLabel << std::fixed << std::setprecision(1) << (20.0 * log10(2.0*(getCeilValue())/(double)fftSize)) << "dB"; + } dbPanelCeil.setText(ssLabel.str(), GLFont::GLFONT_ALIGN_RIGHT); dbPanelCeil.setSize(dbPanelWidth, dbPanelHeight); dbPanelCeil.setPosition(-1.0 + dbPanelWidth, 1.0 - dbPanelHeight); ssLabel.str(""); - ssLabel << (20.0 * log10(2.0*(getFloorValue())/(double)fftSize)) << "dB"; + if (getCeilValue() != getFloorValue() && fftSize) { + ssLabel << (20.0 * log10(2.0*(getFloorValue())/(double)fftSize)) << "dB"; + } dbPanelFloor.setText(ssLabel.str(), GLFont::GLFONT_ALIGN_RIGHT); dbPanelFloor.setSize(dbPanelWidth, dbPanelHeight); diff --git a/src/process/FFTDataDistributor.cpp b/src/process/FFTDataDistributor.cpp index 818c955..aecb0cc 100644 --- a/src/process/FFTDataDistributor.cpp +++ b/src/process/FFTDataDistributor.cpp @@ -16,7 +16,7 @@ int FFTDataDistributor::getLinesPerSecond() { } void FFTDataDistributor::process() { - while (!input->empty()) { + if (!input->empty()) { if (!isAnyOutputEmpty()) { return; } @@ -33,7 +33,7 @@ void FFTDataDistributor::process() { } inp->decRefCount(); } else { - continue; + return; } // number of seconds contained in input diff --git a/src/visual/ScopeCanvas.cpp b/src/visual/ScopeCanvas.cpp index e6a8c99..6c22dc7 100644 --- a/src/visual/ScopeCanvas.cpp +++ b/src/visual/ScopeCanvas.cpp @@ -102,9 +102,9 @@ void ScopeCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); const wxSize ClientSize = GetClientSize(); -#ifdef __APPLE__ - glFinish(); -#endif +//#ifdef __APPLE__ +// glFinish(); +//#endif while (!inputData.empty()) { ScopeRenderData *avData; diff --git a/src/visual/SpectrumCanvas.cpp b/src/visual/SpectrumCanvas.cpp index 220aa04..557398c 100644 --- a/src/visual/SpectrumCanvas.cpp +++ b/src/visual/SpectrumCanvas.cpp @@ -45,9 +45,9 @@ SpectrumCanvas::~SpectrumCanvas() { void SpectrumCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); const wxSize ClientSize = GetClientSize(); -#ifdef __APPLE__ - glFinish(); -#endif +//#ifdef __APPLE__ +// glFinish(); +//#endif if (!visualDataQueue.empty()) { diff --git a/src/visual/WaterfallCanvas.cpp b/src/visual/WaterfallCanvas.cpp index 15299b9..bfd1bc6 100644 --- a/src/visual/WaterfallCanvas.cpp +++ b/src/visual/WaterfallCanvas.cpp @@ -75,9 +75,9 @@ void WaterfallCanvas::processInputQueue() { glContext->SetCurrent(*this); bool processed = false; - while (!visualDataQueue.empty()) { + int numVis = visualDataQueue.size(); + for (int i = 0; i < numVis; i++) { SpectrumVisualData *vData; - visualDataQueue.pop(vData); if (vData) {