From 3c092ad57d4e54f0ada50e522a982cc2bdc9643f Mon Sep 17 00:00:00 2001 From: Ed Gonzalez Date: Mon, 1 Jun 2015 18:10:34 -0500 Subject: [PATCH] Fix scaling issues and decode_out indexing. Audio encode/decode now completely functional --- DSP_API/SmartSDR_Interface/sched_waveform.c | 11 +++++++---- DSP_API/ThumbDV/thumbDV.c | 7 ++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/DSP_API/SmartSDR_Interface/sched_waveform.c b/DSP_API/SmartSDR_Interface/sched_waveform.c index 871d698..64d2c3a 100644 --- a/DSP_API/SmartSDR_Interface/sched_waveform.c +++ b/DSP_API/SmartSDR_Interface/sched_waveform.c @@ -150,9 +150,12 @@ void sched_waveform_signal() //#define SCALE_TX_OUT 32767.0f // Divisor #define SCALE_RX_IN SCALE_AMBE +#define SCALE_TX_OUT SCALE_AMBE + + #define SCALE_RX_OUT SCALE_AMBE #define SCALE_TX_IN SCALE_AMBE -#define SCALE_TX_OUT SCALE_AMBE + #define FILTER_TAPS 48 #define DECIMATION_FACTOR 3 @@ -396,7 +399,8 @@ static void* _sched_waveform_thread(void* param) { for( i=0 ; i< DV_PACKET_SAMPLES ; i++) { - float_in_8k[i+MEM_8] = 0.5f * ((float) (cbReadShort(RX3_cb) / SCALE_RX_OUT)); + float_in_8k[i+MEM_8] = ((float) (cbReadShort(RX3_cb) / SCALE_RX_OUT)); + } fdmdv_8_to_24(float_out_24k, &float_in_8k[MEM_8], DV_PACKET_SAMPLES); @@ -489,8 +493,7 @@ static void* _sched_waveform_thread(void* param) for(i=0 ; i < DV_PACKET_SAMPLES ; i++) { - cbWriteShort(TX2_cb, (short) (0.5f * tx_float_out_8k[i]*SCALE_TX_IN)); - + cbWriteShort(TX2_cb, (short) (tx_float_out_8k[i]*SCALE_TX_IN)); } } diff --git a/DSP_API/ThumbDV/thumbDV.c b/DSP_API/ThumbDV/thumbDV.c index c2f75ba..2d885b0 100644 --- a/DSP_API/ThumbDV/thumbDV.c +++ b/DSP_API/ThumbDV/thumbDV.c @@ -443,7 +443,12 @@ int thumbDV_decode(int serial_fd, unsigned char * packet_in, short * speech_out, if ( desc != NULL ) { samples_in_speech_packet = ((unsigned char * )desc->buf_ptr)[5]; - memcpy(speech_out, desc->buf_ptr + AMBE3000_HEADER_LEN + AMBE3000_SPEECHD_HEADER_LEN - 1, sizeof(uint16) * samples_in_speech_packet); + unsigned char * idx = &(((unsigned char * )desc->buf_ptr)[6]); + uint32 i = 0; + for ( i = 0; i < samples_in_speech_packet; i++, idx += 2) { + speech_out[i] = ( idx[0] << 8 ) + idx[1]; + } + samples_returned = samples_in_speech_packet; if ( samples_returned != 160 ) output("Rate Mismatch expected %d got %d\n", 160, samples_returned); safe_free(desc);