Fix scaling issues and decode_out indexing. Audio encode/decode now completely functional

This commit is contained in:
Ed Gonzalez 2015-06-01 18:10:34 -05:00
parent 011100778c
commit 3c092ad57d
2 changed files with 13 additions and 5 deletions

View file

@ -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));
}
}

View file

@ -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);