From c6a6c4fedd57904d781414c41b0bf67f7a9976bc Mon Sep 17 00:00:00 2001 From: Ed Gonzalez Date: Fri, 30 Jan 2015 10:13:46 -0600 Subject: [PATCH] Add reliable_sync_bit to FreeDV structure and handle audio passthrough in sched_waveform --- DSP_API/CODEC2_FREEDV/freedv_api.c | 2 +- DSP_API/CODEC2_FREEDV/freedv_api.h | 2 ++ DSP_API/SmartSDR_Interface/sched_waveform.c | 21 +++++++++++++-------- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/DSP_API/CODEC2_FREEDV/freedv_api.c b/DSP_API/CODEC2_FREEDV/freedv_api.c index 8d4de0d..1bdd7cf 100644 --- a/DSP_API/CODEC2_FREEDV/freedv_api.c +++ b/DSP_API/CODEC2_FREEDV/freedv_api.c @@ -303,7 +303,7 @@ int freedv_rx(struct freedv *f, short speech_out[], short demod_in[]) { nin_prev = f->nin; fdmdv_demod(f->fdmdv, f->fdmdv_bits, &reliable_sync_bit, rx_fdm, &f->nin); fdmdv_get_demod_stats(f->fdmdv, &f->fdmdv_stats); - + f->reliable_sync_bit = reliable_sync_bit; if (f->fdmdv_stats.sync) { printf("\033[97mIn sync. Pass demod_in to Codec, Codec to speech_out\n"); if (reliable_sync_bit == 0) { diff --git a/DSP_API/CODEC2_FREEDV/freedv_api.h b/DSP_API/CODEC2_FREEDV/freedv_api.h index 5b48cbf..8f4e6c7 100644 --- a/DSP_API/CODEC2_FREEDV/freedv_api.h +++ b/DSP_API/CODEC2_FREEDV/freedv_api.h @@ -65,6 +65,8 @@ struct freedv { void *callback_state; + int reliable_sync_bit; + }; struct freedv *freedv_open(int mode); diff --git a/DSP_API/SmartSDR_Interface/sched_waveform.c b/DSP_API/SmartSDR_Interface/sched_waveform.c index c9439de..cf862ed 100644 --- a/DSP_API/SmartSDR_Interface/sched_waveform.c +++ b/DSP_API/SmartSDR_Interface/sched_waveform.c @@ -247,7 +247,7 @@ static void* _sched_waveform_thread(void* param) int i; // for loop counter float fsample; // a float sample -// float Sig2Noise; // Signal to noise ratio + float Sig2Noise; // Signal to noise ratio // Flags ... int initial_tx = 1; // Flags for TX circular buffer, clear if starting transmit @@ -437,13 +437,18 @@ static void* _sched_waveform_thread(void* param) nout = freedv_rx(_freedvS, speech_out, demod_in); - // if(nout != 320 ) { - // output("NOUT not 320 it is %d\nNIN was %d\n", nout, nin); - // } - for( i=0 ; i < nout ; i++) - { - cbWriteShort(RX3_cb, speech_out[i]); + + if ( nout == nin && _freedvS->reliable_sync_bit ){ + for( i=0 ; i < nout ; i++) + { + cbWriteShort(RX3_cb, speech_out[i]); + } + } else { + + for ( i = 0; i < nin ; i ++ ) { + cbWriteShort(RX3_cb, demod_in[i]); + } } } // } else { @@ -467,7 +472,7 @@ static void* _sched_waveform_thread(void* param) { cbWriteFloat(RX4_cb, float_out_24k[i]); } - //Sig2Noise = (_freedvS->fdmdv_stats.snr_est); + Sig2Noise = (_freedvS->fdmdv_stats.snr_est); } // Check for >= 128 samples in RX4_cb. Form packet and