wxBoxSizer* bSizer1 = new wxBoxSizer(wxVERTICAL);
wxPanel *panel = new wxPanel(parentPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0);
- *plotScalar = new PlotScalar((wxFrame*) panel, TEST_WAVEFORM_PLOT_TIME, 1.0/TEST_WAVEFORM_PLOT_FS, -1, 1, 1, 0.2, "", 1);
+ *plotScalar = new PlotScalar((wxFrame*) panel, 1, TEST_WAVEFORM_PLOT_TIME, 1.0/TEST_WAVEFORM_PLOT_FS, -1, 1, 1, 0.2, "", 1);
(*plotScalar)->SetClientSize(wxSize(TEST_WAVEFORM_X,TEST_WAVEFORM_Y));
bSizer1->Add(panel, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 8);
short plotSamples[TEST_WAVEFORM_PLOT_BUF];
if (fifo_read(fifo, plotSamples, TEST_WAVEFORM_PLOT_BUF))
memset(plotSamples, 0, TEST_WAVEFORM_PLOT_BUF*sizeof(short));
- plotScalar->add_new_short_samples(plotSamples, TEST_WAVEFORM_PLOT_BUF, 32767);
+ plotScalar->add_new_short_samples(0, plotSamples, TEST_WAVEFORM_PLOT_BUF, 32767);
plotScalar->Refresh();
}
}
short plotSamples[TEST_WAVEFORM_PLOT_BUF];
if (fifo_read(fifo, plotSamples, TEST_WAVEFORM_PLOT_BUF))
memset(plotSamples, 0, TEST_WAVEFORM_PLOT_BUF*sizeof(short));
- plotScalar->add_new_short_samples(plotSamples, TEST_WAVEFORM_PLOT_BUF, 32767);
+ plotScalar->add_new_short_samples(0, plotSamples, TEST_WAVEFORM_PLOT_BUF, 32767);
plotScalar->Refresh();
}
}
if(wxGetApp().m_show_demod_in)
{
// Add Demod Input window
- m_panelDemodIn = new PlotScalar((wxFrame*) m_auiNbookCtrl, WAVEFORM_PLOT_TIME, 1.0/WAVEFORM_PLOT_FS, -1, 1, 1, 0.2, "%2.1f", 0);
+ m_panelDemodIn = new PlotScalar((wxFrame*) m_auiNbookCtrl, 1, WAVEFORM_PLOT_TIME, 1.0/WAVEFORM_PLOT_FS, -1, 1, 1, 0.2, "%2.1f", 0);
m_auiNbookCtrl->AddPage(m_panelDemodIn, _("Frm Radio"), true, wxNullBitmap);
g_plotDemodInFifo = fifo_create(2*WAVEFORM_PLOT_BUF);
}
if(wxGetApp().m_show_speech_in)
{
// Add Speech Input window
- m_panelSpeechIn = new PlotScalar((wxFrame*) m_auiNbookCtrl, WAVEFORM_PLOT_TIME, 1.0/WAVEFORM_PLOT_FS, -1, 1, 1, 0.2, "%2.1f", 0);
+ m_panelSpeechIn = new PlotScalar((wxFrame*) m_auiNbookCtrl, 1, WAVEFORM_PLOT_TIME, 1.0/WAVEFORM_PLOT_FS, -1, 1, 1, 0.2, "%2.1f", 0);
m_auiNbookCtrl->AddPage(m_panelSpeechIn, _("Frm Mic"), true, wxNullBitmap);
g_plotSpeechInFifo = fifo_create(2*WAVEFORM_PLOT_BUF);
}
if(wxGetApp().m_show_speech_out)
{
// Add Speech Output window
- m_panelSpeechOut = new PlotScalar((wxFrame*) m_auiNbookCtrl, WAVEFORM_PLOT_TIME, 1.0/WAVEFORM_PLOT_FS, -1, 1, 1, 0.2, "%2.1f", 0);
+ m_panelSpeechOut = new PlotScalar((wxFrame*) m_auiNbookCtrl, 1, WAVEFORM_PLOT_TIME, 1.0/WAVEFORM_PLOT_FS, -1, 1, 1, 0.2, "%2.1f", 0);
m_auiNbookCtrl->AddPage(m_panelSpeechOut, _("To Spkr/Hdphns"), true, wxNullBitmap);
g_plotSpeechOutFifo = fifo_create(2*WAVEFORM_PLOT_BUF);
}
if(wxGetApp().m_show_timing)
{
// Add Timing Offset window
- m_panelTimeOffset = new PlotScalar((wxFrame*) m_auiNbookCtrl, 5.0, DT, -0.5, 0.5, 1, 0.1, "%2.1f", 0);
+ m_panelTimeOffset = new PlotScalar((wxFrame*) m_auiNbookCtrl, 1, 5.0, DT, -0.5, 0.5, 1, 0.1, "%2.1f", 0);
m_auiNbookCtrl->AddPage(m_panelTimeOffset, L"Timing \u0394", true, wxNullBitmap);
}
if(wxGetApp().m_show_freq)
{
// Add Frequency Offset window
- m_panelFreqOffset = new PlotScalar((wxFrame*) m_auiNbookCtrl, 5.0, DT, -200, 200, 1, 50, "%3.0fHz", 0);
+ m_panelFreqOffset = new PlotScalar((wxFrame*) m_auiNbookCtrl, 1, 5.0, DT, -200, 200, 1, 50, "%3.0fHz", 0);
m_auiNbookCtrl->AddPage(m_panelFreqOffset, L"Frequency \u0394", true, wxNullBitmap);
}
short speechInPlotSamples[WAVEFORM_PLOT_BUF];
if (fifo_read(g_plotSpeechInFifo, speechInPlotSamples, WAVEFORM_PLOT_BUF))
memset(speechInPlotSamples, 0, WAVEFORM_PLOT_BUF*sizeof(short));
- m_panelSpeechIn->add_new_short_samples(speechInPlotSamples, WAVEFORM_PLOT_BUF, 32767);
+ m_panelSpeechIn->add_new_short_samples(0, speechInPlotSamples, WAVEFORM_PLOT_BUF, 32767);
m_panelSpeechIn->Refresh();
short speechOutPlotSamples[WAVEFORM_PLOT_BUF];
if (fifo_read(g_plotSpeechOutFifo, speechOutPlotSamples, WAVEFORM_PLOT_BUF))
memset(speechOutPlotSamples, 0, WAVEFORM_PLOT_BUF*sizeof(short));
- m_panelSpeechOut->add_new_short_samples(speechOutPlotSamples, WAVEFORM_PLOT_BUF, 32767);
+ m_panelSpeechOut->add_new_short_samples(0, speechOutPlotSamples, WAVEFORM_PLOT_BUF, 32767);
m_panelSpeechOut->Refresh();
short demodInPlotSamples[WAVEFORM_PLOT_BUF];
if (fifo_read(g_plotDemodInFifo, demodInPlotSamples, WAVEFORM_PLOT_BUF))
memset(demodInPlotSamples, 0, WAVEFORM_PLOT_BUF*sizeof(short));
- m_panelDemodIn->add_new_short_samples(demodInPlotSamples, WAVEFORM_PLOT_BUF, 32767);
+ m_panelDemodIn->add_new_short_samples(0,demodInPlotSamples, WAVEFORM_PLOT_BUF, 32767);
m_panelDemodIn->Refresh();
// Demod states -----------------------------------------------------------------------
- m_panelTimeOffset->add_new_sample((float)g_stats.rx_timing/FDMDV_NOM_SAMPLES_PER_FRAME);
+ m_panelTimeOffset->add_new_sample(0, (float)g_stats.rx_timing/FDMDV_NOM_SAMPLES_PER_FRAME);
m_panelTimeOffset->Refresh();
- m_panelFreqOffset->add_new_sample(g_stats.foff);
+ m_panelFreqOffset->add_new_sample(0, g_stats.foff);
m_panelFreqOffset->Refresh();
// SNR text box and gauge ------------------------------------------------------------
// PlotScalar()
//----------------------------------------------------------------
PlotScalar::PlotScalar(wxFrame* parent,
+ int channels, // number on channel to plot
float t_secs, // time covered by entire x axis in seconds
float sample_period_secs, // time between each sample in seconds
float a_min, // min ampltude of samples being plotted
m_rCtrl = GetClientRect();
+ m_channels = channels;
m_t_secs = t_secs;
m_sample_period_secs = sample_period_secs;
m_a_min = a_min;
// work out number of samples we will store and allocate storage
m_samples = m_t_secs/m_sample_period_secs;
- m_mem = new float[m_samples];
+ m_mem = new float[m_samples*m_channels];
- for(i = 0; i < m_samples; i++)
+ for(i = 0; i < m_samples*m_channels; i++)
{
m_mem[i] = 0.0;
}
//----------------------------------------------------------------
// add_new_sample()
//----------------------------------------------------------------
-void PlotScalar::add_new_sample(float sample)
+void PlotScalar::add_new_sample(int channel, float sample)
{
int i;
+ int offset = channel*m_samples;
+
+ assert(channel < m_channels);
for(i = 0; i < m_samples-1; i++)
{
- m_mem[i] = m_mem[i+1];
+ m_mem[offset+i] = m_mem[offset+i+1];
}
- m_mem[m_samples-1] = sample;
+ m_mem[offset+m_samples-1] = sample;
}
//----------------------------------------------------------------
// add_new_samples()
//----------------------------------------------------------------
-void PlotScalar::add_new_short_samples(short samples[], int length, float scale_factor)
+void PlotScalar::add_new_short_samples(int channel, short samples[], int length, float scale_factor)
{
int i;
+ int offset = channel*m_samples;
+
+ assert(channel < m_channels);
for(i = 0; i < m_samples-length; i++)
- m_mem[i] = m_mem[i+length];
+ m_mem[offset+i] = m_mem[offset+i+length];
for(; i < m_samples; i++)
- m_mem[i] = (float)*samples++/scale_factor;
+ m_mem[offset+i] = (float)*samples++/scale_factor;
}
//----------------------------------------------------------------
prev_x = prev_y = 0; // stop warning
- for(i = 0; i < m_samples; i++)
- {
- x = index_to_px * i;
- a = m_mem[i];
- if (a < m_a_min) a = m_a_min;
- if (a > m_a_max) a = m_a_max;
+ // plot each channel
- // invert y axis and offset by minimum
+ int offset;
+ for(offset=0; offset<m_channels*m_samples; offset+=m_samples) {
- y = m_rGrid.GetHeight() - a_to_py * a + m_a_min*a_to_py;
+ for(i = 0; i < m_samples; i++) {
+ x = index_to_px * i;
+ a = m_mem[offset+i];
+ if (a < m_a_min) a = m_a_min;
+ if (a > m_a_max) a = m_a_max;
- // put inside plot window
+ // invert y axis and offset by minimum
- if (!m_mini) {
- x += PLOT_BORDER + XLEFT_OFFSET;
- y += PLOT_BORDER;
- }
+ y = m_rGrid.GetHeight() - a_to_py * a + m_a_min*a_to_py;
+
+ // put inside plot window
- if (i)
- dc.DrawLine(x, y, prev_x, prev_y);
- prev_x = x; prev_y = y;
+ if (!m_mini) {
+ x += PLOT_BORDER + XLEFT_OFFSET;
+ y += PLOT_BORDER;
+ }
+
+ if (i)
+ dc.DrawLine(x, y, prev_x, prev_y);
+ prev_x = x; prev_y = y;
+ }
}
drawGraticule(dc);