Improve input response time, balance visuals, fix a bug

This commit is contained in:
Charles J. Cliffe 2015-08-12 19:39:11 -04:00
parent 8bce632982
commit 33d51b2bff
6 changed files with 28 additions and 38 deletions

View File

@ -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();

View File

@ -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;

View File

@ -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

View File

@ -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) {

View File

@ -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);
@ -140,18 +159,6 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
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);
waterfallPanel.calcTransform(CubicVR::mat4::identity());

View File

@ -26,6 +26,7 @@ public:
DragState getNextDragState();
void attachSpectrumCanvas(SpectrumCanvas *canvas_in);
void processInputQueue();
SpectrumVisualDataQueue *getVisualDataQueue();
private: