fft_enc_cfg = kiss_fft_alloc(FFT_ENC, 1, NULL, NULL);
fft_dec_cfg = kiss_fft_alloc(FFT_DEC, 0, NULL, NULL);
- make_analysis_window(fft_enc_cfg, w,W);
+ make_analysis_window(fft_enc_cfg, w, W);
make_synthesis_window(Pn);
quantise_init();
}
- aks_to_M2(ak, order, &model, e, &snr, 1);
+ aks_to_M2(fft_dec_cfg, ak, order, &model, e, &snr, 1);
/* note SNR on interpolated frames can't be measured properly
by comparing Am as L has changed. We can dump interp lsps
interp_model.voiced = voiced1;
- interpolate_lsp(&interp_model, &prev_model, &model,
+ interpolate_lsp(fft_dec_cfg, &interp_model, &prev_model, &model,
prev_lsps_, prev_e, lsps_, e, ak_interp, lsps_interp);
apply_lpc_correction(&interp_model);
#endif
if (phase0)
- phase_synth_zero_order(&interp_model, ak_interp, ex_phase,
+ phase_synth_zero_order(fft_dec_cfg, &interp_model, ak_interp, ex_phase,
order);
if (postfilt)
postfilter(&interp_model, &bg_est);
/* decode this frame */
if (phase0)
- phase_synth_zero_order(&model, ak, ex_phase, order);
+ phase_synth_zero_order(fft_dec_cfg, &model, ak, ex_phase, order);
if (postfilt)
postfilter(&model, &bg_est);
synth_one_frame(fft_dec_cfg, buf, &model, Sn_, Pn);
/* no decimation - sythesise each 10ms frame immediately */
if (phase0)
- phase_synth_zero_order(&model, ak, ex_phase, order);
+ phase_synth_zero_order(fft_dec_cfg, &model, ak, ex_phase, order);
if (postfilt)
postfilter(&model, &bg_est);
synth_one_frame(fft_dec_cfg, buf, &model, Sn_, Pn);
interpolate_lsp_ver2(&lsps[0][0], c2->prev_lsps_dec, &lsps[1][0], 0.5);
for(i=0; i<2; i++) {
lsp_to_lpc(&lsps[i][0], &ak[i][0], LPC_ORD);
- aks_to_M2(&ak[i][0], LPC_ORD, &model[i], e[i], &snr, 1);
+ aks_to_M2(c2->fft_dec_cfg, &ak[i][0], LPC_ORD, &model[i], e[i], &snr, 1);
apply_lpc_correction(&model[i]);
}
}
for(i=0; i<4; i++) {
lsp_to_lpc(&lsps[i][0], &ak[i][0], LPC_ORD);
- aks_to_M2(&ak[i][0], LPC_ORD, &model[i], e[i], &snr, 1);
+ aks_to_M2(c2->fft_dec_cfg, &ak[i][0], LPC_ORD, &model[i], e[i], &snr, 1);
apply_lpc_correction(&model[i]);
}
}
for(i=0; i<4; i++) {
lsp_to_lpc(&lsps[i][0], &ak[i][0], LPC_ORD);
- aks_to_M2(&ak[i][0], LPC_ORD, &model[i], e[i], &snr, 1);
+ aks_to_M2(c2->fft_dec_cfg, &ak[i][0], LPC_ORD, &model[i], e[i], &snr, 1);
apply_lpc_correction(&model[i]);
}
{
int i;
- phase_synth_zero_order(model, ak, &c2->ex_phase, LPC_ORD);
+ phase_synth_zero_order(c2->fft_dec_cfg, model, ak, &c2->ex_phase, LPC_ORD);
postfilter(model, &c2->bg_est);
synthesise(c2->fft_dec_cfg, c2->Sn_, model, c2->Pn, 1);
\*---------------------------------------------------------------------------*/
void interpolate_lsp(
+ kiss_fft_cfg fft_dec_cfg,
MODEL *interp, /* interpolated model params */
MODEL *prev, /* previous frames model params */
MODEL *next, /* next frames model params */
/* convert back to amplitudes */
lsp_to_lpc(lsps_interp, ak_interp, LPC_ORD);
- aks_to_M2(ak_interp, LPC_ORD, interp, e, &snr, 0);
+ aks_to_M2(fft_dec_cfg, ak_interp, LPC_ORD, interp, e, &snr, 0);
//printf(" interp: ak[1]: %f A[1] %f\n", ak_interp[1], interp->A[1]);
}
#ifndef __INTERP__
#define __INTERP__
+#include "kiss_fft.h"
+
void interpolate(MODEL *interp, MODEL *prev, MODEL *next);
-void interpolate_lsp(MODEL *interp, MODEL *prev, MODEL *next,
- float *prev_lsps, float prev_e,
- float *next_lsps, float next_e,
- float *ak_interp, float *lsps_interp);
+void interpolate_lsp(kiss_fft_cfg fft_dec_cfg,
+ MODEL *interp, MODEL *prev, MODEL *next,
+ float *prev_lsps, float prev_e,
+ float *next_lsps, float next_e,
+ float *ak_interp, float *lsps_interp);
void interp_Wo(MODEL *interp, MODEL *prev, MODEL *next);
float interp_energy(float prev, float next);
void interpolate_lsp_ver2(float interp[], float prev[], float next[], float weight);
dump_dec(Fw);
#endif
kiss_fft(nlp->fft_cfg, (kiss_fft_cpx *)fw, (kiss_fft_cpx *)Fw);
- //fft(&Fw[0].real,PE_FFT_SIZE,1);
for(i=0; i<PE_FFT_SIZE; i++)
Fw[i].real = Fw[i].real*Fw[i].real + Fw[i].imag*Fw[i].imag;
\*---------------------------------------------------------------------------*/
void aks_to_H(
+ kiss_fft_cfg fft_dec_cfg,
MODEL *model, /* model parameters */
float aks[], /* LPC's */
float G, /* energy term */
int order
)
{
- COMP Pw[FFT_DEC]; /* power spectrum */
+ COMP pw[FFT_DEC]; /* power spectrum (input) */
+ COMP Pw[FFT_DEC]; /* power spectrum (output) */
int i,m; /* loop variables */
int am,bm; /* limits of current band */
float r; /* no. rads/bin */
/* Determine DFT of A(exp(jw)) ------------------------------------------*/
for(i=0; i<FFT_DEC; i++) {
- Pw[i].real = 0.0;
- Pw[i].imag = 0.0;
+ pw[i].real = 0.0;
+ pw[i].imag = 0.0;
}
for(i=0; i<=order; i++)
- Pw[i].real = aks[i];
+ pw[i].real = aks[i];
- fft(&Pw[0].real,FFT_DEC,-1);
+ kiss_fft(fft_dec_cfg, (kiss_fft_cpx *)pw, (kiss_fft_cpx *)Pw);
/* Sample magnitude and phase at harmonics */
\*---------------------------------------------------------------------------*/
void phase_synth_zero_order(
+ kiss_fft_cfg fft_dec_cfg,
MODEL *model,
float aks[],
float *ex_phase, /* excitation phase of fundamental */
int b;
G = 1.0;
- aks_to_H(model, aks, G, H, order);
+ aks_to_H(fft_dec_cfg, model, aks, G, H, order);
/*
Update excitation fundamental phase track, this sets the position
#ifndef __PHASE__
#define __PHASE__
-void phase_synth_zero_order(MODEL *model, float aks[], float *ex_phase,
- int order);
+#include "kiss_fft.h"
+
+void phase_synth_zero_order(kiss_fft_cfg fft_dec_cfg, MODEL *model, float aks[],
+ float *ex_phase, int order);
#endif
#include "quantise.h"
#include "lpc.h"
#include "lsp.h"
-#include "fft.h"
+#include "kiss_fft.h"
#define LSP_DELTA1 0.01 /* grid spacing for LSP root searches */
}
}
+#ifdef NOT_USED
/*---------------------------------------------------------------------------*\
lpc_model_amplitudes
return snr;
}
+#endif
/*---------------------------------------------------------------------------*\
\*---------------------------------------------------------------------------*/
void aks_to_M2(
- float ak[], /* LPC's */
- int order,
- MODEL *model, /* sinusoidal model parameters for this frame */
- float E, /* energy term */
- float *snr, /* signal to noise ratio for this frame in dB */
- int dump /* true to dump sample to dump file */
+ kiss_fft_cfg fft_dec_cfg,
+ float ak[], /* LPC's */
+ int order,
+ MODEL *model, /* sinusoidal model parameters for this frame */
+ float E, /* energy term */
+ float *snr, /* signal to noise ratio for this frame in dB */
+ int dump /* true to dump sample to dump file */
)
{
- COMP Pw[FFT_DEC]; /* power spectrum */
+ COMP pw[FFT_DEC]; /* input to FFT for power spectrum */
+ COMP Pw[FFT_DEC]; /* output power spectrum */
int i,m; /* loop variables */
int am,bm; /* limits of current band */
float r; /* no. rads/bin */
/* Determine DFT of A(exp(jw)) --------------------------------------------*/
for(i=0; i<FFT_DEC; i++) {
- Pw[i].real = 0.0;
- Pw[i].imag = 0.0;
+ pw[i].real = 0.0;
+ pw[i].imag = 0.0;
}
for(i=0; i<=order; i++)
- Pw[i].real = ak[i];
- fft(&Pw[0].real,FFT_DEC,1);
+ pw[i].real = ak[i];
+ kiss_fft(fft_dec_cfg, (kiss_fft_cpx *)pw, (kiss_fft_cpx *)Pw);
/* Determine power spectrum P(w) = E/(A(exp(jw))^2 ------------------------*/
for(i=0; i<FFT_DEC/2; i++)
Pw[i].real = E/(Pw[i].real*Pw[i].real + Pw[i].imag*Pw[i].imag);
-#ifdef DUMP
+ #ifdef DUMP
if (dump)
dump_Pw(Pw);
-#endif
+ #endif
/* Determine magnitudes by linear interpolation of P(w) -------------------*/
return e;
}
+#ifdef NOT_USED
/*---------------------------------------------------------------------------*\
FUNCTION....: decode_amplitudes()
\*---------------------------------------------------------------------------*/
-float decode_amplitudes(MODEL *model,
+float decode_amplitudes(kiss_fft_cfg fft_dec_cfg,
+ MODEL *model,
float ak[],
int lsp_indexes[],
int energy_index,
return snr;
}
-
+#endif
static float ge_coeff[2] = {0.8, 0.9};
#ifndef __QUANTISE__
#define __QUANTISE__
+#include "kiss_fft.h"
+
#define WO_BITS 7
#define WO_LEVELS (1<<WO_BITS)
#define WO_DT_BITS 3
void quantise_init();
float lpc_model_amplitudes(float Sn[], float w[], MODEL *model, int order,
int lsp,float ak[]);
-void aks_to_M2(float ak[], int order, MODEL *model, float E, float *snr,
- int dump);
+void aks_to_M2(kiss_fft_cfg fft_dec_cfg, float ak[], int order, MODEL *model,
+ float E, float *snr, int dump);
int encode_Wo(float Wo);
float decode_Wo(int index);