mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-26 13:48:38 -05:00
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->setDivider(demodAudioData->channels == 2);
|
||||
|
||||
delete demodAudioData;
|
||||
} else {
|
||||
std::cout << "Incoming Demodulator data empty?" << std::endl;
|
||||
|
@ -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;
|
||||
|
@ -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]));
|
||||
|
@ -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<float> &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();
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ public:
|
||||
~ScopeCanvas();
|
||||
|
||||
void setWaveformPoints(std::vector<float> &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();
|
||||
};
|
||||
|
@ -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<float> &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<float> &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();
|
||||
}
|
||||
|
@ -11,7 +11,10 @@ class ScopeContext: public PrimaryGLContext {
|
||||
public:
|
||||
ScopeContext(ScopeCanvas *canvas, wxGLContext *sharedContext);
|
||||
|
||||
void DrawBegin();
|
||||
void Plot(std::vector<float> &points);
|
||||
void DrawDivider();
|
||||
void DrawEnd();
|
||||
|
||||
private:
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user