removed clip, added new 1600 bit/s mode (1300+FEC)
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Mon, 18 Mar 2013 07:30:28 +0000 (07:30 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Mon, 18 Mar 2013 07:30:28 +0000 (07:30 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@1213 01035d8c-6547-0410-b346-abe4f91aad63

fdmdv2/src/fdmdv2_main.cpp
fdmdv2/src/fdmdv2_main.h
fdmdv2/src/topFrame.cpp
fdmdv2/src/topFrame.h
fdmdv2/src/version.h

index af9b6bd60509249d15e8964bb680f44622892427..782d48f0035ad2373e05eb86c213f5f52894b69e 100644 (file)
@@ -854,19 +854,6 @@ void MainFrame::OnCmdSliderScroll(wxScrollEvent& event)
     event.Skip();
 }
 
-//-------------------------------------------------------------------------
-// OnClipEnter()
-//-------------------------------------------------------------------------
-void MainFrame::OnClipEnter(wxCommandEvent& event)
-{
-    wxString clipStr = m_textCtrlClip->GetValue();
-    long value;
-    if(clipStr.ToLong(&value)) {
-        g_clip = (int)value;
-    }
-    printf("g_clip: %d\n", g_clip);
-}
-
 //-------------------------------------------------------------------------
 // OnCheckSQClick()
 //-------------------------------------------------------------------------
@@ -1599,7 +1586,7 @@ void MainFrame::OnTogBtnOnOff(wxCommandEvent& event)
         if (m_rb1600->GetValue()) {
             g_mode = MODE_1600;
             g_Nc = 16;
-            codec2_mode = CODEC2_MODE_1600;
+            codec2_mode = CODEC2_MODE_1300;
         }
         if (m_rb2000->GetValue()) {
             g_mode = MODE_2000;
@@ -1630,13 +1617,8 @@ void MainFrame::OnTogBtnOnOff(wxCommandEvent& event)
         // note: PAPR will still be worse for higher Nc, especially in frame test mode
 
         g_pwr_scale = sqrt((14.0+4.0)/(g_Nc+4.0));
-        wxString clipStr = m_textCtrlClip->GetValue();
-        long value;
-        if(clipStr.ToLong(&value)) {
-            g_clip = (int)value;
-        }
-        printf("g_clip: %d\n", g_clip);
-        
+        g_clip = 120;
+
         // init Codec 2 LPC Post Filter
 
         codec2_set_lpc_post_filter(g_pCodec2, 
@@ -2465,8 +2447,7 @@ void per_frame_rx_processing(
     assert(bits_per_fdmdv_frame <= MAX_BITS_PER_FDMDV_FRAME);
     bits_per_codec_frame = codec2_bits_per_frame(c2);
     assert(bits_per_codec_frame <= MAX_BITS_PER_CODEC_FRAME);
-    assert((bits_per_codec_frame % 8) == 0);
-    bytes_per_codec_frame = bits_per_codec_frame/8;
+    bytes_per_codec_frame = (bits_per_codec_frame+7)/8;
     assert(bytes_per_codec_frame <= MAX_BYTES_PER_CODEC_FRAME);
 
     //
@@ -2531,7 +2512,7 @@ void per_frame_rx_processing(
                     output_buf[i] = 0;
                 fifo_write(output_fifo, output_buf, N8);
 
-                if(g_stats.fest_coarse_fine == 1)
+                if(g_stats.sync == 1)
                 {
                     next_state = 1;
                 }
@@ -2549,7 +2530,7 @@ void per_frame_rx_processing(
                 {
                     next_state = 1;
                 }
-                if(g_stats.fest_coarse_fine == 0)
+                if(g_stats.sync == 0)
                 {
                     next_state = 0;
                 }
@@ -2557,7 +2538,7 @@ void per_frame_rx_processing(
 
             case 2:
                 next_state = 1;
-                if(g_stats.fest_coarse_fine == 0)
+                if(g_stats.sync == 0)
                 {
                     next_state = 0;
                 }
@@ -2640,6 +2621,34 @@ void per_frame_rx_processing(
                             }
                         }
 
+                        if (g_mode == MODE_1600) {
+                            int recd_codeword, codeword1, j;
+
+                            recd_codeword = 0;
+                            for(i=0; i<8; i++) {
+                                recd_codeword <<= 1;
+                                recd_codeword |= codec_bits[i];
+                            }
+                            for(i=11; i<15; i++) {
+                                recd_codeword <<= 1;
+                                recd_codeword |= codec_bits[i];
+                            }
+                            for(i=bits_per_codec_frame; i<bits_per_codec_frame+11; i++) {
+                                recd_codeword <<= 1;
+                                recd_codeword |= codec_bits[i];
+                            }
+                            codeword1 = golay23_decode(recd_codeword);
+                            //codeword1 = recd_codeword;
+                            //fprintf(stderr, "received codeword1: 0x%x  decoded codeword1: 0x%x\n", recd_codeword, codeword1);
+
+                            for(i=0; i<8; i++) {
+                                codec_bits[i] = (codeword1 >> (22-i)) & 0x1;
+                            }
+                            for(i=8,j=11; i<12; i++,j++) {
+                                codec_bits[j] = (codeword1 >> (22-i)) & 0x1;
+                            }
+                        }
+
                         // extract data bit ------------------------------------------------------------
 
                         data_flag_index = codec2_get_spare_bit_index(c2);
@@ -2676,7 +2685,6 @@ void per_frame_rx_processing(
                                         byte++;
                                     }
                             }
-                        assert(byte ==  bytes_per_codec_frame);
 
                         // add decoded speech to end of output buffer
 
@@ -2712,8 +2720,7 @@ void per_frame_tx_processing(
     assert(bits_per_fdmdv_frame <= MAX_BITS_PER_FDMDV_FRAME);
     bits_per_codec_frame = codec2_bits_per_frame(c2);
     assert(bits_per_codec_frame <= MAX_BITS_PER_CODEC_FRAME);
-    assert((bits_per_codec_frame % 8) == 0);
-    bytes_per_codec_frame = bits_per_codec_frame/8;
+    bytes_per_codec_frame = (bits_per_codec_frame+7)/8;
     assert(bytes_per_codec_frame <= MAX_BYTES_PER_CODEC_FRAME);
 
     codec2_encode(c2, packed_bits, input_buf);
@@ -2729,11 +2736,10 @@ void per_frame_tx_processing(
             byte++;
         }
     }
-    assert(byte == bytes_per_codec_frame);
 
     /* add data bit  ----------------------------------*/
 
-    // spare bit in 1400 bit/s frame that codec defines.  Use this 1
+    // spare bit in frame that codec defines.  Use this 1
     // bit/frame to send call sign data
 
     data_flag_index = codec2_get_spare_bit_index(c2);
@@ -2788,6 +2794,38 @@ void per_frame_tx_processing(
         assert(i <= 2*bits_per_fdmdv_frame);
     }
 
+    if (g_mode == MODE_1600) {
+        int data, codeword1;
+
+        /* Protect first 12 out of first 16 excitation bits with (23,12) Golay Code:
+
+           0,1,2,3: v[0]..v[3]
+           4,5,6,7: MSB of pitch
+           11,12,13,14: MSB of energy
+
+        */
+
+        data = 0;
+        for(i=0; i<8; i++) {
+            data <<= 1;
+            data |= bits[i];
+        }
+        for(i=11; i<15; i++) {
+            data <<= 1;
+            data |= bits[i];
+        }
+        codeword1 = golay23_encode(data);
+
+        /* now pack output frame with parity bits at end to make them
+           as far apart as possible from the data they protect.  Parity
+           bits are LSB of the Golay codeword */
+
+        for(j=0,i=bits_per_codec_frame; i<bits_per_codec_frame+11; i++,j++) {
+            bits[i] = (codeword1 >> (10-j)) & 0x1;
+        }
+    }
+
+
     /* if in test frame mode replace codec payload data with test frames */
 
     if (g_testFrames) {
index bed6ea2ceb0fda5c2b6478a65dd8965d7ef2f086..ea1bcc3c645a7dfcfe9e14548911f1dd2c054887 100644 (file)
@@ -393,7 +393,6 @@ class MainFrame : public TopFrame
 //        void OnSliderScrollTop( wxScrollEvent& event );
         void OnCheckSQClick( wxCommandEvent& event );
         void OnCheckSNRClick( wxCommandEvent& event );
-        void OnClipEnter( wxCommandEvent& event );
 
         // Toggle Buttons
         void OnTogBtnSplitClick(wxCommandEvent& event);
index 5a74c757dff701f215e45ac50289225b2558b6af..36b03f761c11a872771eeb70ba6e92f3d9fd5394 100644 (file)
@@ -278,9 +278,6 @@ TopFrame::TopFrame(wxWindow* parent, wxWindowID id, const wxString& title, const
     m_textBER = new wxStaticText(this, wxID_ANY, wxT("BER...: 0.0"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
     sbSizer_testFrames->Add(m_textBER, 0, wxALIGN_LEFT, 1);
 
-    m_textCtrlClip = new wxTextCtrl(this, wxID_ANY, _("120"), wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
-    sbSizer_testFrames->Add(m_textCtrlClip, 1, wxALIGN_LEFT, 1);
-
     rightSizer->Add(sbSizer_testFrames,0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND, 3);
 
     /* new --- */
@@ -451,8 +448,6 @@ TopFrame::TopFrame(wxWindow* parent, wxWindowID id, const wxString& title, const
 
     m_ckboxSNR->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(TopFrame::OnCheckSNRClick), NULL, this);
 
-    m_textCtrlClip->Connect(wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(TopFrame::OnClipEnter), NULL, this);
-
     m_togBtnOnOff->Connect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnOnOff), NULL, this);
     m_togBtnSplit->Connect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnSplitClick), NULL, this);
     m_togBtnAnalog->Connect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnAnalogClick), NULL, this);
@@ -502,8 +497,6 @@ TopFrame::~TopFrame()
     m_sliderSQ->Disconnect(wxEVT_SCROLL_TOP, wxScrollEventHandler(TopFrame::OnSliderScrollTop), NULL, this);
     m_ckboxSQ->Disconnect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(TopFrame::OnCheckSQClick), NULL, this);
 
-    m_textCtrlClip->Disconnect(wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(TopFrame::OnClipEnter), NULL, this);
-
     m_togBtnOnOff->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnOnOff), NULL, this);
     m_togBtnSplit->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnSplitClick), NULL, this);
     m_togBtnAnalog->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnAnalogClick), NULL, this);
