char phaseexp_arg[MAX_STR];
float snr;
float sum_snr;
-
+ int orderi;
int lpc_model = 0, order = LPC_ORD;
int lsp = 0, lspd = 0, lspvq = 0;
int lspres = 0;
int dt = 0, lspjvm = 0, lspanssi = 0, lspjnd = 0, lspmel = 0;
int prede = 0;
float pre_mem = 0.0, de_mem = 0.0;
- float ak[LPC_MAX];
+ float ak[order];
COMP Sw_[FFT_ENC];
COMP Ew[FFT_ENC];
MODEL prev_model, interp_model;
int decimate = 0;
- float lsps[LPC_MAX];
- float prev_lsps[LPC_MAX], prev_lsps_[LPC_MAX];
- float lsps__prev[LPC_MAX];
- float lsps__prev2[LPC_MAX];
+ float lsps[order];
+ float prev_lsps[order], prev_lsps_[order];
+ float lsps__prev[order];
+ float lsps__prev2[order];
float e, prev_e;
- float ak_interp[LPC_MAX];
- int lsp_indexes[LPC_MAX];
- float lsps_[LPC_MAX];
+ float ak_interp[order];
+ int lsp_indexes[order];
+ float lsps_[order];
float Woe_[2];
void *nlp_states;
//ex_phase[i] = (PI/3)*(float)rand()/RAND_MAX;
ex_phase[i] = 0.0;
}
- for(i=0; i<LPC_ORD; i++) {
- lsps_[i] = prev_lsps[i] = prev_lsps_[i] = i*PI/(LPC_ORD+1);
- lsps__prev[i] = lsps__prev2[i] = i*PI/(LPC_ORD+1);
+ for(i=0; i<order; i++) {
+ lsps_[i] = prev_lsps[i] = prev_lsps_[i] = i*PI/(order+1);
+ lsps__prev[i] = lsps__prev2[i] = i*PI/(order+1);
}
e = prev_e = 1;
hpf_states[0] = hpf_states[1] = 0.0;
switch (opt) {
case 0:
if(strcmp(long_options[option_index].name, "lpc") == 0) {
- order = atoi(optarg);
- if((order < 4) || (order > 20)) {
- fprintf(stderr, "Error in LPC order: %s\n", optarg);
+ orderi = atoi(optarg);
+ if((orderi < 4) || (orderi > order)) {
+ fprintf(stderr, "Error in LPC order (4 to %d): %s\n", order, optarg);
exit(1);
}
+ order = orderi;
#ifdef DUMP
} else if(strcmp(long_options[option_index].name, "dump") == 0) {
if (dump)
gain = atof(optarg);
} else if(strcmp(long_options[option_index].name, "rate") == 0) {
if(strcmp(optarg,"3200") == 0) {
- lpc_model = 1; order = 10;
+ lpc_model = 1;
scalar_quant_Wo_e = 1;
lspd = 1;
phase0 = 1;
decimate = 1;
lpcpf = 1;
} else if(strcmp(optarg,"2400") == 0) {
- lpc_model = 1; order = 10;
+ lpc_model = 1;
vector_quant_Wo_e = 1;
lsp = 1;
phase0 = 1;
decimate = 1;
lpcpf = 1;
} else if(strcmp(optarg,"1400") == 0) {
- lpc_model = 1; order = 10;
+ lpc_model = 1;
vector_quant_Wo_e = 1;
lsp = 1; lspdt = 1;
phase0 = 1;
dt = 1;
lpcpf = 1;
} else if(strcmp(optarg,"1200") == 0) {
- lpc_model = 1; order = 10;
+ lpc_model = 1;
scalar_quant_Wo_e = 1;
lspjvm = 1; lspdt = 1;
phase0 = 1;
dt = 1;
lpcpf = 1;
} else {
- fprintf(stderr, "Error: invalid output rate %s\n", optarg);
+ fprintf(stderr, "Error: invalid output rate (3200|2400|1400|1200) %s\n", optarg);
exit(1);
}
}
if (phase0) {
float Wn[M]; /* windowed speech samples */
- float Rk[LPC_MAX+1]; /* autocorrelation coeffs */
+ float Rk[order+1]; /* autocorrelation coeffs */
#ifdef DUMP
dump_phase(&model.phi[0], model.L);
/* determine voicing */
- snr = est_voicing_mbe(&model, Sw, W, Sw_, Ew, prev_uq_Wo);
+ snr = est_voicing_mbe(&model, Sw, W, Sw_, Ew);
if (dump_pitch_e)
fprintf(fjvm, "%f %f %d ", model.Wo, snr, model.voiced);
e = speech_to_uq_lsps(lsps, ak, Sn, w, order);
#ifdef DUMP
- dump_ak(ak, LPC_ORD);
+ dump_ak(ak, order);
#endif
/* tracking down -ve energy values with BW expansion */
/* dump order is different if we are decimating */
if (!decimate)
dump_lsp(lsps);
- for(i=0; i<LPC_ORD; i++)
+ for(i=0; i<order; i++)
prev_lsps[i] = lsps[i];
#endif
apply_lpc_correction(&model);
#ifdef DUMP
- dump_ak_(ak, LPC_ORD);
+ dump_ak_(ak, order);
#endif
/* note SNR on interpolated frames can't be measured properly
\*------------------------------------------------------------*/
if (decimate) {
- float lsps_interp[LPC_ORD];
+ float lsps_interp[order];
if (!phase0) {
printf("needs --phase0 to resample phase for interpolated Wo\n");
exit(0);
}
if (!lpc_model) {
- printf("needs --lpc 10 to resample amplitudes\n");
+ printf("needs --lpc [order] to resample amplitudes\n");
exit(0);
}
printf(" Wo: %1.5f L: %d v1: %d prev_e: %f\n",
interp_model.Wo, interp_model.L, interp_model.voiced, prev_e);
printf(" lsps_interp: ");
- for(i=0; i<LPC_ORD; i++)
+ for(i=0; i<order; i++)
printf("%5.3f ", lsps_interp[i]);
printf("\n A..........: ");
- for(i=0; i<10; i++)
+ for(i=0; i<order; i++)
printf("%5.3f ",interp_model.A[i]);
printf("\n Wo: %1.5f L: %d e: %3.2f v2: %d\n",
model.Wo, model.L, e, model.voiced);
printf(" lsps_......: ");
- for(i=0; i<LPC_ORD; i++)
+ for(i=0; i<order; i++)
printf("%5.3f ", lsps_[i]);
printf("\n A..........: ");
- for(i=0; i<10; i++)
+ for(i=0; i<order; i++)
printf("%5.3f ",model.A[i]);
printf("\n");
*/
/* update states for next time */
prev_model = model;
- for(i=0; i<LPC_ORD; i++)
+ for(i=0; i<order; i++)
prev_lsps_[i] = lsps_[i];
prev_e = e;
}
} else if (strcmp("dump_pitch_e", long_options[i].name) == 0) {
option_parameters = " <Dump File>";
} else if (strcmp("rate", long_options[i].name) == 0) {
- option_parameters = " <4800|2400|1400|1200>";
+ option_parameters = " <3200|2400|1400|1200>";
} else if (strcmp("dump", long_options[i].name) == 0) {
option_parameters = " <DumpFilePrefix>";
} else {
TIMER_SAMPLE_AND_LOG(two_stage, model_start, " two_stage");
estimate_amplitudes(model, Sw, c2->W, 0);
TIMER_SAMPLE_AND_LOG(estamps, two_stage, " est_amps");
- est_voicing_mbe(model, Sw, c2->W, Sw_, Ew, c2->prev_Wo_enc);
+ est_voicing_mbe(model, Sw, c2->W, Sw_, Ew);
c2->prev_Wo_enc = model->Wo;
TIMER_SAMPLE_AND_LOG2(estamps, " est_voicing");
#ifdef DUMP
#define FFT_DEC 512 /* size of FFT used in decoder */
#define TW 40 /* Trapezoidal synthesis window overlap */
#define V_THRESH 6.0 /* voicing threshold in dB */
-#define LPC_MAX 20 /* maximum LPC order */
#define LPC_ORD 10 /* phase modelling LPC order */
/* Pitch estimation defines */
for(i=0; i<NPILOTLPF-nin; i++)
pilot_lpf[i] = pilot_lpf[nin+i];
- for(i=NPILOTLPF-nin, j=0; i<NPILOTLPF; i++,j++) {
+ for(i=NPILOTLPF-nin, j=NPILOTBASEBAND-nin; i<NPILOTLPF; i++,j++) {
pilot_lpf[i].real = 0.0; pilot_lpf[i].imag = 0.0;
for(k=0; k<NPILOTCOEFF; k++)
- pilot_lpf[i] = cadd(pilot_lpf[i], fcmult(pilot_coeff[k], pilot_baseband[j+k]));
+ pilot_lpf[i] = cadd(pilot_lpf[i], fcmult(pilot_coeff[k], pilot_baseband[j-NPILOTCOEFF+1+k]));
}
/* decimate to improve DFT resolution, window and DFT */
int order /* order of the LPC analysis */
)
{
- float E[LPC_MAX+1];
- float k[LPC_MAX+1];
- float a[LPC_MAX+1][LPC_MAX+1];
+ float E[order+1];
+ float k[order+1];
+ float a[order+1][order+1];
float sum;
int i,j; /* loop variables */
)
{
float Wn[LPC_MAX_N]; /* windowed frame of Nsam speech samples */
- float R[LPC_MAX+1]; /* order+1 autocorrelation values of Sn[] */
+ float R[order+1]; /* order+1 autocorrelation values of Sn[] */
int i;
- assert(order < LPC_MAX);
assert(Nsam < LPC_MAX_N);
hanning_window(Sn,Wn,Nsam);
#include <stdio.h>
#include <stdlib.h>
-#define LSP_MAX_ORDER 20
-
/*---------------------------------------------------------------------------*\
Introduction to Line Spectrum Pairs (LSPs)
static float
-cheb_poly_eva(float *coef,float x,int m)
+cheb_poly_eva(float *coef,float x,int order)
/* float coef[] coefficients of the polynomial to be evaluated */
/* float x the point where polynomial is to be evaluated */
-/* int m order of the polynomial */
+/* int order order of the polynomial */
{
int i;
float *t,*u,*v,sum;
- float T[(LSP_MAX_ORDER / 2) + 1];
+ float T[(order / 2) + 1];
/* Initialise pointers */
/* Evaluate chebyshev series formulation using iterative approach */
- for(i=2;i<=m/2;i++)
+ for(i=2;i<=order/2;i++)
*v++ = (2*x)*(*u++) - *t++; /* T[i] = 2*x*T[i-1] - T[i-2] */
sum=0.0; /* initialise sum to zero */
/* Evaluate polynomial and return value also free memory space */
- for(i=0;i<=m/2;i++)
- sum+=coef[(m/2)-i]**t++;
+ for(i=0;i<=order/2;i++)
+ sum+=coef[(order/2)-i]**t++;
return sum;
}
\*---------------------------------------------------------------------------*/
-int lpc_to_lsp (float *a, int lpcrdr, float *freq, int nb, float delta)
+int lpc_to_lsp (float *a, int order, float *freq, int nb, float delta)
/* float *a lpc coefficients */
-/* int lpcrdr order of LPC coefficients (10) */
+/* int order order of LPC coefficients (10) */
/* float *freq LSP frequencies in radians */
/* int nb number of sub-intervals (4) */
/* float delta grid spacing interval (0.02) */
float *pt; /* ptr used for cheb_poly_eval()
whether P' or Q' */
int roots=0; /* number of roots found */
- float Q[LSP_MAX_ORDER + 1];
- float P[LSP_MAX_ORDER + 1];
+ float Q[order + 1];
+ float P[order + 1];
flag = 1;
- m = lpcrdr/2; /* order of P'(z) & Q'(z) polynimials */
+ m = order/2; /* order of P'(z) & Q'(z) polynimials */
/* Allocate memory space for polynomials */
*px++ = 1.0;
*qx++ = 1.0;
for(i=1;i<=m;i++){
- *px++ = a[i]+a[lpcrdr+1-i]-*p++;
- *qx++ = a[i]-a[lpcrdr+1-i]+*q++;
+ *px++ = a[i]+a[order+1-i]-*p++;
+ *qx++ = a[i]-a[order+1-i]+*q++;
}
px = P;
qx = Q;
xl = 1.0; /* start at point xl = 1 */
- for(j=0;j<lpcrdr;j++){
+ for(j=0;j<order;j++){
if(j%2) /* determines whether P' or Q' is eval. */
pt = qx;
else
pt = px;
- psuml = cheb_poly_eva(pt,xl,lpcrdr); /* evals poly. at xl */
+ psuml = cheb_poly_eva(pt,xl,order); /* evals poly. at xl */
flag = 1;
while(flag && (xr >= -1.0)){
xr = xl - delta ; /* interval spacing */
- psumr = cheb_poly_eva(pt,xr,lpcrdr);/* poly(xl-delta_x) */
+ psumr = cheb_poly_eva(pt,xr,order);/* poly(xl-delta_x) */
temp_psumr = psumr;
temp_xr = xr;
psumm=psuml;
for(k=0;k<=nb;k++){
xm = (xl+xr)/2; /* bisect the interval */
- psumm=cheb_poly_eva(pt,xm,lpcrdr);
+ psumm=cheb_poly_eva(pt,xm,order);
if(psumm*psuml>0.){
psuml=psumm;
xl=xm;
/* convert from x domain to radians */
- for(i=0; i<lpcrdr; i++) {
+ for(i=0; i<order; i++) {
freq[i] = acos(freq[i]);
}
\*---------------------------------------------------------------------------*/
-void lsp_to_lpc(float *lsp, float *ak, int lpcrdr)
+void lsp_to_lpc(float *lsp, float *ak, int order)
/* float *freq array of LSP frequencies in radians */
/* float *ak array of LPC coefficients */
-/* int lpcrdr order of LPC coefficients */
+/* int order order of LPC coefficients */
{
int i,j;
float xout1,xout2,xin1,xin2;
float *pw,*n1,*n2,*n3,*n4 = 0;
- int m = lpcrdr/2;
- float freq[LSP_MAX_ORDER];
- float Wp[(LSP_MAX_ORDER * 4) + 2];
+ float freq[order];
+ float Wp[(order * 4) + 2];
/* convert from radians to the x=cos(w) domain */
- for(i=0; i<lpcrdr; i++)
+ for(i=0; i<order; i++)
freq[i] = cos(lsp[i]);
pw = Wp;
/* initialise contents of array */
- for(i=0;i<=4*m+1;i++){ /* set contents of buffer to 0 */
+ for(i=0;i<=4*(order/2)+1;i++){ /* set contents of buffer to 0 */
*pw++ = 0.0;
}
/* reconstruct P(z) and Q(z) by cascading second order polynomials
in form 1 - 2xz(-1) +z(-2), where x is the LSP coefficient */
- for(j=0;j<=lpcrdr;j++){
- for(i=0;i<m;i++){
+ for(j=0;j<=order;j++){
+ for(i=0;i<(order/2);i++){
n1 = pw+(i*4);
n2 = n1 + 1;
n3 = n2 + 1;
)
{
int i,k,m;
- float lsp_hz[LPC_MAX];
- float lsp__hz[LPC_MAX];
- float dlsp[LPC_MAX];
- float dlsp_[LPC_MAX];
- float wt[LPC_MAX];
+ float lsp_hz[order];
+ float lsp__hz[order];
+ float dlsp[order];
+ float dlsp_[order];
+ float wt[order];
const float *cb;
float se;
- assert(order == LPC_ORD);
-
for(i=0; i<order; i++) {
wt[i] = 1.0;
}
)
{
int i,k;
- float lsp__hz[LPC_MAX];
- float dlsp_[LPC_MAX];
+ float lsp__hz[order];
+ float dlsp_[order];
const float *cb;
- assert(order == LPC_ORD);
-
for(i=0; i<order; i++) {
k = lsp_cbd[i].k;
)
{
int i,k,m,ncb, nlsp;
- float wt[LPC_ORD], lsp_hz[LPC_ORD];
+ float wt[order], lsp_hz[order];
const float *cb;
float se;
int index;
- for(i=0; i<LPC_ORD; i++) {
+ for(i=0; i<order; i++) {
wt[i] = 1.0;
lsp_hz[i] = 4000.0*lsp[i]/PI;
}
m = lsp_cbjnd[ncb].m;
cb = lsp_cbjnd[ncb].cb;
index = quantise(cb, &lsp_hz[nlsp], &wt[nlsp], k, m, &se);
- for(i=4; i<LPC_ORD; i++) {
+ for(i=4; i<order; i++) {
lsp_[i] = cb[index*k+i-4]*(PI/4000.0);
//printf("%4.f (%4.f) ", lsp_hz[i], cb[index*k+i-4]);
}
void lspjnd_quantise(float lsps[], float lsps_[], int order)
{
int i,k,m;
- float wt[LPC_ORD], lsps_hz[LPC_ORD];
+ float wt[order], lsps_hz[order];
const float *cb;
float se = 0.0;
int index;
- for(i=0; i<LPC_ORD; i++) {
+ for(i=0; i<order; i++) {
wt[i] = 1.0;
}
/* convert to Hz */
- for(i=0; i<LPC_ORD; i++) {
+ for(i=0; i<order; i++) {
lsps_hz[i] = lsps[i]*(4000.0/PI);
lsps_[i] = lsps[i];
}
index = quantise(cb, &lsps_hz[4], &wt[4], k, m, &se);
//printf("k = %d m = %d c[0] %f cb[k] %f\n", k,m,cb[0],cb[k]);
//printf("index = %4d: ", index);
- for(i=4; i<LPC_ORD; i++) {
+ for(i=4; i<order; i++) {
lsps_[i] = cb[index*k+i-4]*(PI/4000.0);
//printf("%4.f (%4.f) ", lsps_hz[i], cb[index*k+i-4]);
}
//w[1]*=2;
}
+#ifdef __EXPERIMENTAL__
/* LSP weight calculation ported from m-file function kindly submitted
by Anssi, OH3GDD */
w[i]=pow(w[i]+0.3, 0.66);
}
}
+#endif
int find_nearest(const float *codebook, int nb_entries, float *x, int ndim)
{
return nearest;
}
-void lspjvm_quantise(float *x, float *xq, int ndim)
+void lspjvm_quantise(float *x, float *xq, int order)
{
int i, n1, n2, n3;
- float err[LPC_ORD], err2[LPC_ORD], err3[LPC_ORD];
- float w[LPC_ORD], w2[LPC_ORD], w3[LPC_ORD];
+ float err[order], err2[order], err3[order];
+ float w[order], w2[order], w3[order];
const float *codebook1 = lsp_cbjvm[0].cb;
const float *codebook2 = lsp_cbjvm[1].cb;
const float *codebook3 = lsp_cbjvm[2].cb;
w[0] = MIN(x[0], x[1]-x[0]);
- for (i=1;i<ndim-1;i++)
+ for (i=1;i<order-1;i++)
w[i] = MIN(x[i]-x[i-1], x[i+1]-x[i]);
- w[ndim-1] = MIN(x[ndim-1]-x[ndim-2], PI-x[ndim-1]);
+ w[order-1] = MIN(x[order-1]-x[order-2], PI-x[order-1]);
- compute_weights(x, w, ndim);
+ compute_weights(x, w, order);
- n1 = find_nearest(codebook1, lsp_cbjvm[0].m, x, ndim);
+ n1 = find_nearest(codebook1, lsp_cbjvm[0].m, x, order);
- for (i=0;i<ndim;i++)
+ for (i=0;i<order;i++)
{
- xq[i] = codebook1[ndim*n1+i];
+ xq[i] = codebook1[order*n1+i];
err[i] = x[i] - xq[i];
}
- for (i=0;i<ndim/2;i++)
+ for (i=0;i<order/2;i++)
{
err2[i] = err[2*i];
err3[i] = err[2*i+1];
w2[i] = w[2*i];
w3[i] = w[2*i+1];
}
- n2 = find_nearest_weighted(codebook2, lsp_cbjvm[1].m, err2, w2, ndim/2);
- n3 = find_nearest_weighted(codebook3, lsp_cbjvm[2].m, err3, w3, ndim/2);
+ n2 = find_nearest_weighted(codebook2, lsp_cbjvm[1].m, err2, w2, order/2);
+ n3 = find_nearest_weighted(codebook3, lsp_cbjvm[2].m, err3, w3, order/2);
- for (i=0;i<ndim/2;i++)
+ for (i=0;i<order/2;i++)
{
- xq[2*i] += codebook2[ndim*n2/2+i];
- xq[2*i+1] += codebook3[ndim*n3/2+i];
+ xq[2*i] += codebook2[order*n2/2+i];
+ xq[2*i+1] += codebook3[order*n3/2+i];
}
}
}
#endif
-int check_lsp_order(float lsp[], int lpc_order)
+int check_lsp_order(float lsp[], int order)
{
int i;
float tmp;
int swaps = 0;
- for(i=1; i<lpc_order; i++)
+ for(i=1; i<order; i++)
if (lsp[i] < lsp[i-1]) {
//fprintf(stderr, "swap %d\n",i);
swaps++;
return swaps;
}
-void force_min_lsp_dist(float lsp[], int lpc_order)
+void force_min_lsp_dist(float lsp[], int order)
{
int i;
- for(i=1; i<lpc_order; i++)
+ for(i=1; i<order; i++)
if ((lsp[i]-lsp[i-1]) < 0.01) {
lsp[i] += 0.01;
}
\*---------------------------------------------------------------------------*/
-void lpc_post_filter(kiss_fft_cfg fft_fwd_cfg, MODEL *model, COMP Pw[], float ak[],
+void lpc_post_filter(kiss_fft_cfg fft_fwd_cfg, COMP Pw[], float ak[],
int order, int dump, float beta, float gamma, int bass_boost)
{
int i;
TIMER_SAMPLE_AND_LOG(tpw, tfft, " Pw");
if (pf)
- lpc_post_filter(fft_fwd_cfg, model, Pw, ak, order, dump, beta, gamma, bass_boost);
+ lpc_post_filter(fft_fwd_cfg, Pw, ak, order, dump, beta, gamma, bass_boost);
TIMER_SAMPLE_AND_LOG(tpf, tpw, " LPC post filter");
{
int i, roots;
float Wn[M];
- float R[LPC_MAX+1];
+ float R[order+1];
float e, E;
e = 0.0;
{
int i,k,m;
float wt[1];
- float lsp_hz[LPC_MAX];
+ float lsp_hz[order];
const float * cb;
float se;
void decode_lsps_scalar(float lsp[], int indexes[], int order)
{
int i,k;
- float lsp_hz[LPC_MAX];
+ float lsp_hz[order];
const float * cb;
for(i=0; i<order; i++) {
void encode_lsps_diff_freq_vq(int indexes[], float lsp[], int order)
{
int i,k,m;
- float lsp_hz[LPC_MAX];
- float lsp__hz[LPC_MAX];
- float dlsp[LPC_MAX];
- float dlsp_[LPC_MAX];
- float wt[LPC_MAX];
+ float lsp_hz[order];
+ float lsp__hz[order];
+ float dlsp[order];
+ float dlsp_[order];
+ float wt[order];
const float * cb;
float se;
- for(i=0; i<LPC_ORD; i++) {
+ for(i=0; i<order; i++) {
wt[i] = 1.0;
}
void decode_lsps_diff_freq_vq(float lsp_[], int indexes[], int order)
{
int i,k,m;
- float dlsp_[LPC_MAX];
- float lsp__hz[LPC_MAX];
+ float dlsp_[order];
+ float lsp__hz[order];
const float * cb;
/* scalar LSP differences */
int order)
{
int i,k,m;
- float lsps_dt[LPC_ORD];
+ float lsps_dt[order];
float wt[LPC_MAX];
const float * cb;
float se;
/* Determine difference in time and convert from radians to Hz so
we can use human readable frequencies */
- for(i=0; i<LPC_ORD; i++) {
+ for(i=0; i<order; i++) {
lsps_dt[i] = (4000/PI)*(lsps[i] - lsps__prev[i]);
}
\*---------------------------------------------------------------------------*/
-void encode_lsps_vq(int *indexes, float *x, float *xq, int ndim)
+void encode_lsps_vq(int *indexes, float *x, float *xq, int order)
{
int i, n1, n2, n3;
- float err[LPC_ORD], err2[LPC_ORD], err3[LPC_ORD];
- float w[LPC_ORD], w2[LPC_ORD], w3[LPC_ORD];
+ float err[order], err2[order], err3[order];
+ float w[order], w2[order], w3[order];
const float *codebook1 = lsp_cbjvm[0].cb;
const float *codebook2 = lsp_cbjvm[1].cb;
const float *codebook3 = lsp_cbjvm[2].cb;
- assert(ndim <= LPC_ORD);
-
w[0] = MIN(x[0], x[1]-x[0]);
- for (i=1;i<ndim-1;i++)
+ for (i=1;i<order-1;i++)
w[i] = MIN(x[i]-x[i-1], x[i+1]-x[i]);
- w[ndim-1] = MIN(x[ndim-1]-x[ndim-2], PI-x[ndim-1]);
+ w[order-1] = MIN(x[order-1]-x[order-2], PI-x[order-1]);
- compute_weights(x, w, ndim);
+ compute_weights(x, w, order);
- n1 = find_nearest(codebook1, lsp_cbjvm[0].m, x, ndim);
+ n1 = find_nearest(codebook1, lsp_cbjvm[0].m, x, order);
- for (i=0;i<ndim;i++)
+ for (i=0;i<order;i++)
{
- xq[i] = codebook1[ndim*n1+i];
+ xq[i] = codebook1[order*n1+i];
err[i] = x[i] - xq[i];
}
- for (i=0;i<ndim/2;i++)
+ for (i=0;i<order/2;i++)
{
err2[i] = err[2*i];
err3[i] = err[2*i+1];
w2[i] = w[2*i];
w3[i] = w[2*i+1];
}
- n2 = find_nearest_weighted(codebook2, lsp_cbjvm[1].m, err2, w2, ndim/2);
- n3 = find_nearest_weighted(codebook3, lsp_cbjvm[2].m, err3, w3, ndim/2);
+ n2 = find_nearest_weighted(codebook2, lsp_cbjvm[1].m, err2, w2, order/2);
+ n3 = find_nearest_weighted(codebook3, lsp_cbjvm[2].m, err3, w3, order/2);
indexes[0] = n1;
indexes[1] = n2;
\*---------------------------------------------------------------------------*/
-void decode_lsps_vq(int *indexes, float *xq, int ndim)
+void decode_lsps_vq(int *indexes, float *xq, int order)
{
int i, n1, n2, n3;
const float *codebook1 = lsp_cbjvm[0].cb;
n2 = indexes[1];
n3 = indexes[2];
- for (i=0;i<ndim;i++)
+ for (i=0;i<order;i++)
{
- xq[i] = codebook1[ndim*n1+i];
+ xq[i] = codebook1[order*n1+i];
}
- for (i=0;i<ndim/2;i++)
+ for (i=0;i<order/2;i++)
{
- xq[2*i] += codebook2[ndim*n2/2+i];
- xq[2*i+1] += codebook3[ndim*n3/2+i];
+ xq[2*i] += codebook2[order*n2/2+i];
+ xq[2*i+1] += codebook3[order*n3/2+i];
}
}
static float ge_coeff[2] = {0.8, 0.9};
-void compute_weights2(const float *x, const float *xp, float *w, int ndim)
+void compute_weights2(const float *x, const float *xp, float *w)
{
w[0] = 30;
w[1] = 1;
x[0] = log10f((model->Wo/PI)*4000.0/50.0)/log10f(2);
x[1] = 10.0*log10f(1e-4 + *e);
- compute_weights2(x, xq, w, ndim);
+ compute_weights2(x, xq, w);
for (i=0;i<ndim;i++)
err[i] = x[i]-ge_coeff[i]*xq[i];
n1 = find_nearest_weighted(codebook1, nb_entries, err, w, ndim);
x[0] = log10f((model->Wo/PI)*4000.0/50.0)/log10f(2);
x[1] = 10.0*log10f(1e-4 + e);
- compute_weights2(x, xq, w, ndim);
+ compute_weights2(x, xq, w);
for (i=0;i<ndim;i++)
err[i] = x[i]-ge_coeff[i]*xq[i];
n1 = find_nearest_weighted(codebook1, nb_entries, err, w, ndim);
float lsp__prev[],
int order);
-void encode_lsps_vq(int *indexes, float *x, float *xq, int ndim);
-void decode_lsps_vq(int *indexes, float *xq, int ndim);
+void encode_lsps_vq(int *indexes, float *x, float *xq, int order);
+void decode_lsps_vq(int *indexes, float *xq, int order);
long quantise(const float * cb, float vec[], float w[], int k, int m, float *se);
void lspvq_quantise(float lsp[], float lsp_[], int order);
COMP W[],
COMP Sw_[], /* DFT of all voiced synthesised signal */
/* useful for debugging/dump file */
- COMP Ew[], /* DFT of error */
- float prev_Wo)
+ COMP Ew[]) /* DFT of error */
{
int i,l,al,bl,m; /* loop variables */
COMP Am; /* amplitude sample for this band */
void dft_speech(kiss_fft_cfg fft_fwd_cfg, COMP Sw[], float Sn[], float w[]);
void two_stage_pitch_refinement(MODEL *model, COMP Sw[]);
void estimate_amplitudes(MODEL *model, COMP Sw[], COMP W[], int est_phase);
-float est_voicing_mbe(MODEL *model, COMP Sw[], COMP W[], COMP Sw_[],COMP Ew[],
- float prev_Wo);
+float est_voicing_mbe(MODEL *model, COMP Sw[], COMP W[], COMP Sw_[],COMP Ew[]);
void make_synthesis_window(float Pn[]);
void synthesise(kiss_fft_cfg fft_inv_cfg, float Sn_[], MODEL *model, float Pn[], int shift);