Add reliable_sync_bit to FreeDV structure and handle audio passthrough in sched_waveform

This commit is contained in:
Ed Gonzalez 2015-01-30 10:13:46 -06:00
parent 3c21c89580
commit a14898a070
3 changed files with 16 additions and 9 deletions

View file

@ -303,7 +303,7 @@ int freedv_rx(struct freedv *f, short speech_out[], short demod_in[]) {
nin_prev = f->nin; nin_prev = f->nin;
fdmdv_demod(f->fdmdv, f->fdmdv_bits, &reliable_sync_bit, rx_fdm, &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); fdmdv_get_demod_stats(f->fdmdv, &f->fdmdv_stats);
f->reliable_sync_bit = reliable_sync_bit;
if (f->fdmdv_stats.sync) { if (f->fdmdv_stats.sync) {
if (reliable_sync_bit == 0) { if (reliable_sync_bit == 0) {
memcpy(f->rx_bits, f->fdmdv_bits, bits_per_fdmdv_frame*sizeof(int)); memcpy(f->rx_bits, f->fdmdv_bits, bits_per_fdmdv_frame*sizeof(int));

View file

@ -65,6 +65,8 @@ struct freedv {
void *callback_state; void *callback_state;
int reliable_sync_bit;
}; };
struct freedv *freedv_open(int mode); struct freedv *freedv_open(int mode);

View file

@ -263,7 +263,7 @@ static void* _sched_waveform_thread(void* param)
int i; // for loop counter int i; // for loop counter
float fsample; // a float sample float fsample; // a float sample
// float Sig2Noise; // Signal to noise ratio float Sig2Noise; // Signal to noise ratio
// Flags ... // Flags ...
int initial_tx = 1; // Flags for TX circular buffer, clear if starting transmit int initial_tx = 1; // Flags for TX circular buffer, clear if starting transmit
@ -457,14 +457,19 @@ static void* _sched_waveform_thread(void* param)
nout = freedv_rx(_freedvS, speech_out, demod_in); nout = freedv_rx(_freedvS, speech_out, demod_in);
// if(nout != 320 ) {
// output("NOUT not 320 it is %d\nNIN was %d\n", nout, nin);
// }
if ( nout == nin && _freedvS->reliable_sync_bit ){
for( i=0 ; i < nout ; i++) for( i=0 ; i < nout ; i++)
{ {
cbWriteShort(RX3_cb, speech_out[i]); cbWriteShort(RX3_cb, speech_out[i]);
} }
} else {
for ( i = 0; i < nin ; i ++ ) {
cbWriteShort(RX3_cb, demod_in[i]);
}
}
} }
// } else { // } else {
// break; /* Break out of while loop */ // break; /* Break out of while loop */
@ -487,7 +492,7 @@ static void* _sched_waveform_thread(void* param)
{ {
cbWriteFloat(RX4_cb, float_out_24k[i]); 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 // Check for >= 128 samples in RX4_cb. Form packet and