Show stereo divider
This commit is contained in:
parent
01eb62883b
commit
06103a2d1b
|
@ -123,6 +123,8 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
|
||||||
scopeCanvas->waveform_points[i * 2] = ((double) i / (double) iMax);
|
scopeCanvas->waveform_points[i * 2] = ((double) i / (double) iMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scopeCanvas->setDivider(demodAudioData->channels == 2);
|
||||||
|
|
||||||
delete demodAudioData;
|
delete demodAudioData;
|
||||||
} else {
|
} else {
|
||||||
std::cout << "Incoming Demodulator data empty?" << std::endl;
|
std::cout << "Incoming Demodulator data empty?" << std::endl;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
DemodulatorInstance::DemodulatorInstance() :
|
DemodulatorInstance::DemodulatorInstance() :
|
||||||
t_Demod(NULL), t_PreDemod(NULL), t_Audio(NULL), threadQueueDemod(NULL), demodulatorThread(NULL), terminated(false), audioTerminated(false), demodTerminated(
|
t_Demod(NULL), t_PreDemod(NULL), t_Audio(NULL), threadQueueDemod(NULL), demodulatorThread(NULL), terminated(false), audioTerminated(false), demodTerminated(
|
||||||
false), preDemodTerminated(false), active(false), squelch(false) {
|
false), preDemodTerminated(false), active(false), squelch(false), stereo(false) {
|
||||||
|
|
||||||
label = new std::string("Unnamed");
|
label = new std::string("Unnamed");
|
||||||
threadQueueDemod = new DemodulatorThreadInputQueue;
|
threadQueueDemod = new DemodulatorThreadInputQueue;
|
||||||
|
|
|
@ -186,6 +186,7 @@ void DemodulatorThread::threadMain() {
|
||||||
stereoSize = DEMOD_VIS_SIZE;
|
stereoSize = DEMOD_VIS_SIZE;
|
||||||
}
|
}
|
||||||
ati_vis->data.resize(stereoSize);
|
ati_vis->data.resize(stereoSize);
|
||||||
|
ati_vis->channels = stereo?2:1;
|
||||||
|
|
||||||
for (int i = 0; i < stereoSize / 2; i++) {
|
for (int i = 0; i < stereoSize / 2; i++) {
|
||||||
ati_vis->data[i] = (resampled_audio_output[i] - (resampled_audio_output_stereo[i]));
|
ati_vis->data[i] = (resampled_audio_output[i] - (resampled_audio_output_stereo[i]));
|
||||||
|
|
|
@ -21,7 +21,7 @@ wxEND_EVENT_TABLE()
|
||||||
|
|
||||||
ScopeCanvas::ScopeCanvas(wxWindow *parent, int *attribList) :
|
ScopeCanvas::ScopeCanvas(wxWindow *parent, int *attribList) :
|
||||||
wxGLCanvas(parent, wxID_ANY, attribList, wxDefaultPosition, wxDefaultSize,
|
wxGLCanvas(parent, wxID_ANY, attribList, wxDefaultPosition, wxDefaultSize,
|
||||||
wxFULL_REPAINT_ON_RESIZE), parent(parent), frameTimer(0) {
|
wxFULL_REPAINT_ON_RESIZE), parent(parent), frameTimer(0), divider(false) {
|
||||||
|
|
||||||
glContext = new ScopeContext(this, &wxGetApp().GetContext(this));
|
glContext = new ScopeContext(this, &wxGetApp().GetContext(this));
|
||||||
timer.start();
|
timer.start();
|
||||||
|
@ -35,6 +35,10 @@ void ScopeCanvas::setWaveformPoints(std::vector<float> &waveform_points_in) {
|
||||||
waveform_points = waveform_points_in;
|
waveform_points = waveform_points_in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScopeCanvas::setDivider(bool state) {
|
||||||
|
divider = state;
|
||||||
|
}
|
||||||
|
|
||||||
void ScopeCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
void ScopeCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
||||||
wxPaintDC dc(this);
|
wxPaintDC dc(this);
|
||||||
const wxSize ClientSize = GetClientSize();
|
const wxSize ClientSize = GetClientSize();
|
||||||
|
@ -42,7 +46,12 @@ void ScopeCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
||||||
glContext->SetCurrent(*this);
|
glContext->SetCurrent(*this);
|
||||||
glViewport(0, 0, ClientSize.x, ClientSize.y);
|
glViewport(0, 0, ClientSize.x, ClientSize.y);
|
||||||
|
|
||||||
|
glContext->DrawBegin();
|
||||||
glContext->Plot(waveform_points);
|
glContext->Plot(waveform_points);
|
||||||
|
if (divider) {
|
||||||
|
glContext->DrawDivider();
|
||||||
|
}
|
||||||
|
glContext->DrawEnd();
|
||||||
|
|
||||||
SwapBuffers();
|
SwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ public:
|
||||||
~ScopeCanvas();
|
~ScopeCanvas();
|
||||||
|
|
||||||
void setWaveformPoints(std::vector<float> &waveform_points_in);
|
void setWaveformPoints(std::vector<float> &waveform_points_in);
|
||||||
|
void setDivider(bool state);
|
||||||
private:
|
private:
|
||||||
void OnPaint(wxPaintEvent& event);
|
void OnPaint(wxPaintEvent& event);
|
||||||
|
|
||||||
|
@ -29,6 +30,7 @@ private:
|
||||||
ScopeContext *glContext;
|
ScopeContext *glContext;
|
||||||
Timer timer;
|
Timer timer;
|
||||||
float frameTimer;
|
float frameTimer;
|
||||||
|
bool divider;
|
||||||
// event table
|
// event table
|
||||||
wxDECLARE_EVENT_TABLE();
|
wxDECLARE_EVENT_TABLE();
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,36 +4,47 @@
|
||||||
|
|
||||||
ScopeContext::ScopeContext(ScopeCanvas *canvas, wxGLContext *sharedContext) :
|
ScopeContext::ScopeContext(ScopeCanvas *canvas, wxGLContext *sharedContext) :
|
||||||
PrimaryGLContext(canvas, sharedContext) {
|
PrimaryGLContext(canvas, sharedContext) {
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable (GL_CULL_FACE);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable (GL_DEPTH_TEST);
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode (GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopeContext::Plot(std::vector<float> &points) {
|
void ScopeContext::DrawBegin() {
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode (GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable (GL_TEXTURE_2D);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScopeContext::Plot(std::vector<float> &points) {
|
||||||
glColor3f(1.0, 1.0, 1.0);
|
glColor3f(1.0, 1.0, 1.0);
|
||||||
|
|
||||||
if (points.size()) {
|
if (points.size()) {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(-1.0f, 0.0f, 0.0f);
|
glTranslatef(-1.0f, 0.0f, 0.0f);
|
||||||
glScalef(2.0f, 2.0f, 1.0f);
|
glScalef(2.0f, 2.0f, 1.0f);
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState (GL_VERTEX_ARRAY);
|
||||||
glVertexPointer(2, GL_FLOAT, 0, &points[0]);
|
glVertexPointer(2, GL_FLOAT, 0, &points[0]);
|
||||||
glDrawArrays(GL_LINE_STRIP, 0, points.size() / 2);
|
glDrawArrays(GL_LINE_STRIP, 0, points.size() / 2);
|
||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScopeContext::DrawEnd() {
|
||||||
glFlush();
|
glFlush();
|
||||||
|
|
||||||
CheckGLError();
|
CheckGLError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScopeContext::DrawDivider() {
|
||||||
|
glColor3f(1.0, 1.0, 1.0);
|
||||||
|
glBegin(GL_LINES);
|
||||||
|
glVertex2f(0.0,-1.0);
|
||||||
|
glVertex2f(0.0,1.0);
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
|
|
|
@ -11,7 +11,10 @@ class ScopeContext: public PrimaryGLContext {
|
||||||
public:
|
public:
|
||||||
ScopeContext(ScopeCanvas *canvas, wxGLContext *sharedContext);
|
ScopeContext(ScopeCanvas *canvas, wxGLContext *sharedContext);
|
||||||
|
|
||||||
|
void DrawBegin();
|
||||||
void Plot(std::vector<float> &points);
|
void Plot(std::vector<float> &points);
|
||||||
|
void DrawDivider();
|
||||||
|
void DrawEnd();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue