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()
//-------------------------------------------------------------------------
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;
// 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,
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);
//
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;
}
{
next_state = 1;
}
- if(g_stats.fest_coarse_fine == 0)
+ if(g_stats.sync == 0)
{
next_state = 0;
}
case 2:
next_state = 1;
- if(g_stats.fest_coarse_fine == 0)
+ if(g_stats.sync == 0)
{
next_state = 0;
}
}
}
+ 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);
byte++;
}
}
- assert(byte == bytes_per_codec_frame);
// add decoded speech to end of output buffer
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);
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);
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) {
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 --- */
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);
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);