end
printf(": ");
- if abs(sum(a - b))/n < 1E-3
+ if sum(abs(a - b))/n < 1E-3
printf("OK\n");
passes++;
else
sine.c \
codec2.c \
fdmdv.c \
-fft.c \
kiss_fft.c \
interp.c \
lsp.c \
am_libcodec2_la_OBJECTS = libcodec2_la-dump.lo libcodec2_la-lpc.lo \
libcodec2_la-nlp.lo libcodec2_la-postfilter.lo \
libcodec2_la-sine.lo libcodec2_la-codec2.lo \
- libcodec2_la-fdmdv.lo libcodec2_la-fft.lo \
- libcodec2_la-kiss_fft.lo libcodec2_la-interp.lo \
- libcodec2_la-lsp.lo libcodec2_la-phase.lo \
- libcodec2_la-quantise.lo libcodec2_la-pack.lo \
- libcodec2_la-codebook.lo libcodec2_la-codebookd.lo \
- libcodec2_la-codebookvq.lo libcodec2_la-codebookjnd.lo \
- libcodec2_la-codebookjvm.lo libcodec2_la-codebookdt.lo \
- libcodec2_la-codebookge.lo
+ libcodec2_la-fdmdv.lo libcodec2_la-kiss_fft.lo \
+ libcodec2_la-interp.lo libcodec2_la-lsp.lo \
+ libcodec2_la-phase.lo libcodec2_la-quantise.lo \
+ libcodec2_la-pack.lo libcodec2_la-codebook.lo \
+ libcodec2_la-codebookd.lo libcodec2_la-codebookvq.lo \
+ libcodec2_la-codebookjnd.lo libcodec2_la-codebookjvm.lo \
+ libcodec2_la-codebookdt.lo libcodec2_la-codebookge.lo
libcodec2_la_OBJECTS = $(am_libcodec2_la_OBJECTS)
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS)
sine.c \
codec2.c \
fdmdv.c \
-fft.c \
kiss_fft.c \
interp.c \
lsp.c \
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcodec2_la-codec2.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcodec2_la-dump.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcodec2_la-fdmdv.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcodec2_la-fft.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcodec2_la-interp.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcodec2_la-kiss_fft.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcodec2_la-lpc.Plo@am__quote@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcodec2_la_CFLAGS) $(CFLAGS) -c -o libcodec2_la-fdmdv.lo `test -f 'fdmdv.c' || echo '$(srcdir)/'`fdmdv.c
-libcodec2_la-fft.lo: fft.c
-@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcodec2_la_CFLAGS) $(CFLAGS) -MT libcodec2_la-fft.lo -MD -MP -MF "$(DEPDIR)/libcodec2_la-fft.Tpo" -c -o libcodec2_la-fft.lo `test -f 'fft.c' || echo '$(srcdir)/'`fft.c; \
-@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libcodec2_la-fft.Tpo" "$(DEPDIR)/libcodec2_la-fft.Plo"; else rm -f "$(DEPDIR)/libcodec2_la-fft.Tpo"; exit 1; fi
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='fft.c' object='libcodec2_la-fft.lo' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcodec2_la_CFLAGS) $(CFLAGS) -c -o libcodec2_la-fft.lo `test -f 'fft.c' || echo '$(srcdir)/'`fft.c
-
libcodec2_la-kiss_fft.lo: kiss_fft.c
@am__fastdepCC_TRUE@ if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcodec2_la_CFLAGS) $(CFLAGS) -MT libcodec2_la-kiss_fft.lo -MD -MP -MF "$(DEPDIR)/libcodec2_la-kiss_fft.Tpo" -c -o libcodec2_la-kiss_fft.lo `test -f 'kiss_fft.c' || echo '$(srcdir)/'`kiss_fft.c; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/libcodec2_la-kiss_fft.Tpo" "$(DEPDIR)/libcodec2_la-kiss_fft.Plo"; else rm -f "$(DEPDIR)/libcodec2_la-kiss_fft.Tpo"; exit 1; fi
#include "postfilter.h"
#include "interp.h"
-void synth_one_frame(kiss_fft_cfg fft_dec_cfg, short buf[], MODEL *model, float Sn_[], float Pn[]);
+void synth_one_frame(kiss_fft_cfg fft_inv_cfg, short buf[], MODEL *model, float Sn_[], float Pn[]);
void print_help(const struct option *long_options, int num_opts, char* argv[]);
/*---------------------------------------------------------------------------*\
short buf[N]; /* input/output buffer */
float Sn[M]; /* float input speech samples */
COMP Sw[FFT_ENC]; /* DFT of Sn[] */
- kiss_fft_cfg fft_enc_cfg;
- kiss_fft_cfg fft_dec_cfg;
+ kiss_fft_cfg fft_fwd_cfg;
+ kiss_fft_cfg fft_inv_cfg;
float w[M]; /* time domain hamming window */
COMP W[FFT_ENC]; /* DFT of w[] */
MODEL model;
/* Initialise ------------------------------------------------------------*/
- 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);
+ fft_fwd_cfg = kiss_fft_alloc(FFT_ENC, 0, NULL, NULL); /* fwd FFT,used in several places */
+ fft_inv_cfg = kiss_fft_alloc(FFT_DEC, 1, NULL, NULL); /* inverse FFT, used just for synth */
+ make_analysis_window(fft_fwd_cfg, w, W);
make_synthesis_window(Pn);
quantise_init();
nlp(nlp_states,Sn,N,M,P_MIN,P_MAX,&pitch,Sw,&prev_uq_Wo);
model.Wo = TWO_PI/pitch;
- dft_speech(fft_enc_cfg, Sw, Sn, w);
+ dft_speech(fft_fwd_cfg, Sw, Sn, w);
two_stage_pitch_refinement(&model, Sw);
estimate_amplitudes(&model, Sw, W);
uq_Wo = model.Wo;
}
- aks_to_M2(fft_dec_cfg, ak, order, &model, e, &snr, 1);
+ aks_to_M2(fft_fwd_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(fft_dec_cfg, &interp_model, &prev_model, &model,
+ interpolate_lsp(fft_fwd_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(fft_dec_cfg, &interp_model, ak_interp, ex_phase,
+ phase_synth_zero_order(fft_fwd_cfg, &interp_model, ak_interp, ex_phase,
order);
if (postfilt)
postfilter(&interp_model, &bg_est);
- synth_one_frame(fft_dec_cfg, buf, &interp_model, Sn_, Pn);
+ synth_one_frame(fft_inv_cfg, buf, &interp_model, Sn_, Pn);
//printf(" buf[0] %d\n", buf[0]);
if (fout != NULL)
fwrite(buf,sizeof(short),N,fout);
/* decode this frame */
if (phase0)
- phase_synth_zero_order(fft_dec_cfg, &model, ak, ex_phase, order);
+ phase_synth_zero_order(fft_fwd_cfg, &model, ak, ex_phase, order);
if (postfilt)
postfilter(&model, &bg_est);
- synth_one_frame(fft_dec_cfg, buf, &model, Sn_, Pn);
+ synth_one_frame(fft_inv_cfg, buf, &model, Sn_, Pn);
//printf(" buf[0] %d\n", buf[0]);
if (fout != NULL)
fwrite(buf,sizeof(short),N,fout);
/* no decimation - sythesise each 10ms frame immediately */
if (phase0)
- phase_synth_zero_order(fft_dec_cfg, &model, ak, ex_phase, order);
+ phase_synth_zero_order(fft_fwd_cfg, &model, ak, ex_phase, order);
if (postfilt)
postfilter(&model, &bg_est);
- synth_one_frame(fft_dec_cfg, buf, &model, Sn_, Pn);
+ synth_one_frame(fft_inv_cfg, buf, &model, Sn_, Pn);
if (fout != NULL) fwrite(buf,sizeof(short),N,fout);
}
return 0;
}
-void synth_one_frame(kiss_fft_cfg fft_dec_cfg, short buf[], MODEL *model, float Sn_[], float Pn[])
+void synth_one_frame(kiss_fft_cfg fft_inv_cfg, short buf[], MODEL *model, float Sn_[], float Pn[])
{
int i;
- synthesise(fft_dec_cfg, Sn_, model, Pn, 1);
+ synthesise(fft_inv_cfg, Sn_, model, Pn, 1);
for(i=0; i<N; i++) {
if (Sn_[i] > 32767.0)
c2->hpf_states[0] = c2->hpf_states[1] = 0.0;
for(i=0; i<2*N; i++)
c2->Sn_[i] = 0;
- c2->fft_enc_cfg = kiss_fft_alloc(FFT_ENC, 1, NULL, NULL);
- make_analysis_window(c2->fft_enc_cfg, c2->w,c2->W);
+ c2->fft_fwd_cfg = kiss_fft_alloc(FFT_ENC, 0, NULL, NULL);
+ make_analysis_window(c2->fft_fwd_cfg, c2->w,c2->W);
make_synthesis_window(c2->Pn);
- c2->fft_dec_cfg = kiss_fft_alloc(FFT_DEC, 0, NULL, NULL);
+ c2->fft_inv_cfg = kiss_fft_alloc(FFT_DEC, 1, NULL, NULL);
quantise_init();
c2->prev_Wo_enc = 0.0;
c2->bg_est = 0.0;
{
assert(c2 != NULL);
nlp_destroy(c2->nlp);
- KISS_FFT_FREE(c2->fft_enc_cfg);
- KISS_FFT_FREE(c2->fft_dec_cfg);
+ KISS_FFT_FREE(c2->fft_fwd_cfg);
+ KISS_FFT_FREE(c2->fft_inv_cfg);
free(c2);
}
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(c2->fft_dec_cfg, &ak[i][0], LPC_ORD, &model[i], e[i], &snr, 1);
+ aks_to_M2(c2->fft_fwd_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(c2->fft_dec_cfg, &ak[i][0], LPC_ORD, &model[i], e[i], &snr, 1);
+ aks_to_M2(c2->fft_fwd_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(c2->fft_dec_cfg, &ak[i][0], LPC_ORD, &model[i], e[i], &snr, 1);
+ aks_to_M2(c2->fft_fwd_cfg, &ak[i][0], LPC_ORD, &model[i], e[i], &snr, 1);
apply_lpc_correction(&model[i]);
}
{
int i;
- phase_synth_zero_order(c2->fft_dec_cfg, model, ak, &c2->ex_phase, LPC_ORD);
+ phase_synth_zero_order(c2->fft_fwd_cfg, model, ak, &c2->ex_phase, LPC_ORD);
postfilter(model, &c2->bg_est);
- synthesise(c2->fft_dec_cfg, c2->Sn_, model, c2->Pn, 1);
+ synthesise(c2->fft_inv_cfg, c2->Sn_, model, c2->Pn, 1);
for(i=0; i<N; i++) {
if (c2->Sn_[i] > 32767.0)
for(i=0; i<N; i++)
c2->Sn[i+M-N] = speech[i];
- dft_speech(c2->fft_enc_cfg, Sw, c2->Sn, c2->w);
+ dft_speech(c2->fft_fwd_cfg, Sw, c2->Sn, c2->w);
/* Estimate pitch */
struct CODEC2 {
int mode;
- kiss_fft_cfg fft_enc_cfg; /* FFT config for encoder */
+ kiss_fft_cfg fft_fwd_cfg; /* forward FFT config */
float w[M]; /* time domain hamming window */
COMP W[FFT_ENC]; /* DFT of w[] */
float Pn[2*N]; /* trapezoidal synthesis window */
float hpf_states[2]; /* high pass filter states */
void *nlp; /* pitch predictor states */
- kiss_fft_cfg fft_dec_cfg; /* FFT config for decoder */
+ kiss_fft_cfg fft_inv_cfg; /* inverse FFT config */
float Sn_[2*N]; /* synthesised output speech */
float ex_phase; /* excitation model phase track */
float bg_est; /* background noise estimate for post filter */
#include "rn.h"
#include "test_bits.h"
#include "pilot_coeff.h"
+#include "kiss_fft.h"
#include "fft.h"
#include "hanning.h"
#include "os.h"
/* freq Offset estimation states */
+ f->fft_pilot_cfg = kiss_fft_alloc (MPILOTFFT, 0, NULL, NULL);
+ assert(f->fft_pilot_cfg != NULL);
+
for(i=0; i<NPILOTBASEBAND; i++) {
f->pilot_baseband1[i].real = f->pilot_baseband2[i].real = 0.0;
f->pilot_baseband1[i].imag = f->pilot_baseband2[i].imag = 0.0;
void CODEC2_WIN32SUPPORT fdmdv_destroy(struct FDMDV *fdmdv)
{
assert(fdmdv != NULL);
+ KISS_FFT_FREE(fdmdv->fft_pilot_cfg);
free(fdmdv);
}
\*---------------------------------------------------------------------------*/
-void lpf_peak_pick(float *foff, float *max, COMP pilot_baseband[], COMP pilot_lpf[], COMP S[], int nin)
+void lpf_peak_pick(float *foff, float *max, COMP pilot_baseband[],
+ COMP pilot_lpf[], kiss_fft_cfg fft_pilot_cfg, COMP S[], int nin)
{
int i,j,k;
int mpilot;
+ COMP s[MPILOTFFT];
float mag, imax;
int ix;
float r;
mpilot = FS/(2*200); /* calc decimation rate given new sample rate is twice LPF freq */
for(i=0; i<MPILOTFFT; i++) {
- S[i].real = 0.0; S[i].imag = 0.0;
+ s[i].real = 0.0; s[i].imag = 0.0;
}
for(i=0,j=0; i<NPILOTLPF; i+=mpilot,j++) {
- S[j] = fcmult(hanning[i], pilot_lpf[i]);
+ s[j] = fcmult(hanning[i], pilot_lpf[i]);
}
- fft(&S[0].real, MPILOTFFT, -1);
+ kiss_fft(fft_pilot_cfg, (kiss_fft_cpx *)s, (kiss_fft_cpx *)S);
/* peak pick and convert to Hz */
f->pilot_baseband2[j] = fcmult(rx_fdm[i], cconj(prev_pilot[i]));
}
- lpf_peak_pick(&foff1, &max1, f->pilot_baseband1, f->pilot_lpf1, f->S1, nin);
- lpf_peak_pick(&foff2, &max2, f->pilot_baseband2, f->pilot_lpf2, f->S2, nin);
+ lpf_peak_pick(&foff1, &max1, f->pilot_baseband1, f->pilot_lpf1, f->fft_pilot_cfg, f->S1, nin);
+ lpf_peak_pick(&foff2, &max2, f->pilot_baseband2, f->pilot_lpf2, f->fft_pilot_cfg, f->S2, nin);
if (max1 > max2)
foff = foff1;
fft_io[i].real = 1.0;
fft_io[i].imag = 0.0;
}
- fft(&fft_io[0].real, 2*FDMDV_NFFT, -1);
+ //fft(&fft_io[0].real, 2*FDMDV_NFFT, -1);
printf("%d fft_io[%d] %f %f\n", FDMDV_NFFT,0, fft_io[0].real, fft_io[0].imag);
#ifdef TMP
#include "comp.h"
#include "fdmdv.h"
+#include "kiss_fft.h"
/*---------------------------------------------------------------------------*\
/* freq offset estimation states */
+ kiss_fft_cfg fft_pilot_cfg;
COMP pilot_baseband1[NPILOTBASEBAND];
COMP pilot_baseband2[NPILOTBASEBAND];
COMP pilot_lpf1[NPILOTLPF];
void generate_pilot_fdm(COMP *pilot_fdm, int *bit, float *symbol, float *filter_mem, COMP *phase, COMP *freq);
void generate_pilot_lut(COMP pilot_lut[], COMP *pilot_freq);
float rx_est_freq_offset(struct FDMDV *f, float rx_fdm[], int nin);
-void lpf_peak_pick(float *foff, float *max, COMP pilot_baseband[], COMP pilot_lpf[], COMP S[], int nin);
+void lpf_peak_pick(float *foff, float *max, COMP pilot_baseband[], COMP pilot_lpf[], kiss_fft_cfg fft_pilot_cfg, COMP S[], int nin);
void freq_shift(COMP rx_fdm_fcorr[], float rx_fdm[], float foff, COMP *foff_rect, COMP *foff_phase_rect, int nin);
void fdm_downconvert(COMP rx_baseband[NC+1][M+M/P], COMP rx_fdm[], COMP phase_rx[], COMP freq[], int nin);
void rx_filter(COMP rx_filt[NC+1][P+1], COMP rx_baseband[NC+1][M+M/P], COMP rx_filter_memory[NC+1][NFILTER], int nin);
\*---------------------------------------------------------------------------*/
void interpolate_lsp(
- kiss_fft_cfg fft_dec_cfg,
+ kiss_fft_cfg fft_fwd_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(fft_dec_cfg, ak_interp, LPC_ORD, interp, e, &snr, 0);
+ aks_to_M2(fft_fwd_cfg, ak_interp, LPC_ORD, interp, e, &snr, 0);
//printf(" interp: ak[1]: %f A[1] %f\n", ak_interp[1], interp->A[1]);
}
for(i=0; i<NLP_NTAP; i++)
nlp->mem_fir[i] = 0.0;
- nlp->fft_cfg = kiss_fft_alloc (PE_FFT_SIZE, 1, NULL, NULL);
+ nlp->fft_cfg = kiss_fft_alloc (PE_FFT_SIZE, 0, NULL, NULL);
assert(nlp->fft_cfg != NULL);
return (void*)nlp;
for(i=0; i<m/DEC; i++) {
fw[i].real = nlp->sq[i*DEC]*(0.5 - 0.5*cos(2*PI*i/(m/DEC-1)));
}
-#ifdef DUMP
+ #ifdef DUMP
dump_dec(Fw);
-#endif
+ #endif
+
kiss_fft(nlp->fft_cfg, (kiss_fft_cpx *)fw, (kiss_fft_cpx *)Fw);
for(i=0; i<PE_FFT_SIZE; i++)
Fw[i].real = Fw[i].real*Fw[i].real + Fw[i].imag*Fw[i].imag;
-#ifdef DUMP
+ #ifdef DUMP
dump_sq(nlp->sq);
dump_Fw(Fw);
-#endif
+ #endif
/* find global peak */
\*---------------------------------------------------------------------------*/
void aks_to_H(
- kiss_fft_cfg fft_dec_cfg,
+ kiss_fft_cfg fft_fwd_cfg,
MODEL *model, /* model parameters */
float aks[], /* LPC's */
float G, /* energy term */
int order
)
{
- COMP pw[FFT_DEC]; /* power spectrum (input) */
- COMP Pw[FFT_DEC]; /* power spectrum (output) */
+ COMP pw[FFT_ENC]; /* power spectrum (input) */
+ COMP Pw[FFT_ENC]; /* power spectrum (output) */
int i,m; /* loop variables */
int am,bm; /* limits of current band */
float r; /* no. rads/bin */
int b; /* centre bin of harmonic */
float phi_; /* phase of LPC spectra */
- r = TWO_PI/(FFT_DEC);
+ r = TWO_PI/(FFT_ENC);
/* Determine DFT of A(exp(jw)) ------------------------------------------*/
- for(i=0; i<FFT_DEC; i++) {
+ for(i=0; i<FFT_ENC; i++) {
pw[i].real = 0.0;
pw[i].imag = 0.0;
}
for(i=0; i<=order; i++)
pw[i].real = aks[i];
- kiss_fft(fft_dec_cfg, (kiss_fft_cpx *)pw, (kiss_fft_cpx *)Pw);
+ kiss_fft(fft_fwd_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,
+ kiss_fft_cfg fft_fwd_cfg,
MODEL *model,
float aks[],
float *ex_phase, /* excitation phase of fundamental */
int b;
G = 1.0;
- aks_to_H(fft_dec_cfg, model, aks, G, H, order);
+ aks_to_H(fft_fwd_cfg, model, aks, G, H, order);
/*
Update excitation fundamental phase track, this sets the position
\*---------------------------------------------------------------------------*/
void aks_to_M2(
- kiss_fft_cfg fft_dec_cfg,
+ kiss_fft_cfg fft_fwd_cfg,
float ak[], /* LPC's */
int order,
MODEL *model, /* sinusoidal model parameters for this frame */
int dump /* true to dump sample to dump file */
)
{
- COMP pw[FFT_DEC]; /* input to FFT for power spectrum */
- COMP Pw[FFT_DEC]; /* output power spectrum */
+ COMP pw[FFT_ENC]; /* input to FFT for power spectrum */
+ COMP Pw[FFT_ENC]; /* output power spectrum */
int i,m; /* loop variables */
int am,bm; /* limits of current band */
float r; /* no. rads/bin */
float Am; /* spectral amplitude sample */
float signal, noise;
- r = TWO_PI/(FFT_DEC);
+ r = TWO_PI/(FFT_ENC);
/* Determine DFT of A(exp(jw)) --------------------------------------------*/
- for(i=0; i<FFT_DEC; i++) {
+ for(i=0; i<FFT_ENC; i++) {
pw[i].real = 0.0;
pw[i].imag = 0.0;
}
for(i=0; i<=order; i++)
pw[i].real = ak[i];
- kiss_fft(fft_dec_cfg, (kiss_fft_cpx *)pw, (kiss_fft_cpx *)Pw);
+ kiss_fft(fft_fwd_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++)
+ for(i=0; i<FFT_ENC/2; i++)
Pw[i].real = E/(Pw[i].real*Pw[i].real + Pw[i].imag*Pw[i].imag);
#ifdef DUMP
if (dump)
\*---------------------------------------------------------------------------*/
-float decode_amplitudes(kiss_fft_cfg fft_dec_cfg,
+float decode_amplitudes(kiss_fft_cfg fft_fwd_cfg,
MODEL *model,
float ak[],
int lsp_indexes[],
void quantise_init();
float lpc_model_amplitudes(float Sn[], float w[], MODEL *model, int order,
int lsp,float ak[]);
-void aks_to_M2(kiss_fft_cfg fft_dec_cfg, float ak[], int order, MODEL *model,
+void aks_to_M2(kiss_fft_cfg fft_fwd_cfg, float ak[], int order, MODEL *model,
float E, float *snr, int dump);
int encode_Wo(float Wo);
\*---------------------------------------------------------------------------*/
-void make_analysis_window(kiss_fft_cfg fft_enc_cfg, float w[], COMP W[])
+void make_analysis_window(kiss_fft_cfg fft_fwd_cfg, float w[], COMP W[])
{
float m;
COMP wshift[FFT_ENC];
for(i=FFT_ENC-NW/2,j=M/2-NW/2; i<FFT_ENC; i++,j++)
wshift[i].real = w[j];
- kiss_fft(fft_enc_cfg, (kiss_fft_cpx *)wshift, (kiss_fft_cpx *)W);
+ kiss_fft(fft_fwd_cfg, (kiss_fft_cpx *)wshift, (kiss_fft_cpx *)W);
/*
Re-arrange W[] to be symmetrical about FFT_ENC/2. Makes later
\*---------------------------------------------------------------------------*/
-void dft_speech(kiss_fft_cfg fft_enc_cfg, COMP Sw[], float Sn[], float w[])
+void dft_speech(kiss_fft_cfg fft_fwd_cfg, COMP Sw[], float Sn[], float w[])
{
int i;
COMP sw[FFT_ENC];
for(i=0; i<NW/2; i++)
sw[FFT_ENC-NW/2+i].real = Sn[i+M/2-NW/2]*w[i+M/2-NW/2];
- kiss_fft(fft_enc_cfg, (kiss_fft_cpx *)sw, (kiss_fft_cpx *)Sw);
+ kiss_fft(fft_fwd_cfg, (kiss_fft_cpx *)sw, (kiss_fft_cpx *)Sw);
}
/*---------------------------------------------------------------------------*\
/* Estimate phase of harmonic */
- model->phi[m] = atan2(-Sw[b].imag,Sw[b].real);
+ model->phi[m] = atan2(Sw[b].imag,Sw[b].real);
}
}
\*---------------------------------------------------------------------------*/
void synthesise(
- kiss_fft_cfg fft_dec_cfg,
+ kiss_fft_cfg fft_inv_cfg,
float Sn_[], /* time domain synthesised signal */
MODEL *model, /* ptr to model parameters for this frame */
float Pn[], /* time domain Parzen window */
b = (FFT_DEC/2)-1;
}
Sw_[b].real = model->A[l]*cos(model->phi[l]);
- Sw_[b].imag = -model->A[l]*sin(model->phi[l]);
+ Sw_[b].imag = model->A[l]*sin(model->phi[l]);
Sw_[FFT_DEC-b].real = Sw_[b].real;
Sw_[FFT_DEC-b].imag = -Sw_[b].imag;
}
/* Perform inverse DFT */
- kiss_fft(fft_dec_cfg, (kiss_fft_cpx *)Sw_, (kiss_fft_cpx *)sw_);
+ kiss_fft(fft_inv_cfg, (kiss_fft_cpx *)Sw_, (kiss_fft_cpx *)sw_);
#else
/*
Direct time domain synthesis using the cos() function. Works
#include "comp.h"
#include "kiss_fft.h"
-void make_analysis_window(kiss_fft_cfg fft_enc_cfg, float w[], COMP W[]);
+void make_analysis_window(kiss_fft_cfg fft_fwd_cfg, float w[], COMP W[]);
float hpf(float x, float states[]);
-void dft_speech(kiss_fft_cfg fft_enc_cfg, COMP Sw[], float Sn[], float w[]);
+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[]);
float est_voicing_mbe(MODEL *model, COMP Sw[], COMP W[], COMP Sw_[],COMP Ew[],
float prev_Wo);
void make_synthesis_window(float Pn[]);
-void synthesise(kiss_fft_cfg fft_dec_cfg, float Sn_[], MODEL *model, float Pn[], int shift);
+void synthesise(kiss_fft_cfg fft_inv_cfg, float Sn_[], MODEL *model, float Pn[], int shift);
#endif
NAME = libcodec2
AM_CPPFLAGS = $(AM_CFLAGS)
-noinst_PROGRAMS = genres genlsp extract vqtrain vqtrainjnd tnlp tinterp tquant tcodec2 vq_train_jvm scalarlsptest tfdmdv t48_8 lspsync create_interleaver tlspsens
+noinst_PROGRAMS = genres genlsp extract vqtrain vqtrainjnd tnlp tinterp tquant vq_train_jvm scalarlsptest tfdmdv t48_8 lspsync create_interleaver tlspsens
genres_SOURCES = genres.c ../src/lpc.c
genres_LDADD = $(lib_LTLIBRARIES)
tquant_LDADD = $(lib_LTLIBRARIES)
tquant_LDFLAGS = $(LIBS)
-tcodec2_SOURCES = tcodec2.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/fft.c ../src/kiss_fft.c \
-../src/codec2.c ../src/sine.c ../src/nlp.c ../src/postfilter.c ../src/phase.c ../src/interp.c ../src/pack.c $(CODEBOOKS)
-tcodec2_LDADD = $(lib_LTLIBRARIES)
-tcodec2_LDFLAGS = $(LIBS)
-
scalarlsptest_SOURCES = scalarlsptest.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/fft.c ../src/kiss_fft.c $(CODEBOOKS)
scalarlsptest_LDADD = $(lib_LTLIBRARIES)
scalarlsptest_LDFLAGS = $(LIBS)
host_triplet = @host@
noinst_PROGRAMS = genres$(EXEEXT) genlsp$(EXEEXT) extract$(EXEEXT) \
vqtrain$(EXEEXT) vqtrainjnd$(EXEEXT) tnlp$(EXEEXT) \
- tinterp$(EXEEXT) tquant$(EXEEXT) tcodec2$(EXEEXT) \
- vq_train_jvm$(EXEEXT) scalarlsptest$(EXEEXT) tfdmdv$(EXEEXT) \
- t48_8$(EXEEXT) lspsync$(EXEEXT) create_interleaver$(EXEEXT) \
- tlspsens$(EXEEXT)
+ tinterp$(EXEEXT) tquant$(EXEEXT) vq_train_jvm$(EXEEXT) \
+ scalarlsptest$(EXEEXT) tfdmdv$(EXEEXT) t48_8$(EXEEXT) \
+ lspsync$(EXEEXT) create_interleaver$(EXEEXT) tlspsens$(EXEEXT)
subdir = unittest
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
kiss_fft.$(OBJEXT)
t48_8_OBJECTS = $(am_t48_8_OBJECTS)
t48_8_DEPENDENCIES =
-am_tcodec2_OBJECTS = tcodec2.$(OBJEXT) quantise.$(OBJEXT) \
- lpc.$(OBJEXT) lsp.$(OBJEXT) dump.$(OBJEXT) fft.$(OBJEXT) \
- kiss_fft.$(OBJEXT) codec2.$(OBJEXT) sine.$(OBJEXT) \
- nlp.$(OBJEXT) postfilter.$(OBJEXT) phase.$(OBJEXT) \
- interp.$(OBJEXT) pack.$(OBJEXT) $(am__objects_1)
-tcodec2_OBJECTS = $(am_tcodec2_OBJECTS)
-tcodec2_DEPENDENCIES =
am_tfdmdv_OBJECTS = tfdmdv.$(OBJEXT) fdmdv.$(OBJEXT) fft.$(OBJEXT) \
kiss_fft.$(OBJEXT) octave.$(OBJEXT)
tfdmdv_OBJECTS = $(am_tfdmdv_OBJECTS)
$(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(create_interleaver_SOURCES) $(extract_SOURCES) \
$(genlsp_SOURCES) $(genres_SOURCES) $(lspsync_SOURCES) \
- $(scalarlsptest_SOURCES) $(t48_8_SOURCES) $(tcodec2_SOURCES) \
- $(tfdmdv_SOURCES) $(tinterp_SOURCES) $(tlspsens_SOURCES) \
- $(tnlp_SOURCES) $(tquant_SOURCES) $(vq_train_jvm_SOURCES) \
- $(vqtrain_SOURCES) $(vqtrainjnd_SOURCES)
+ $(scalarlsptest_SOURCES) $(t48_8_SOURCES) $(tfdmdv_SOURCES) \
+ $(tinterp_SOURCES) $(tlspsens_SOURCES) $(tnlp_SOURCES) \
+ $(tquant_SOURCES) $(vq_train_jvm_SOURCES) $(vqtrain_SOURCES) \
+ $(vqtrainjnd_SOURCES)
DIST_SOURCES = $(create_interleaver_SOURCES) $(extract_SOURCES) \
$(genlsp_SOURCES) $(genres_SOURCES) $(lspsync_SOURCES) \
- $(scalarlsptest_SOURCES) $(t48_8_SOURCES) $(tcodec2_SOURCES) \
- $(tfdmdv_SOURCES) $(tinterp_SOURCES) $(tlspsens_SOURCES) \
- $(tnlp_SOURCES) $(tquant_SOURCES) $(vq_train_jvm_SOURCES) \
- $(vqtrain_SOURCES) $(vqtrainjnd_SOURCES)
+ $(scalarlsptest_SOURCES) $(t48_8_SOURCES) $(tfdmdv_SOURCES) \
+ $(tinterp_SOURCES) $(tlspsens_SOURCES) $(tnlp_SOURCES) \
+ $(tquant_SOURCES) $(vq_train_jvm_SOURCES) $(vqtrain_SOURCES) \
+ $(vqtrainjnd_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
tquant_SOURCES = tquant.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/fft.c ../src/kiss_fft.c $(CODEBOOKS)
tquant_LDADD = $(lib_LTLIBRARIES)
tquant_LDFLAGS = $(LIBS)
-tcodec2_SOURCES = tcodec2.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/fft.c ../src/kiss_fft.c \
-../src/codec2.c ../src/sine.c ../src/nlp.c ../src/postfilter.c ../src/phase.c ../src/interp.c ../src/pack.c $(CODEBOOKS)
-
-tcodec2_LDADD = $(lib_LTLIBRARIES)
-tcodec2_LDFLAGS = $(LIBS)
scalarlsptest_SOURCES = scalarlsptest.c ../src/quantise.c ../src/lpc.c ../src/lsp.c ../src/dump.c ../src/fft.c ../src/kiss_fft.c $(CODEBOOKS)
scalarlsptest_LDADD = $(lib_LTLIBRARIES)
scalarlsptest_LDFLAGS = $(LIBS)
t48_8$(EXEEXT): $(t48_8_OBJECTS) $(t48_8_DEPENDENCIES)
@rm -f t48_8$(EXEEXT)
$(LINK) $(t48_8_LDFLAGS) $(t48_8_OBJECTS) $(t48_8_LDADD) $(LIBS)
-tcodec2$(EXEEXT): $(tcodec2_OBJECTS) $(tcodec2_DEPENDENCIES)
- @rm -f tcodec2$(EXEEXT)
- $(LINK) $(tcodec2_LDFLAGS) $(tcodec2_OBJECTS) $(tcodec2_LDADD) $(LIBS)
tfdmdv$(EXEEXT): $(tfdmdv_OBJECTS) $(tfdmdv_DEPENDENCIES)
@rm -f tfdmdv$(EXEEXT)
$(LINK) $(tfdmdv_LDFLAGS) $(tfdmdv_OBJECTS) $(tfdmdv_LDADD) $(LIBS)
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scalarlsptest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sine.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t48_8.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcodec2.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tfdmdv.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tinterp.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tlspsens.Po@am__quote@
FILE *fin;
short buf[N];
struct CODEC2 *c2;
+ kiss_fft_cfg fft_fwd_cfg;
MODEL model;
float ak[LPC_ORD+1];
float lsps[LPC_ORD], e;
int frames, i, mask, index;
c2 = codec2_create(CODEC2_MODE_2400);
+ fft_fwd_cfg = kiss_fft_alloc(FFT_ENC, 0, NULL, NULL);
fin = fopen(raw_file_name, "rb");
assert(fin != NULL);
check_lsp_order(lsps, LPC_ORD);
bw_expand_lsps(lsps, LPC_ORD);
lsp_to_lpc(lsps, ak, LPC_ORD);
- aks_to_M2(ak, LPC_ORD, &model, e, &snr, 1);
+ aks_to_M2(fft_fwd_cfg, ak, LPC_ORD, &model, e, &snr, 1);
snr_sum += snr;
frames++;
#include "dump.h"
#include "sine.h"
#include "nlp.h"
+#include "kiss_fft.h"
int frames;
FILE *fin,*fout;
short buf[N];
float Sn[M]; /* float input speech samples */
+ kiss_fft_cfg fft_fwd_cfg;
COMP Sw[FFT_ENC]; /* DFT of Sn[] */
float w[M]; /* time domain hamming window */
COMP W[FFT_ENC]; /* DFT of w[] */
#endif
nlp_states = nlp_create();
- make_analysis_window(w,W);
+ fft_fwd_cfg = kiss_fft_alloc(FFT_ENC, 0, NULL, NULL);
+ make_analysis_window(fft_fwd_cfg, w, W);
frames = 0;
prev_Wo = 0;
Sn[i] = Sn[i+N];
for(i=0; i<N; i++)
Sn[i+M-N] = buf[i];
- dft_speech(Sw, Sn, w);
+ dft_speech(fft_fwd_cfg, Sw, Sn, w);
#ifdef DUMP
dump_Sn(Sn); dump_Sw(Sw);
#endif