index 5a4489c07939af1b9f5cc25d113e4bf100837abc..70b04167badd3e127f72e18f7de0b0777927858c 100644 (file)
@@ -97,7 +97,6 @@ class TopFrame : public wxFrame
         wxStaticText  *m_textBits;
         wxStaticText  *m_textErrors;
         wxStaticText  *m_textBER;
-        wxTextCtrl    *m_textCtrlClip;
 
         wxRadioButton *m_rbSync;
         wxRadioButton *m_rb1400old;
@@ -137,8 +136,6 @@ class TopFrame : public wxFrame
         virtual void OnCheckSQClick( wxCommandEvent& event ) { event.Skip(); }
         virtual void OnCheckSNRClick( wxCommandEvent& event ) { event.Skip(); }
 
-        virtual void OnClipEnter( wxCommandEvent& event ) { event.Skip(); }
-
         virtual void OnTogBtnLoopRx( wxCommandEvent& event ) { event.Skip(); }
         virtual void OnTogBtnLoopTx( wxCommandEvent& event ) { event.Skip(); }
         virtual void OnTogBtnOnOff( wxCommandEvent& event ) { event.Skip(); }
index 60494ab2d9ce1ba940bbf20d462fd2edab2e8c18..8df71b077d17aefd927ee01ceb70a4727edd96b6 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef FREEDV_VER_DOT_H
 #define FREEDV_VER_DOT_H 1
 
-#define FREEDV_VERSION "0.93 Beta"
+#define FREEDV_VERSION "0.94 Beta"
 
 #endif //FREEDV_VER_DOT_H