From 190fc36b8e768e83fc08857ae8ec09d5d8f17ebe Mon Sep 17 00:00:00 2001 From: drowe67 Date: Mon, 5 Nov 2012 00:23:51 +0000 Subject: [PATCH] added experimental waveform plots, the idea is to usethm as a tool to adjust levels. Not sure if they are useful yet... git-svn-id: https://svn.code.sf.net/p/freetel/code@928 01035d8c-6547-0410-b346-abe4f91aad63 --- fdmdv2/src/fdmdv2_defines.h | 7 ++++ fdmdv2/src/fdmdv2_main.cpp | 64 +++++++++++++++++++++++++++++- fdmdv2/src/fdmdv2_main.h | 10 +++-- fdmdv2/src/fdmdv2_plot_scatter.cpp | 2 +- 4 files changed, 76 insertions(+), 7 deletions(-) diff --git a/fdmdv2/src/fdmdv2_defines.h b/fdmdv2/src/fdmdv2_defines.h index 493e4346..64bf8c40 100644 --- a/fdmdv2/src/fdmdv2_defines.h +++ b/fdmdv2/src/fdmdv2_defines.h @@ -52,7 +52,14 @@ #define SCATTER_X_MAX 4.0 #define SCATTER_Y_MAX 4.0 +// Waveform plotting constants + +#define WAVEFORM_PLOT_FS 100 // sample rate (points/s) of waveform plotted to screen +#define WAVEFORM_PLOT_TIME 5 // length or entire waveform on screen +#define WAVEFORM_PLOT_BUF ((int)(DT*WAVEFORM_PLOT_FS)) // number of sample we add per update + // sample rate I/O & conversion constants + #define MAX_FPB 2048 // maximum value of portAudio framesPerBuffer #define PA_FPB 1024 // nominal value of portAudio framesPerBuffer #define SAMPLE_RATE 48000 // 48 kHz sampling rate rec. as we can trust accuracy of sound card diff --git a/fdmdv2/src/fdmdv2_main.cpp b/fdmdv2/src/fdmdv2_main.cpp index 00f82085..8d997df6 100644 --- a/fdmdv2/src/fdmdv2_main.cpp +++ b/fdmdv2/src/fdmdv2_main.cpp @@ -39,6 +39,9 @@ struct CODEC2 *g_pCodec2; struct FDMDV *g_pFDMDV; struct FDMDV_STATS g_stats; +short g_speechIn[WAVEFORM_PLOT_BUF]; +short g_speechOut[WAVEFORM_PLOT_BUF]; +short g_demodIn[WAVEFORM_PLOT_BUF]; int g_nSoundCards = 2; @@ -151,6 +154,10 @@ MainFrame::MainFrame(wxWindow *parent) : TopFrame(parent) wxGetApp().m_show_scatter = pConfig->Read(wxT("/MainFrame/show_scatter"), 1); wxGetApp().m_show_timing = pConfig->Read(wxT("/MainFrame/show_timing"), 1); wxGetApp().m_show_freq = pConfig->Read(wxT("/MainFrame/show_freq"), 1); + wxGetApp().m_show_speech_in = pConfig->Read(wxT("/MainFrame/show_speech_in"), 1); + wxGetApp().m_show_speech_out = pConfig->Read(wxT("/MainFrame/show_speech_out"), 1); + wxGetApp().m_show_demod_in = pConfig->Read(wxT("/MainFrame/show_demod_in"), 1); + Move(x, y); SetClientSize(w, h); @@ -184,6 +191,31 @@ MainFrame::MainFrame(wxWindow *parent) : TopFrame(parent) m_panelFreqOffset = new PlotScalar((wxFrame*) m_auiNbookCtrl, 5.0, DT, -200, 200, 1, 50, "%3fHz"); m_auiNbookCtrl->AddPage(m_panelFreqOffset, L"Frequency \u0394", true, wxNullBitmap); } + + 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"); + m_auiNbookCtrl->AddPage(m_panelSpeechIn, _("Speech In"), true, wxNullBitmap); + } + + 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"); + m_auiNbookCtrl->AddPage(m_panelSpeechOut, _("Speech Out"), true, wxNullBitmap); + } + + 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"); + m_auiNbookCtrl->AddPage(m_panelDemodIn, _("Demod In"), true, wxNullBitmap); + } + wxGetApp().m_strRxInAudio = pConfig->Read(wxT("/Audio/RxIn"), wxT("")); wxGetApp().m_strRxOutAudio = pConfig->Read(wxT("/Audio/RxOut"), wxT("")); wxGetApp().m_textVoiceInput = pConfig->Read(wxT("/Audio/TxIn"), wxT("")); @@ -253,6 +285,9 @@ MainFrame::~MainFrame() pConfig->Write(wxT("/MainFrame/show_scatter"), wxGetApp().m_show_scatter); pConfig->Write(wxT("/MainFrame/show_timing"), wxGetApp().m_show_timing); pConfig->Write(wxT("/MainFrame/show_freq"), wxGetApp().m_show_freq); + pConfig->Write(wxT("/MainFrame/show_speech_in"),wxGetApp().m_show_speech_in); + pConfig->Write(wxT("/MainFrame/show_speech_out"),wxGetApp().m_show_speech_out); + pConfig->Write(wxT("/MainFrame/show_demod_in"),wxGetApp().m_show_demod_in); pConfig->Write(wxT("/Audio/RxIn"), wxGetApp().m_strRxInAudio); pConfig->Write(wxT("/Audio/RxOut"), wxGetApp().m_strRxOutAudio); @@ -309,9 +344,25 @@ void MainFrame::OnTimer(wxTimerEvent &evt) m_panelTimeOffset->add_new_sample((float)g_stats.rx_timing/FDMDV_NOM_SAMPLES_PER_FRAME); m_panelTimeOffset->Refresh(); - + m_panelFreqOffset->add_new_sample(g_stats.foff); m_panelFreqOffset->Refresh(); + + int nsam = DT*WAVEFORM_PLOT_FS; + for(int i=0; iadd_new_sample((float)g_speechIn[i]/32767); + } + m_panelSpeechIn->Refresh(); + + for(int i=0; iadd_new_sample((float)g_speechOut[i]/32767); + } + m_panelSpeechOut->Refresh(); + + for(int i=0; iadd_new_sample((float)g_demodIn[i]/32767); + } + m_panelDemodIn->Refresh(); } #endif @@ -1355,7 +1406,10 @@ int MainFrame::rxCallback( n8k = resample(cbData->insrc1, in8k_short, in48k_short, FS, g_soundCard1SampleRate, N8, N48); fifo_write(cbData->rxinfifo, in8k_short, n8k); - per_frame_rx_processing(cbData->rxoutfifo, g_CodecBits, cbData->rxinfifo, &g_nRxIn, &g_State, g_pCodec2); + assert(sizeof(g_demodIn) <= sizeof(in8k_short)); + memcpy(g_demodIn, in8k_short, sizeof(g_demodIn)); // undersampled buffer for plotting + + per_frame_rx_processing(cbData->rxoutfifo, g_CodecBits, cbData->rxinfifo, &g_nRxIn, &g_State, g_pCodec2); // if demod out of sync just pass thru audio so we can hear // SSB radio ouput as an aid to tuning @@ -1367,6 +1421,9 @@ int MainFrame::rxCallback( fifo_read(cbData->rxoutfifo, out8k_short, N8); } + assert(sizeof(g_speechOut) <= sizeof(out8k_short)); + memcpy(g_speechOut, out8k_short, sizeof(g_speechOut)); // undersampled buffer for plotting + if (g_nSoundCards == 1) { nout = resample(cbData->outsrc2, out48k_short, out8k_short, g_soundCard1SampleRate, FS, N48, N8); fifo_write(cbData->outfifo1, out48k_short, nout); @@ -1415,6 +1472,9 @@ int MainFrame::rxCallback( nout = resample(cbData->insrc2, in8k_short, in48k_short, FS, g_soundCard2SampleRate, 2*N8, nsam); + assert(sizeof(g_speechIn) <= sizeof(in8k_short)); + memcpy(g_speechIn, in8k_short, sizeof(g_speechIn)); // undersampled buffer for plotting + if (write_file) { fwrite( in8k_short, sizeof(short), nout, g_write_file); } diff --git a/fdmdv2/src/fdmdv2_main.h b/fdmdv2/src/fdmdv2_main.h index 80775beb..ca591f87 100644 --- a/fdmdv2/src/fdmdv2_main.h +++ b/fdmdv2/src/fdmdv2_main.h @@ -42,11 +42,7 @@ #include "fdmdv2_plot.h" #include "fdmdv2_plot_scalar.h" #include "fdmdv2_plot_scatter.h" -//#ifdef __LINUX__ #include "fdmdv2_plot_waterfall_linux.h" -//#else -//#include "fdmdv2_plot_waterfall.h" -//#endif #include "fdmdv2_plot_spectrum.h" #include "fdmdv2_pa_wrapper.h" #include "sndfile.h" @@ -112,6 +108,9 @@ class MainApp : public wxApp int m_show_scatter; int m_show_timing; int m_show_freq; + int m_show_speech_in; + int m_show_speech_out; + int m_show_demod_in; wxRect m_rTopWindow; @@ -177,6 +176,9 @@ class MainFrame : public TopFrame PlotScatter* m_panelScatter; PlotScalar* m_panelTimeOffset; PlotScalar* m_panelFreqOffset; + PlotScalar* m_panelSpeechIn; + PlotScalar* m_panelSpeechOut; + PlotScalar* m_panelDemodIn; bool m_SquelchActive; bool m_RxRunning; bool m_TxRunning; diff --git a/fdmdv2/src/fdmdv2_plot_scatter.cpp b/fdmdv2/src/fdmdv2_plot_scatter.cpp index 86662dc3..d1aa38bb 100644 --- a/fdmdv2/src/fdmdv2_plot_scatter.cpp +++ b/fdmdv2/src/fdmdv2_plot_scatter.cpp @@ -43,7 +43,7 @@ END_EVENT_TABLE() PlotScatter::PlotScatter(wxFrame* parent) : PlotPanel(parent) { int i; - printf("PlotScatter\n"); + for(i=0; i < SCATTER_MEM_SYMS; i++) { m_mem[i].real = 0.0; -- 2.25.1