From 5439f4147c42b4b87c2f8d5104590b55776c7e28 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Mon, 18 Mar 2013 07:30:28 +0000 Subject: [PATCH] removed clip, added new 1600 bit/s mode (1300+FEC) git-svn-id: https://svn.code.sf.net/p/freetel/code@1213 01035d8c-6547-0410-b346-abe4f91aad63 --- fdmdv2/src/fdmdv2_main.cpp | 100 +++++++++++++++++++++++++------------ fdmdv2/src/fdmdv2_main.h | 1 - fdmdv2/src/topFrame.cpp | 7 --- fdmdv2/src/topFrame.h | 3 -- fdmdv2/src/version.h | 2 +- 5 files changed, 70 insertions(+), 43 deletions(-) diff --git a/fdmdv2/src/fdmdv2_main.cpp b/fdmdv2/src/fdmdv2_main.cpp index af9b6bd6..782d48f0 100644 --- a/fdmdv2/src/fdmdv2_main.cpp +++ b/fdmdv2/src/fdmdv2_main.cpp @@ -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> (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> (10-j)) & 0x1; + } + } + + /* if in test frame mode replace codec payload data with test frames */ if (g_testFrames) { diff --git a/fdmdv2/src/fdmdv2_main.h b/fdmdv2/src/fdmdv2_main.h index bed6ea2c..ea1bcc3c 100644 --- a/fdmdv2/src/fdmdv2_main.h +++ b/fdmdv2/src/fdmdv2_main.h @@ -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); diff --git a/fdmdv2/src/topFrame.cpp b/fdmdv2/src/topFrame.cpp index 5a74c757..36b03f76 100644 --- a/fdmdv2/src/topFrame.cpp +++ b/fdmdv2/src/topFrame.cpp @@ -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); diff --git a/fdmdv2/src/topFrame.h b/fdmdv2/src/topFrame.h index 5a4489c0..70b04167 100644 --- a/fdmdv2/src/topFrame.h +++ b/fdmdv2/src/topFrame.h @@ -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(); } diff --git a/fdmdv2/src/version.h b/fdmdv2/src/version.h index 60494ab2..8df71b07 100644 --- a/fdmdv2/src/version.h +++ b/fdmdv2/src/version.h @@ -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 -- 2.25.1