first pass at option to introduce interfering carrier
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 5 Mar 2017 09:14:14 +0000 (09:14 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 5 Mar 2017 09:14:14 +0000 (09:14 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@3056 01035d8c-6547-0410-b346-abe4f91aad63

freedv-dev/src/dlg_options.cpp
freedv-dev/src/dlg_options.h
freedv-dev/src/fdmdv2_main.cpp
freedv-dev/src/fdmdv2_main.h

index 27e1b0d0d6d5badfba1412a98edb6142f2c95ce4..b42464084526474d99428ea8e88ebb52124b3392 100644 (file)
@@ -58,6 +58,25 @@ OptionsDlg::OptionsDlg(wxWindow* parent, wxWindowID id, const wxString& title, c
 
     bSizer30->Add(sbSizer_testFrames,0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND, 3);
 
+    //------------------------------
+    // Interfering tone
+    //------------------------------
+
+    wxStaticBoxSizer* sbSizer_tone;
+    wxStaticBox *sb_tone = new wxStaticBox(this, wxID_ANY, _("Simulated Interference Tone"));
+    sbSizer_tone = new wxStaticBoxSizer(sb_tone, wxHORIZONTAL);
+
+    m_ckboxTone = new wxCheckBox(this, wxID_ANY, _("Tone   Freq (Hz):"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE);
+    sbSizer_tone->Add(m_ckboxTone, 0, wxALIGN_LEFT, 0);
+    m_txtToneFreqHz = new wxTextCtrl(this, wxID_ANY,  "1000", wxDefaultPosition, wxSize(60,-1), 0, wxTextValidator(wxFILTER_DIGITS));
+    sbSizer_tone->Add(m_txtToneFreqHz, 0, wxALIGN_LEFT, 0);
+    wxStaticText *m_staticTextta = new wxStaticText(this, wxID_ANY, _(" Amplitude (pk): "), wxDefaultPosition, wxDefaultSize, 0);
+    sbSizer_tone->Add(m_staticTextta, 0, wxALIGN_CENTER_VERTICAL, 5);    
+    m_txtToneAmplitude = new wxTextCtrl(this, wxID_ANY,  "1000", wxDefaultPosition, wxSize(60,-1), 0, wxTextValidator(wxFILTER_DIGITS));
+    sbSizer_tone->Add(m_txtToneAmplitude, 0, wxALIGN_LEFT, 0);
+
+    bSizer30->Add(sbSizer_tone,0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND, 3);
+
     //------------------------------
     // FreeDV 700 Options
     //------------------------------
@@ -249,6 +268,10 @@ void OptionsDlg::ExchangeData(int inout, bool storePersistent)
         m_ckboxChannelNoise->SetValue(wxGetApp().m_channel_noise);
         m_txtNoiseSNR->SetValue(wxString::Format(wxT("%i"),wxGetApp().m_noise_snr));
 
+        m_ckboxTone->SetValue(wxGetApp().m_tone);
+        m_txtToneFreqHz->SetValue(wxString::Format(wxT("%i"),wxGetApp().m_tone_freq_hz));
+        m_txtToneAmplitude->SetValue(wxString::Format(wxT("%i"),wxGetApp().m_tone_amplitude));
+
         m_ckboxAttnCarrierEn->SetValue(wxGetApp().m_attn_carrier_en);
         m_txtAttnCarrier->SetValue(wxString::Format(wxT("%i"),wxGetApp().m_attn_carrier));
 
@@ -284,6 +307,14 @@ void OptionsDlg::ExchangeData(int inout, bool storePersistent)
         m_txtNoiseSNR->GetValue().ToLong(&noise_snr);
         wxGetApp().m_noise_snr = (int)noise_snr;
 
+        wxGetApp().m_tone    = m_ckboxTone->GetValue();
+        long tone_freq_hz, tone_amplitude;
+        m_txtToneFreqHz->GetValue().ToLong(&tone_freq_hz);
+        wxGetApp().m_tone_freq_hz = (int)tone_freq_hz;
+        m_txtToneAmplitude->GetValue().ToLong(&tone_amplitude);
+        wxGetApp().m_tone_amplitude = (int)tone_amplitude;
+
+
         wxGetApp().m_attn_carrier_en = m_ckboxAttnCarrierEn->GetValue();
         long attn_carrier;
         m_txtAttnCarrier->GetValue().ToLong(&attn_carrier);
index 1724a2f1a380c3fd2f1265d4a0e9141826e6c2b3..7bf5c85c5b5aedbd6f7331688db70d955d14e806 100644 (file)
@@ -33,7 +33,7 @@ class OptionsDlg : public wxDialog
     public:
     OptionsDlg( wxWindow* parent,
                wxWindowID id = wxID_ANY, const wxString& title = _("Options"), 
-                const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(600,630), 
+                const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(600,660), 
                long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
         ~OptionsDlg();
 
@@ -78,6 +78,10 @@ class OptionsDlg : public wxDialog
         wxCheckBox   *m_ckboxAttnCarrierEn;
         wxTextCtrl   *m_txtAttnCarrier;
 
+        wxCheckBox   *m_ckboxTone;
+        wxTextCtrl   *m_txtToneFreqHz;
+        wxTextCtrl   *m_txtToneAmplitude;
+
         wxCheckBox   *m_ckboxFreeDV700txClip;
         wxCheckBox   *m_ckboxFreeDV700Combine;
 
index 953fcb801b6b3930cb7b688dcc67ebfda94614f4..386512a731c9c41b47686ca7db05aaafacc3d207 100644 (file)
@@ -53,7 +53,8 @@ int                 g_resyncs;
 float               g_sig_pwr_av = 0.0;
 struct FIFO        *g_error_pattern_fifo;
 short              *g_error_hist, *g_error_histn;
+float               g_tone_phase;
+
 // time averaged magnitude spectrum used for waterfall and spectrum display
 float               g_avmag[MODEM_STATS_NSPEC];
 
@@ -504,6 +505,10 @@ MainFrame::MainFrame(wxString plugInName, wxWindow *parent) : TopFrame(plugInNam
     wxGetApp().m_attn_carrier_en = 0;
     wxGetApp().m_attn_carrier    = 0;
 
+    wxGetApp().m_tone = 0;
+    wxGetApp().m_tone_freq_hz = 1000;
+    wxGetApp().m_tone_amplitude = 500;
+
     int mode  = pConfig->Read(wxT("/Audio/mode"), (long)0);
     if (mode == 0)
         m_rb1600->SetValue(1);
@@ -594,6 +599,7 @@ MainFrame::MainFrame(wxString plugInName, wxWindow *parent) : TopFrame(plugInNam
     g_test_frame_sync_state = 0;
     g_resyncs = 0;
     wxGetApp().m_testFrames = false;
+    g_tone_phase = 0.0;
 
     g_modal = false;
 
@@ -3465,6 +3471,21 @@ void txRxProcessing()
             freedv_set_snr_squelch_thresh(g_pfreedv, g_SquelchLevel);
         }
 
+        // Optional tone interferer
+
+        if (wxGetApp().m_tone) {
+            float w = 2.0*M_PI*wxGetApp().m_tone_freq_hz/freedv_get_modem_sample_rate(g_pfreedv);
+            float s;
+            unsigned int i;
+            for(i=0; i<n8k; i++) {
+                s = (float)wxGetApp().m_tone_amplitude*cos(g_tone_phase);   
+                in8k_short[i] += (int)s;             
+                g_tone_phase += w;
+                //fprintf(stderr, "%f\n", s);
+            }
+            g_tone_phase -= 2.0*M_PI*floor(g_tone_phase/(2.0*M_PI));                                         
+        }
+
         //fprintf(g_logfile, "snr_squelch_thresh: %f\n",  g_pfreedv->snr_squelch_thresh);
 
         // compute rx spectrum - do here so update rate in constant
@@ -3728,14 +3749,18 @@ void per_frame_rx_processing(
             //fwrite(input_buf, sizeof(short), nin, ftest);
 
             // demod per frame processing
+
             for(i=0; i<nin; i++) {
                 rx_fdm[i].real = (float)input_buf[i];
                 rx_fdm[i].imag = 0.0;
             }
        
+            // Optional channel noise
+
             if (g_channel_noise) {
                 fdmdv_simulate_channel(&g_sig_pwr_av, rx_fdm, nin, wxGetApp().m_noise_snr);
             }
+
             freq_shift_coh(rx_fdm_offset, rx_fdm, g_RxFreqOffsetHz, freedv_get_modem_sample_rate(g_pfreedv), &g_RxFreqOffsetPhaseRect, nin);
             nout = freedv_comprx(g_pfreedv, output_buf, rx_fdm_offset);
             //kprintf("nout %d outbuf_buf[0]: %d\n", nout, output_buf[0]);
index c958d2961c56c6e7df5fc90ea6c86f99d9087d07..f14a758707c63cc89ba9a991a407575f86e38a32 100644 (file)
@@ -309,6 +309,13 @@ class MainApp : public wxApp
         bool       m_attn_carrier_en;
         int        m_attn_carrier;
 
+        // tone interferer simulation
+
+        bool       m_tone;
+        int        m_tone_freq_hz;
+        int        m_tone_amplitude;
+
+
     protected:
 };