Frame rate limiter

This commit is contained in:
Charles J. Cliffe
2014-11-16 23:20:48 -05:00
parent 3614c2ad9f
commit a7d7ec0d93
9 changed files with 412 additions and 6 deletions
+8 -2
View File
@@ -22,9 +22,10 @@ wxEND_EVENT_TABLE()
ScopeCanvas::ScopeCanvas(wxWindow *parent, int *attribList) :
wxGLCanvas(parent, wxID_ANY, attribList, wxDefaultPosition, wxDefaultSize,
wxFULL_REPAINT_ON_RESIZE), parent(parent) {
wxFULL_REPAINT_ON_RESIZE), parent(parent), frameTimer(0) {
glContext = new ScopeContext(this, &wxGetApp().GetContext(this));
timer.start();
}
ScopeCanvas::~ScopeCanvas() {
@@ -75,5 +76,10 @@ void ScopeCanvas::OnKeyDown(wxKeyEvent& event) {
}
void ScopeCanvas::OnIdle(wxIdleEvent &event) {
Refresh(false);
timer.update();
frameTimer += timer.lastUpdateSeconds();
if (frameTimer > 1.0/30.0) {
Refresh(false);
frameTimer = 0;
}
}
+3
View File
@@ -9,6 +9,7 @@
#include "ScopeContext.h"
#include "fftw3.h"
#include "Timer.h"
class ScopeCanvas: public wxGLCanvas {
public:
@@ -27,6 +28,8 @@ private:
wxWindow *parent;
ScopeContext *glContext;
Timer timer;
float frameTimer;
// event table
wxDECLARE_EVENT_TABLE();
};
+8 -2
View File
@@ -22,7 +22,7 @@ wxEND_EVENT_TABLE()
SpectrumCanvas::SpectrumCanvas(wxWindow *parent, int *attribList) :
wxGLCanvas(parent, wxID_ANY, attribList, wxDefaultPosition, wxDefaultSize,
wxFULL_REPAINT_ON_RESIZE), parent(parent) {
wxFULL_REPAINT_ON_RESIZE), parent(parent), frameTimer(0) {
int in_block_size = BUF_SIZE / 2;
int out_block_size = FFT_SIZE;
@@ -35,6 +35,7 @@ SpectrumCanvas::SpectrumCanvas(wxWindow *parent, int *attribList) :
fft_floor_ma = fft_floor_maa = 0.0;
glContext = new SpectrumContext(this, &wxGetApp().GetContext(this));
timer.start();
}
SpectrumCanvas::~SpectrumCanvas() {
@@ -152,5 +153,10 @@ void SpectrumCanvas::setData(std::vector<signed char> *data) {
}
void SpectrumCanvas::OnIdle(wxIdleEvent &event) {
Refresh(false);
timer.update();
frameTimer += timer.lastUpdateSeconds();
if (frameTimer > 1.0/30.0) {
Refresh(false);
frameTimer = 0;
}
}
+3
View File
@@ -9,6 +9,7 @@
#include "SpectrumContext.h"
#include "fftw3.h"
#include "Timer.h"
class SpectrumCanvas: public wxGLCanvas {
public:
@@ -36,6 +37,8 @@ private:
std::vector<float> fft_result_maa;
SpectrumContext *glContext;
Timer timer;
float frameTimer;
// event table
wxDECLARE_EVENT_TABLE();
};
+8 -2
View File
@@ -22,7 +22,7 @@ wxEND_EVENT_TABLE()
WaterfallCanvas::WaterfallCanvas(wxWindow *parent, int *attribList) :
wxGLCanvas(parent, wxID_ANY, attribList, wxDefaultPosition, wxDefaultSize,
wxFULL_REPAINT_ON_RESIZE), parent(parent) {
wxFULL_REPAINT_ON_RESIZE), parent(parent), frameTimer(0) {
int in_block_size = BUF_SIZE / 2;
int out_block_size = FFT_SIZE;
@@ -35,6 +35,7 @@ WaterfallCanvas::WaterfallCanvas(wxWindow *parent, int *attribList) :
fft_floor_ma = fft_floor_maa = 0.0;
glContext = new WaterfallContext(this, &wxGetApp().GetContext(this));
timer.start();
}
WaterfallCanvas::~WaterfallCanvas() {
@@ -150,5 +151,10 @@ void WaterfallCanvas::setData(std::vector<signed char> *data) {
}
void WaterfallCanvas::OnIdle(wxIdleEvent &event) {
Refresh(false);
timer.update();
frameTimer += timer.lastUpdateSeconds();
if (frameTimer > 1.0/30.0) {
Refresh(false);
frameTimer = 0;
}
}
+3
View File
@@ -9,6 +9,7 @@
#include "WaterfallContext.h"
#include "fftw3.h"
#include "Timer.h"
class WaterfallCanvas: public wxGLCanvas {
public:
@@ -36,6 +37,8 @@ private:
std::vector<float> fft_result_maa;
WaterfallContext *glContext;
Timer timer;
float frameTimer;
// event table
wxDECLARE_EVENT_TABLE();
};