diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index beb251f..ce3ad1f 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -123,6 +123,8 @@ void AppFrame::OnIdle(wxIdleEvent& event) { scopeCanvas->waveform_points[i * 2] = ((double) i / (double) iMax); } + scopeCanvas->setDivider(demodAudioData->channels == 2); + delete demodAudioData; } else { std::cout << "Incoming Demodulator data empty?" << std::endl; diff --git a/src/demod/DemodulatorInstance.cpp b/src/demod/DemodulatorInstance.cpp index 746468e..9650f01 100644 --- a/src/demod/DemodulatorInstance.cpp +++ b/src/demod/DemodulatorInstance.cpp @@ -2,7 +2,7 @@ DemodulatorInstance::DemodulatorInstance() : 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"); threadQueueDemod = new DemodulatorThreadInputQueue; diff --git a/src/demod/DemodulatorThread.cpp b/src/demod/DemodulatorThread.cpp index 1747587..b501def 100644 --- a/src/demod/DemodulatorThread.cpp +++ b/src/demod/DemodulatorThread.cpp @@ -186,6 +186,7 @@ void DemodulatorThread::threadMain() { stereoSize = DEMOD_VIS_SIZE; } ati_vis->data.resize(stereoSize); + ati_vis->channels = stereo?2:1; for (int i = 0; i < stereoSize / 2; i++) { ati_vis->data[i] = (resampled_audio_output[i] - (resampled_audio_output_stereo[i])); diff --git a/src/visual/ScopeCanvas.cpp b/src/visual/ScopeCanvas.cpp index 54db54d..76071ed 100644 --- a/src/visual/ScopeCanvas.cpp +++ b/src/visual/ScopeCanvas.cpp @@ -21,7 +21,7 @@ wxEND_EVENT_TABLE() ScopeCanvas::ScopeCanvas(wxWindow *parent, int *attribList) : 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)); timer.start(); @@ -35,6 +35,10 @@ void ScopeCanvas::setWaveformPoints(std::vector &waveform_points_in) { waveform_points = waveform_points_in; } +void ScopeCanvas::setDivider(bool state) { + divider = state; +} + void ScopeCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); const wxSize ClientSize = GetClientSize(); @@ -42,7 +46,12 @@ void ScopeCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { glContext->SetCurrent(*this); glViewport(0, 0, ClientSize.x, ClientSize.y); + glContext->DrawBegin(); glContext->Plot(waveform_points); + if (divider) { + glContext->DrawDivider(); + } + glContext->DrawEnd(); SwapBuffers(); } diff --git a/src/visual/ScopeCanvas.h b/src/visual/ScopeCanvas.h index 9cd40f9..26ace11 100644 --- a/src/visual/ScopeCanvas.h +++ b/src/visual/ScopeCanvas.h @@ -19,6 +19,7 @@ public: ~ScopeCanvas(); void setWaveformPoints(std::vector &waveform_points_in); + void setDivider(bool state); private: void OnPaint(wxPaintEvent& event); @@ -29,6 +30,7 @@ private: ScopeContext *glContext; Timer timer; float frameTimer; + bool divider; // event table wxDECLARE_EVENT_TABLE(); }; diff --git a/src/visual/ScopeContext.cpp b/src/visual/ScopeContext.cpp index 2b1937f..5c1badd 100644 --- a/src/visual/ScopeContext.cpp +++ b/src/visual/ScopeContext.cpp @@ -4,36 +4,47 @@ ScopeContext::ScopeContext(ScopeCanvas *canvas, wxGLContext *sharedContext) : PrimaryGLContext(canvas, sharedContext) { - glDisable(GL_CULL_FACE); - glDisable(GL_DEPTH_TEST); + glDisable (GL_CULL_FACE); + glDisable (GL_DEPTH_TEST); - glMatrixMode(GL_PROJECTION); + glMatrixMode (GL_PROJECTION); glLoadIdentity(); } -void ScopeContext::Plot(std::vector &points) { +void ScopeContext::DrawBegin() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glMatrixMode(GL_MODELVIEW); + glMatrixMode (GL_MODELVIEW); glLoadIdentity(); - glDisable(GL_TEXTURE_2D); + glDisable (GL_TEXTURE_2D); +} +void ScopeContext::Plot(std::vector &points) { glColor3f(1.0, 1.0, 1.0); if (points.size()) { glPushMatrix(); glTranslatef(-1.0f, 0.0f, 0.0f); glScalef(2.0f, 2.0f, 1.0f); - glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState (GL_VERTEX_ARRAY); glVertexPointer(2, GL_FLOAT, 0, &points[0]); glDrawArrays(GL_LINE_STRIP, 0, points.size() / 2); glDisableClientState(GL_VERTEX_ARRAY); glPopMatrix(); } +} - +void ScopeContext::DrawEnd() { glFlush(); 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(); +} diff --git a/src/visual/ScopeContext.h b/src/visual/ScopeContext.h index 41cad0d..6f001b0 100644 --- a/src/visual/ScopeContext.h +++ b/src/visual/ScopeContext.h @@ -11,7 +11,10 @@ class ScopeContext: public PrimaryGLContext { public: ScopeContext(ScopeCanvas *canvas, wxGLContext *sharedContext); + void DrawBegin(); void Plot(std::vector &points); + void DrawDivider(); + void DrawEnd(); private: };