From ff5302a17508bb8865debdde26a5de282bb1cb58 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Thu, 10 May 2012 02:37:17 +0000 Subject: [PATCH] fixed seg fault issue due to bit errors in delta-time Wo quantiser, first pass at 48 to 8 kHz sample conversion functions git-svn-id: https://svn.code.sf.net/p/freetel/code@407 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/README_fdmdv.txt | 7 ++-- codec2-dev/src/codec2.c | 6 ++- codec2-dev/src/fdmdv.c | 67 +++++++++++++++++++++++++++++++++ codec2-dev/src/fdmdv_internal.h | 5 +++ codec2-dev/src/os.h | 53 ++++++++++++++++++++++++++ codec2-dev/src/quantise.c | 6 +++ 6 files changed, 139 insertions(+), 5 deletions(-) create mode 100644 codec2-dev/src/os.h diff --git a/codec2-dev/README_fdmdv.txt b/codec2-dev/README_fdmdv.txt index 783239fd..301d6ad2 100644 --- a/codec2-dev/README_fdmdv.txt +++ b/codec2-dev/README_fdmdv.txt @@ -165,6 +165,7 @@ This introduces a simulated 1000ppm error: TODO ---- +[ ] 48 kHz to and from 8 kHz routines to drive 48 kHz sound card audio [ ] try interfering sine wave + maybe swept + does modem fall over? @@ -172,10 +173,10 @@ TODO + make sure all estimators keep working [ ] test rx level sensitivity, i.e. 0 to 20dB attenuation [ ] make fine freq indep of amplitude - + use angle rather than imag corrd + + use angle rather than imag coord [ ] document use of fdmdv_ut and fdmdv_demod + PathSim -[ ] more positibe form of sync reqd for DV frames? - + like using track/acquire bit +[ ] more positive form of sync reqd for DV frames? + + like using coarse_fine==1 to decode valid DV frame bit? + when should we start decoding? [ ] more robust track/acquite state machine? + e.g. hang on thru the fades? diff --git a/codec2-dev/src/codec2.c b/codec2-dev/src/codec2.c index ad806eca..984b8170 100644 --- a/codec2-dev/src/codec2.c +++ b/codec2-dev/src/codec2.c @@ -739,7 +739,7 @@ void codec2_decode_1500(struct CODEC2 *c2, short speech[], const unsigned char * Encodes 320 speech samples (40ms of speech) into 48 bits. The codec2 algorithm actually operates internally on 10ms (80 - sample) frames, so we run the encoding algorithm for times: + sample) frames, so we run the encoding algorithm four times: frame 0: just send voicing bit frame 1: predictive vector quantisation of LSPs and Wo and E @@ -969,10 +969,12 @@ void codec2_decode_1200(struct CODEC2 *c2, short speech[], const unsigned char * /* decode integer codes to model parameters */ model.Wo = decode_Wo_dt(delta_Wo_index, prev__Wo); + assert(model.Wo >= TWO_PI/P_MAX); + assert(model.Wo <= TWO_PI/P_MIN); model.L = PI/model.Wo; memset(&model.A, 0, (model.L+1)*sizeof(model.A[0])); energy = decode_energy(energy_index); - + /* decode frame 4 */ aks_to_M2(ak, LPC_ORD, &model, energy, &snr, 1); diff --git a/codec2-dev/src/fdmdv.c b/codec2-dev/src/fdmdv.c index 0efe5e70..c17ab483 100644 --- a/codec2-dev/src/fdmdv.c +++ b/codec2-dev/src/fdmdv.c @@ -44,6 +44,7 @@ #include "pilot_coeff.h" #include "fft.h" #include "hanning.h" +#include "os.h" /*---------------------------------------------------------------------------*\ @@ -1170,3 +1171,69 @@ void fdmdv_get_demod_stats(struct FDMDV *fdmdv, struct FDMDV_STATS *fdmdv_stats) } +/*---------------------------------------------------------------------------*\ + + FUNCTION....: fdmdv_8_to_48() + AUTHOR......: David Rowe + DATE CREATED: 9 May 2012 + + Changes the sample rate of a signal from 8 to 48 kHz. Experience + with PC based modems has shown that PC sound cards have a more + accurate sample clock when set for 48 kHz than 8 kHz. + + n is the number of samples at the 8 kHz rate, there are FDMDV_OS*n samples + at the 48 kHz rate. A memory of FDMDV_OS_TAPS/FDMDV_OS samples is reqd for + in8k[] (see example). + + This is a classic polyphase upsampler. We take the 8 kHz samples + and insert (FDMDV_OS-1) zeroes between each sample, then + FDMDV_OS_TAPS FIR low pass filter the signal at 4kHz. As most of + the input samples are zeroes, we only need to multiply non-zero + input samples by filter coefficients. The zero insertion and + filtering are combined in the code below and I'm too lazy to explain + it further right now.... + +\*---------------------------------------------------------------------------*/ + +void fdmdv_8_to_48(float out48k[], float in8k[], int n) +{ + int i,j,k,l; + + for(i=0; i Wo_max) Wo = Wo_max; + if (Wo < Wo_min) Wo = Wo_min; + return Wo; } -- 2.25.1