From: drowe67 Date: Thu, 1 Nov 2012 02:45:49 +0000 (+0000) Subject: modified several files to make more robust to zero input vectors X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=5a824923f18f7bf8b8ccdd468bd0b6e4f45f99ae;p=freetel-svn-tracking.git modified several files to make more robust to zero input vectors git-svn-id: https://svn.code.sf.net/p/freetel/code@913 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/src/c2sim.c b/codec2-dev/src/c2sim.c index f9403ccf..6aef4ef2 100644 --- a/codec2-dev/src/c2sim.c +++ b/codec2-dev/src/c2sim.c @@ -363,7 +363,7 @@ int main(int argc, char *argv[]) //printf("frame: %d ", frames); /* Read input speech */ - + for(i=0; isq[i] = Sn[i]*Sn[i]; for(i=m-n; imem_y; nlp->mem_x = nlp->sq[i]; nlp->mem_y = notch; - nlp->sq[i] = notch; + nlp->sq[i] = notch + 1.0; /* With 0 input vectors to codec, + kiss_fft() would take a long + time to execute when running in + real time. Problem was traced + to kiss_fft function call in + this function. Adding this small + constant fixed problem. Not + exactly sure why. */ } for(i=m-n; i= min_bin) { b = gmax_bin/mult; /* determine search interval */ diff --git a/codec2-dev/src/postfilter.c b/codec2-dev/src/postfilter.c index 077a3d27..c78f495b 100644 --- a/codec2-dev/src/postfilter.c +++ b/codec2-dev/src/postfilter.c @@ -27,6 +27,7 @@ along with this program; if not, see . */ +#include #include #include #include @@ -110,6 +111,7 @@ void postfilter( for(m=1; m<=model->L; m++) e += model->A[m]*model->A[m]; + assert(e > 0.0); e = 10.0*log10(e/model->L); /* If beneath threhold, update bg estimate. The idea diff --git a/codec2-dev/src/quantise.c b/codec2-dev/src/quantise.c index 4a5fefee..1c98afd4 100644 --- a/codec2-dev/src/quantise.c +++ b/codec2-dev/src/quantise.c @@ -972,7 +972,7 @@ void lpc_post_filter(kiss_fft_cfg fft_fwd_cfg, MODEL *model, COMP Pw[], float ak /* measure energy before post filtering */ - e_before = 0.0; + e_before = 1E-4; for(i=0; i= 0.0); x[0] = log10((model->Wo/PI)*4000.0/50.0)/log10(2); x[1] = 10.0*log10(1e-4 + e); @@ -1970,6 +1983,7 @@ int encode_WoE(MODEL *model, float e, float xq[]) err[i] -= codebook1[ndim*n1+i]; } + //printf("enc: %f %f (%f)(%f) \n", xq[0], xq[1], e, 10.0*log10(1e-4 + e)); return n1; } @@ -2001,6 +2015,7 @@ void decode_WoE(MODEL *model, float *e, float xq[], int n1) err[i] -= codebook1[ndim*n1+i]; } + //printf("dec: %f %f\n", xq[0], xq[1]); model->Wo = pow(2.0, xq[0])*(PI*50.0)/4000.0; /* bit errors can make us go out of range leading to all sorts of diff --git a/codec2-dev/src/sine.c b/codec2-dev/src/sine.c index 4ada8d80..67cbeaeb 100644 --- a/codec2-dev/src/sine.c +++ b/codec2-dev/src/sine.c @@ -400,7 +400,7 @@ float est_voicing_mbe( float elow, ehigh, eratio; float dF0, sixty; - sig = 0.0; + sig = 1E-4; for(l=1; l<=model->L/4; l++) { sig += model->A[l]*model->A[l]; } @@ -412,7 +412,7 @@ float est_voicing_mbe( } Wo = model->Wo; - error = 0.0; + error = 1E-4; /* Just test across the harmonics in the first 1000 Hz (L/4) */ @@ -463,7 +463,7 @@ float est_voicing_mbe( determine if we have made any gross errors. */ - elow = ehigh = 0.0; + elow = ehigh = 1E-4; for(l=1; l<=model->L/2; l++) { elow += model->A[l]*model->A[l]; }