float xq_enc[2]; /* joint pitch and energy VQ states */
float xq_dec[2];
+
+ int smoothing; /* enable smoothing for channels with errors */
};
#endif
MODEL *prev, /* previous frames model params */
MODEL *next /* next frames model params */
)
+{
+ interp_Wo2(interp, prev, next, 0.5);
+}
+
+/*---------------------------------------------------------------------------*\
+
+ FUNCTION....: interp_Wo2()
+ AUTHOR......: David Rowe
+ DATE CREATED: 22 May 2012
+
+ Weighted interpolation of two Wo samples.
+
+\*---------------------------------------------------------------------------*/
+
+void interp_Wo2(
+ MODEL *interp, /* interpolated model params */
+ MODEL *prev, /* previous frames model params */
+ MODEL *next, /* next frames model params */
+ float weight
+)
{
/* trap corner case where voicing est is probably wrong */
if (interp->voiced) {
if (prev->voiced && next->voiced)
- interp->Wo = (prev->Wo + next->Wo)/2.0;
+ interp->Wo = (1.0 - weight)*prev->Wo + weight*next->Wo;
if (!prev->voiced && next->voiced)
interp->Wo = next->Wo;
if (prev->voiced && !next->voiced)
}
+/*---------------------------------------------------------------------------*\
+
+ FUNCTION....: interp_energy2()
+ AUTHOR......: David Rowe
+ DATE CREATED: 22 May 2012
+
+ Interpolates centre 10ms sample of energy given two samples 20ms
+ apart.
+
+\*---------------------------------------------------------------------------*/
+
+float interp_energy2(float prev_e, float next_e, float weight)
+{
+ return pow(10.0, (1.0 - weight)*log10(prev_e) + weight*log10(next_e));
+
+}
+
+
/*---------------------------------------------------------------------------*\
FUNCTION....: interpolate_lsp_ver2()
float *next_lsps, float next_e,
float *ak_interp, float *lsps_interp);
void interp_Wo(MODEL *interp, MODEL *prev, MODEL *next);
+void interp_Wo2(MODEL *interp, MODEL *prev, MODEL *next, float weight);
float interp_energy(float prev, float next);
+float interp_energy2(float prev, float next, float weight);
void interpolate_lsp_ver2(float interp[], float prev[], float next[], float weight);
#endif
for(i=1; i<lpc_order; i++)
if (lsp[i] < lsp[i-1]) {
- //printf("swap %d\n",i);
+ //fprintf(stderr, "swap %d\n",i);
swaps++;
tmp = lsp[i-1];
- lsp[i-1] = lsp[i]-0.05;
- lsp[i] = tmp+0.05;
+ lsp[i-1] = lsp[i]-0.1;
+ lsp[i] = tmp+0.1;
+ i = 1; /* start check again, as swap may have caused out of order */
}
return swaps;
for(i=1; i<4; i++) {
- if ((lsp[i] - lsp[i-1]) < 50*(PI/4000.0))
+ if ((lsp[i] - lsp[i-1]) < 50.0*(PI/4000.0))
lsp[i] = lsp[i-1] + 50.0*(PI/4000.0);
}
*/
for(i=4; i<order; i++) {
- if (lsp[i] - lsp[i-1] < PI*(100.0/4000.0))
- lsp[i] = lsp[i-1] + PI*(100.0/4000.0);
+ if (lsp[i] - lsp[i-1] < 100.0*(PI/4000.0))
+ lsp[i] = lsp[i-1] + 100.0*(PI/4000.0);
+ }
+}
+
+void bw_expand_lsps2(float lsp[],
+ int order
+)
+{
+ int i;
+
+ for(i=1; i<4; i++) {
+
+ if ((lsp[i] - lsp[i-1]) < 100.0*(PI/4000.0))
+ lsp[i] = lsp[i-1] + 100.0*(PI/4000.0);
+
+ }
+
+ /* As quantiser gaps increased, larger BW expansion was required
+ to prevent twinkly noises. This may need more experiment for
+ different quanstisers.
+ */
+
+ for(i=4; i<order; i++) {
+ if (lsp[i] - lsp[i-1] < 200.0*(PI/4000.0))
+ lsp[i] = lsp[i-1] + 200.0*(PI/4000.0);
}
}
);
int check_lsp_order(float lsp[], int lpc_order);
void bw_expand_lsps(float lsp[], int order);
+void bw_expand_lsps2(float lsp[], int order);
void locate_lsps_jnd_steps(float lsp[], int order);
float decode_amplitudes(MODEL *model,
float ak[],