//printf("frame: %d ", frames);
/* Read input speech */
-
+
for(i=0; i<M-N; i++) {
Sn[i] = Sn[i+N];
Sn_pre[i] = Sn_pre[i+N];
for(i=0; i<LSP_SCALAR_INDEXES; i++) {
pack(bits, &nbit, lsp_indexes[i], lsp_bits(i));
}
-
+
assert(nbit == (unsigned)codec2_bits_per_frame(c2));
}
/*---------------------------------------------------------------------------*\
- FILE........: fdmdv_internal.h
+ FILE........: codec2_internal.h
AUTHOR......: David Rowe
DATE CREATED: April 16 2012
#
# Listen to files processed with sim.sh
-../script/menu.sh $1_lpcpf.raw $1_3200.raw $1_2400.raw $2 $3
+../script/menu.sh $1_uq.raw $1_lpc10.raw $1_lpcpf.raw $1_phase0.raw $1_phase0_lpcpf.raw $2 $3 $4 $5
float best_f0;
assert(nlp_state != NULL);
+ assert(m <= PMAX_M);
nlp = (NLP*)nlp_state;
/* Square, notch filter at DC, and LP filter vector */
- for(i=m-n; i<M; i++) /* square latest speech samples */
+ for(i=m-n; i<m; i++) /* square latest speech samples */
nlp->sq[i] = Sn[i]*Sn[i];
for(i=m-n; i<m; i++) { /* notch filter at DC */
notch += COEFF*nlp->mem_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<m; i++) { /* FIR filter vector */
gmax_bin = i;
}
}
-
+
//#define POST_PROCESS_MBE
#ifdef POST_PROCESS_MBE
best_f0 = post_process_mbe(Fw, pmin, pmax, gmax, Sw, W, prev_Wo);
/* post process estimate by searching submultiples */
mult = 2;
- min_bin = PE_FFT_SIZE*DEC/pmax;
+ min_bin = PE_FFT_SIZE*DEC/pmax;
cmax_bin = gmax_bin;
prev_f0_bin = *prev_Wo*(4000.0/PI)*(PE_FFT_SIZE*DEC)/SAMPLE_RATE;
-
+
while(gmax_bin/mult >= min_bin) {
b = gmax_bin/mult; /* determine search interval */
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
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
/* measure energy before post filtering */
- e_before = 0.0;
+ e_before = 1E-4;
for(i=0; i<FFT_ENC/2; i++)
e_before += Pw[i].real;
dump_Pwb(Pw);
#endif
- e_after = 0.0;
+ e_after = 1E-4;
for(i=0; i<FFT_ENC/2; i++) {
Pfw[i] = pow(Rw[i], LPCPF_BETA);
Pw[i].real *= Pfw[i] * Pfw[i];
int i, roots;
float Wn[M];
float R[LPC_MAX+1];
- float E;
+ float e, E;
- for(i=0; i<M; i++)
+ e = 0.0;
+ for(i=0; i<M; i++) {
Wn[i] = Sn[i]*w[i];
+ e += Wn[i]*Wn[i];
+ }
+
+ /* trap 0 energy case as LPC analysis will fail */
+
+ if (e == 0.0) {
+ for(i=0; i<order; i++)
+ lsp[i] = (PI/order)*(float)i;
+ return 0.0;
+ }
+
autocorrelate(Wn, R, M, order);
levinson_durbin(R, ak, order);
E = 0.0;
for(i=0; i<=order; i++)
E += ak[i]*R[i];
-
+
/* 15 Hz BW expansion as I can't hear the difference and it may help
help occasional fails in the LSP root finding. Important to do this
after energy calculation to avoid -ve energy values.
int ndim = ge_cb[0].k;
assert((1<<WO_E_BITS) == nb_entries);
+ assert(e >= 0.0);
x[0] = log10((model->Wo/PI)*4000.0/50.0)/log10(2);
x[1] = 10.0*log10(1e-4 + e);
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;
}
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
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];
}
}
Wo = model->Wo;
- error = 0.0;
+ error = 1E-4;
/* Just test across the harmonics in the first 1000 Hz (L/4) */
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];
}