From 0a9cb663e9259777e2012e87987c33f53cdd6a3e Mon Sep 17 00:00:00 2001 From: drowe67 Date: Wed, 17 Jun 2015 08:13:44 +0000 Subject: [PATCH] after a few hours merry chase transmit working at 700 and 1600 yayayay, coded up and debugging txt msgs git-svn-id: https://svn.code.sf.net/p/freetel/code@2201 01035d8c-6547-0410-b346-abe4f91aad63 --- fdmdv2-dev/README.txt | 12 ++++-- fdmdv2-dev/src/fdmdv2_main.cpp | 77 ++++++++++++++++++++++------------ fdmdv2-dev/src/fdmdv2_main.h | 3 ++ 3 files changed, 62 insertions(+), 30 deletions(-) diff --git a/fdmdv2-dev/README.txt b/fdmdv2-dev/README.txt index db34eefa..4df4cadb 100644 --- a/fdmdv2-dev/README.txt +++ b/fdmdv2-dev/README.txt @@ -152,13 +152,16 @@ TODO [X] varicode, codec, modem states [X] tx and rx freq shifts [X] generic, mode indep, sync, snr, scatter? - [ ] text working on 700 + [ ] text working on 700 and 1600 + [ ] char by char text appearing [ ] add 700 to freedv API [X] modem signal spectrum and stats consistent with fdmdv [X] rx from file works - [ ] tx works + [X] cohpsk snr est + [X] tx works in full duplex [ ] clipper a check box, so we can see difference in spectrum - [ ] cohpsk snr est + [ ] analog mode + + complicated by sample rate change [ ] squelch [ ] from radio plot broken [ ] freedv api @@ -181,9 +184,12 @@ TODO [X] option to _not_ require checksum, on by default [X] default squelch 2dB [ ] win32 X-compile + [ ] installer + [ ] works [ ] cmd line file decode [ ] Waterfall direction [ ] test mode on 1600 with freedv api + maybe calc stats, hist + [ ] from radio display breaking up [ ] Presence/spotting hooks diff --git a/fdmdv2-dev/src/fdmdv2_main.cpp b/fdmdv2-dev/src/fdmdv2_main.cpp index 1aa76fdd..5ffb347c 100644 --- a/fdmdv2-dev/src/fdmdv2_main.cpp +++ b/fdmdv2-dev/src/fdmdv2_main.cpp @@ -124,6 +124,7 @@ SpeexPreprocessState *g_speex_st; // WxWidgets - initialize the application IMPLEMENT_APP(MainApp); + //------------------------------------------------------------------------- // OnInit() //------------------------------------------------------------------------- @@ -485,11 +486,6 @@ MainFrame::MainFrame(wxWindow *parent) : TopFrame(parent) optionsDlg = new OptionsDlg(NULL); m_schedule_restore = false; - // Init Speex pre-processor states - // by inspecting Speex source it seems that only denoiser is on be default - - g_speex_st = speex_preprocess_state_init(2*N8, FS); - } //------------------------------------------------------------------------- @@ -951,23 +947,20 @@ void MainFrame::OnTimer(wxTimerEvent &evt) if ((unsigned)fifo_used(g_txDataInFifo) < strlen(callsign)) { unsigned char checksum = 0; - for(unsigned int i=0; icallback_state = NULL; + g_pfreedv->freedv_get_next_tx_char = &my_get_next_tx_char; + g_pfreedv->freedv_put_next_rx_char = &my_put_next_rx_char; + + //cohpsk_set_verbose(g_pfreedv->cohpsk, 1); assert(g_pfreedv != NULL); modem_stats_open(&g_stats); + // Init Speex pre-processor states + // by inspecting Speex source it seems that only denoiser is on be default + + g_speex_st = speex_preprocess_state_init(g_pfreedv->n_speech_samples, FS); + #ifdef TODO g_sz_error_pattern = fdmdv_error_pattern_size(g_pfreedv->fdmdv); g_error_pattern = (short*)malloc(g_sz_error_pattern*sizeof(short)); @@ -2048,7 +2051,7 @@ void MainFrame::OnTogBtnOnOff(wxCommandEvent& event) fifo_destroy(g_errorFifo); modem_stats_close(&g_stats); freedv_close(g_pfreedv); - + speex_preprocess_state_destroy(g_speex_st); m_newMicInFilter = m_newSpkOutFilter = true; m_togBtnSplit->Disable(); @@ -2324,7 +2327,7 @@ void MainFrame::startRxStream() // create FIFOs used to interface between different buffer sizes g_rxUserdata->infifo1 = fifo_create(8*N48); - g_rxUserdata->outfifo1 = fifo_create(8*N48); + g_rxUserdata->outfifo1 = fifo_create(10*N48); g_rxUserdata->outfifo2 = fifo_create(8*N48); g_rxUserdata->infifo2 = fifo_create(8*N48); @@ -2762,9 +2765,7 @@ void resample_for_plot(struct FIFO *plotFifo, short buf[], int length) int decimation = FS/WAVEFORM_PLOT_FS; int nSamples, sample; int i, st, en, max, min; - short dec_samples[2*N8]; - - assert(length <= 2*N8); + short dec_samples[length]; nSamples = length/decimation; @@ -2862,6 +2863,7 @@ void txRxProcessing() per_frame_rx_processing(cbData->rxoutfifo, cbData->rxinfifo); +#ifdef TMPa // Get some audio to send to headphones/speaker. If out of // sync or in analog mode we pass thru the "from radio" audio // to the headphones/speaker. When out of sync it's useful to @@ -2872,9 +2874,10 @@ void txRxProcessing() } else { // we are in sync so use decoded audio - memset(out8k_short, 0, sizeof(short)*N8); - fifo_read(cbData->rxoutfifo, out8k_short, N8); } +#endif + memset(out8k_short, 0, sizeof(short)*N8); + fifo_read(cbData->rxoutfifo, out8k_short, N8); // Optional Spk Out EQ Filtering, need mutex as filter can change at run time g_mutexProtectingCallbackData.Lock(); @@ -2911,8 +2914,9 @@ void txRxProcessing() // if ((g_nSoundCards == 2) && ((g_half_duplex && g_tx) || !g_half_duplex)) { + int ret; - // Make sure we have at least 6 frames of modulator output + // Make sure we have q few frames of modulator output // samples. This also locks the modulator to the sample rate // of sound card 1. We want to make sure that modulator // samples are uninterrupted by differences in sample rate @@ -2936,13 +2940,14 @@ void txRxProcessing() memset(in48k_short, 0, nsam*sizeof(short)); fifo_read(cbData->infifo2, in48k_short, nsam); - nout = resample(cbData->insrc2, in8k_short, in48k_short, FS, g_soundCard2SampleRate, 2*N8, nsam); + nout = resample(cbData->insrc2, in8k_short, in48k_short, FS, g_soundCard2SampleRate, 4*N8, nsam); // optionally use file for mic input signal g_mutexProtectingCallbackData.Lock(); if (g_playFileToMicIn && (g_sfPlayFile != NULL)) { int n = sf_read_short(g_sfPlayFile, in8k_short, nout); + //fprintf(stderr, "n: %d nout: %d\n", n, nout); if (n != nout) { if (g_loopPlayFileToMicIn) sf_seek(g_sfPlayFile, 0, SEEK_SET); @@ -2983,7 +2988,7 @@ void txRxProcessing() // of the peak level for normal SSB voice. So we // introduce 6dB gain to make analog SSB sound the // same level as the digital. Watch out for clipping. - for(int i=0; i<2*N8; i++) { + for(int i=0; in_nom_modem_samples; i++) { float out = (float)in8k_short[i]*2.0; if (out > 32767) out = 32767.0; if (out < -32767) out = -32767.0; @@ -2996,15 +3001,19 @@ void txRxProcessing() int i; freedv_comptx(g_pfreedv, tx_fdm, in8k_short); + fdmdv_freq_shift(tx_fdm_offset, tx_fdm, g_TxFreqOffsetHz, &g_TxFreqOffsetPhaseRect, g_pfreedv->n_nom_modem_samples); for(i=0; in_nom_modem_samples; i++) out8k_short[i] = tx_fdm_offset[i].real; } // output one frame of modem signal - nout = resample(cbData->outsrc1, out48k_short, out8k_short, g_soundCard1SampleRate, g_pfreedv->modem_sample_rate, N48, g_pfreedv->n_nom_modem_samples); + nout = resample(cbData->outsrc1, out48k_short, out8k_short, g_soundCard1SampleRate, g_pfreedv->modem_sample_rate, N48*4, g_pfreedv->n_nom_modem_samples); g_mutexProtectingCallbackData.Lock(); - fifo_write(cbData->outfifo1, out48k_short, nout); + ret = fifo_write(cbData->outfifo1, out48k_short, nout); + //fprintf(stderr,"nout: %d ret: %d N48*4: %d\n", nout, ret, N48*4); + + assert(ret != -1); } g_mutexProtectingCallbackData.Unlock(); } @@ -3406,3 +3415,17 @@ void *UDPThread::Entry() { } return NULL; } + + +char my_get_next_tx_char(void *callback_state) { + short ch = 0; + + fifo_read(g_txDataInFifo, &ch, 1); + + return (char)ch; +} + +void my_put_next_rx_char(void *callback_state, char c) { + short ch = (short)c; + fifo_write(g_rxDataOutFifo, &ch, 1); +} diff --git a/fdmdv2-dev/src/fdmdv2_main.h b/fdmdv2-dev/src/fdmdv2_main.h index 672c82bb..fe33346a 100644 --- a/fdmdv2-dev/src/fdmdv2_main.h +++ b/fdmdv2-dev/src/fdmdv2_main.h @@ -596,4 +596,7 @@ void per_frame_rx_processing( FIFO *input_fifo // modem samples input to demod ); +char my_get_next_tx_char(void *callback_state); +void my_put_next_rx_char(void *callback_state, char c); + #endif //__FDMDV2_MAIN__ -- 2.25.1