From b345dc7516de0130021c8984a16a82bfef2bb2a8 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Wed, 12 Aug 2015 22:14:14 -0400 Subject: [PATCH] Spectrum averaging control now functional --- src/AppFrame.cpp | 12 +++++++++--- src/process/SpectrumVisualProcessor.cpp | 12 ++++++++---- src/process/SpectrumVisualProcessor.h | 3 +++ src/sdr/SDRPostThread.cpp | 2 +- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index 890aa25..07c919b 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -118,8 +118,8 @@ AppFrame::AppFrame() : wxGetApp().getSpectrumProcesor()->attachOutput(spectrumCanvas->getVisualDataQueue()); spectrumAvgMeter = new MeterCanvas(this, attribList); - spectrumAvgMeter->setMax(3.0); - spectrumAvgMeter->setLevel(1.0); + spectrumAvgMeter->setMax(1.0); + spectrumAvgMeter->setLevel(0.65); spectrumAvgMeter->setShowUserInput(false); spectrumSizer->Add(spectrumCanvas, 63, wxEXPAND | wxALL, 0); @@ -712,9 +712,15 @@ void AppFrame::OnIdle(wxIdleEvent& event) { wxGetApp().getScopeProcessor()->run(); wxGetApp().getSpectrumDistributor()->run(); - + SpectrumVisualProcessor *proc = wxGetApp().getSpectrumProcesor(); + if (spectrumAvgMeter->inputChanged()) { + float val = spectrumAvgMeter->getInputValue(); + spectrumAvgMeter->setLevel(val); + proc->setFFTAverageRate(val); + } + proc->setView(spectrumCanvas->getViewState()); proc->setBandwidth(spectrumCanvas->getBandwidth()); proc->setCenterFrequency(spectrumCanvas->getCenterFrequency()); diff --git a/src/process/SpectrumVisualProcessor.cpp b/src/process/SpectrumVisualProcessor.cpp index 932477b..34b2543 100644 --- a/src/process/SpectrumVisualProcessor.cpp +++ b/src/process/SpectrumVisualProcessor.cpp @@ -15,6 +15,7 @@ SpectrumVisualProcessor::SpectrumVisualProcessor() : lastInputBandwidth(0), last fft_ceil_ma = fft_ceil_maa = 100.0; fft_floor_ma = fft_floor_maa = 0.0; desiredInputSize = 0; + fft_average_rate = 0.65; } SpectrumVisualProcessor::~SpectrumVisualProcessor() { @@ -29,6 +30,9 @@ void SpectrumVisualProcessor::setView(bool bView) { is_view.store(bView); } +void SpectrumVisualProcessor::setFFTAverageRate(float fftAverageRate) { + this->fft_average_rate = fftAverageRate; +} void SpectrumVisualProcessor::setCenterFrequency(long long centerFreq_in) { centerFreq.store(centerFreq_in); @@ -260,11 +264,11 @@ void SpectrumVisualProcessor::process() { for (int i = 0, iMax = fftSize; i < iMax; i++) { if (is_view.load()) { - fft_result_maa[i] += (fft_result_ma[i] - fft_result_maa[i]) * 0.65; - fft_result_ma[i] += (fft_result[i] - fft_result_ma[i]) * 0.65; + fft_result_maa[i] += (fft_result_ma[i] - fft_result_maa[i]) * fft_average_rate; + fft_result_ma[i] += (fft_result[i] - fft_result_ma[i]) * fft_average_rate; } else { - fft_result_maa[i] += (fft_result_ma[i] - fft_result_maa[i]) * 0.65; - fft_result_ma[i] += (fft_result[i] - fft_result_ma[i]) * 0.65; + fft_result_maa[i] += (fft_result_ma[i] - fft_result_maa[i]) * fft_average_rate; + fft_result_ma[i] += (fft_result[i] - fft_result_ma[i]) * fft_average_rate; } if (fft_result_maa[i] > fft_ceil) { diff --git a/src/process/SpectrumVisualProcessor.h b/src/process/SpectrumVisualProcessor.h index 2ee8ba2..134d61f 100644 --- a/src/process/SpectrumVisualProcessor.h +++ b/src/process/SpectrumVisualProcessor.h @@ -21,6 +21,8 @@ public: bool isView(); void setView(bool bView); + void setFFTAverageRate(float fftAverageRate); + void setCenterFrequency(long long centerFreq_in); long long getCenterFrequency(); @@ -50,6 +52,7 @@ private: float fft_ceil_ma, fft_ceil_maa; float fft_floor_ma, fft_floor_maa; + float fft_average_rate; std::vector fft_result; std::vector fft_result_ma; diff --git a/src/sdr/SDRPostThread.cpp b/src/sdr/SDRPostThread.cpp index a9955cd..30944cf 100644 --- a/src/sdr/SDRPostThread.cpp +++ b/src/sdr/SDRPostThread.cpp @@ -86,7 +86,7 @@ void SDRPostThread::run() { std::vector fpData; std::vector dataOut; - iqDataInQueue->set_max_num_items(30); + iqDataInQueue->set_max_num_items(0); while (!terminated) { SDRThreadIQData *data_in;