From 33d51b2bff7b40fd7753edee1647ef2cdc3723c8 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Wed, 12 Aug 2015 19:39:11 -0400 Subject: [PATCH] Improve input response time, balance visuals, fix a bug --- src/AppFrame.cpp | 24 +++++------------------- src/AppFrame.h | 4 ---- src/CubicSDRDefs.h | 2 +- src/sdr/SDRPostThread.cpp | 4 ++-- src/visual/WaterfallCanvas.cpp | 31 +++++++++++++++++++------------ src/visual/WaterfallCanvas.h | 1 + 6 files changed, 28 insertions(+), 38 deletions(-) diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index 5930a5c..614b2e5 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -35,11 +35,10 @@ EVT_CLOSE(AppFrame::OnClose) EVT_MENU(wxID_ANY, AppFrame::OnMenu) EVT_COMMAND(wxID_ANY, wxEVT_THREAD, AppFrame::OnThread) EVT_IDLE(AppFrame::OnIdle) -//EVT_TIMER(FRAME_TIMER_ID, AppFrame::OnTimer) wxEND_EVENT_TABLE() AppFrame::AppFrame() : - wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL), frame_timer(this, FRAME_TIMER_ID) { + wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) { #ifdef __linux__ SetIcon(wxICON(cubicsdr)); @@ -261,7 +260,7 @@ AppFrame::AppFrame() : // sampleRateMenuItems[wxID_BANDWIDTH_3000M] = menu->AppendRadioItem(wxID_BANDWIDTH_3000M, "3.0M"); sampleRateMenuItems[wxID_BANDWIDTH_3200M] = menu->AppendRadioItem(wxID_BANDWIDTH_3200M, "3.2M"); - sampleRateMenuItems[wxID_BANDWIDTH_2400M]->Check(true); + sampleRateMenuItems[wxID_BANDWIDTH_2048M]->Check(true); menuBar->Append(menu, wxT("&Input Bandwidth")); @@ -402,18 +401,6 @@ void AppFrame::initDeviceParams(std::string deviceId) { if (devConfig->getIQSwap()) { iqSwapMenuItem->Check(); } - - if (!frame_timer.IsRunning()) { - // frame rate = 1000 / 30 = 33ms - -// windows needs a bit more time or it lags? -//#ifdef _WIN32 -// frame_timer.Start(25); -//#else -// frame_timer.Start(15); -//#endif - - } } @@ -608,10 +595,6 @@ void AppFrame::OnThread(wxCommandEvent& event) { } void AppFrame::OnIdle(wxIdleEvent& event) { -// event.Skip(); -//} -// -//void AppFrame::OnTimer(wxTimerEvent& event) { DemodulatorInstance *demod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); @@ -769,6 +752,9 @@ void AppFrame::OnIdle(wxIdleEvent& event) { wproc->run(); } + waterfallCanvas->processInputQueue(); + demodWaterfallCanvas->processInputQueue(); + usleep(5000); /* scopeCanvas->Refresh(); diff --git a/src/AppFrame.h b/src/AppFrame.h index fd9eac6..3531de5 100644 --- a/src/AppFrame.h +++ b/src/AppFrame.h @@ -50,8 +50,6 @@ #define wxID_AUDIO_BANDWIDTH_BASE 9000 #define wxID_AUDIO_DEVICE_MULTIPLIER 50 -#define FRAME_TIMER_ID 1000 - // Define a new frame type class AppFrame: public wxFrame { public: @@ -69,7 +67,6 @@ private: void OnClose(wxCloseEvent& event); void OnNewWindow(wxCommandEvent& event); void OnIdle(wxIdleEvent& event); -// void OnTimer(wxTimerEvent& event); ScopeCanvas *scopeCanvas; SpectrumCanvas *spectrumCanvas; @@ -96,7 +93,6 @@ private: wxMenuItem *iqSwapMenuItem; std::string currentSessionFile; - wxTimer frame_timer; FFTDataDistributor fftDistrib; DemodulatorThreadInputQueue fftQueue; diff --git a/src/CubicSDRDefs.h b/src/CubicSDRDefs.h index b2c326a..677e68b 100644 --- a/src/CubicSDRDefs.h +++ b/src/CubicSDRDefs.h @@ -27,7 +27,7 @@ const char filePathSeparator = #define BUF_SIZE (16384*6) -#define DEFAULT_SAMPLE_RATE 2400000 +#define DEFAULT_SAMPLE_RATE 2048000 #define DEFAULT_FFT_SIZE 2048 #define DEFAULT_DEMOD_TYPE 1 diff --git a/src/sdr/SDRPostThread.cpp b/src/sdr/SDRPostThread.cpp index 5658615..7a999f9 100644 --- a/src/sdr/SDRPostThread.cpp +++ b/src/sdr/SDRPostThread.cpp @@ -121,8 +121,8 @@ void SDRPostThread::run() { visualDataOut->busy_rw.lock(); visualDataOut->setRefCount(1); - if (num_vis_samples > data_in->data.size()) { - num_vis_samples = data_in->data.size(); + if (num_vis_samples > dataOut.size()) { + num_vis_samples = dataOut.size(); } if (visualDataOut->data.size() < num_vis_samples) { diff --git a/src/visual/WaterfallCanvas.cpp b/src/visual/WaterfallCanvas.cpp index 892b17f..2a52a11 100644 --- a/src/visual/WaterfallCanvas.cpp +++ b/src/visual/WaterfallCanvas.cpp @@ -68,6 +68,25 @@ void WaterfallCanvas::attachSpectrumCanvas(SpectrumCanvas *canvas_in) { spectrumCanvas = canvas_in; } +void WaterfallCanvas::processInputQueue() { + if (!glContext) { + return; + } + glContext->SetCurrent(*this); + + while (!visualDataQueue.empty()) { + SpectrumVisualData *vData; + + visualDataQueue.pop(vData); + + if (vData) { + waterfallPanel.setPoints(vData->spectrum_points); + waterfallPanel.step(); + vData->decRefCount(); + } + } +} + void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); @@ -139,18 +158,6 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { glContext->SetCurrent(*this); initGLExtensions(); glViewport(0, 0, ClientSize.x, ClientSize.y); - - while (!visualDataQueue.empty()) { - SpectrumVisualData *vData; - - visualDataQueue.pop(vData); - - if (vData) { - waterfallPanel.setPoints(vData->spectrum_points); - waterfallPanel.step(); - vData->decRefCount(); - } - } glContext->BeginDraw(0,0,0); diff --git a/src/visual/WaterfallCanvas.h b/src/visual/WaterfallCanvas.h index b570ffb..2f51ec3 100644 --- a/src/visual/WaterfallCanvas.h +++ b/src/visual/WaterfallCanvas.h @@ -26,6 +26,7 @@ public: DragState getNextDragState(); void attachSpectrumCanvas(SpectrumCanvas *canvas_in); + void processInputQueue(); SpectrumVisualDataQueue *getVisualDataQueue(); private: