/* stack used: 60 bytes */ void fir_fft_init(const short *coeffs, Complex *fft_coeffs, Complex *result, \ short *trail, int ncoeffs, int fft_N, int log_fft_N, \ fir_fft_state *s) { int i; int *hlp; s->c = fft_coeffs; /* set up pointers */ s->r = result; s->d = trail; s->k = ncoeffs; s->l = log_fft_N; s->n = fft_N; for(i = 0; i < ncoeffs-1; i++) trail[i] = 0; /* clear trail */ hlp = (int *) fft_coeffs; for(i = 0; i < ncoeffs; i++) hlp[i] = coeffs[i]; /* copy coeffs */ for(i = ncoeffs; i < fft_N; i++) hlp[i] = 0; /* add zero padding */ while(REALFFT(hlp, fft_coeffs, log_fft_N-1)) ; /* error */ }
void Helmholtz::autocorrelation() { int n; int fftsize = framesize * 2; REALFFT(fftsize, processbuf); // compute power spectrum processbuf[0] *= processbuf[0]; // DC processbuf[framesize] *= processbuf[framesize]; // Nyquist for(n=1; n<framesize; n++) { processbuf[n] = processbuf[n] * processbuf[n] + processbuf[fftsize-n] * processbuf[fftsize-n]; // imag coefficients appear reversed processbuf[fftsize-n] = 0.; } REALIFFT(fftsize, processbuf); }