void scfft_doifft(scfft * f) { #if SC_FFT_FFTW float *trbuf = f->trbuf; size_t bytesize = f->nfull * sizeof(float); memcpy(trbuf, f->indata, bytesize); trbuf[1] = 0.f; trbuf[f->nfull] = f->indata[1]; // Nyquist goes all the way down to the end of the line... trbuf[f->nfull+1] = 0.f; fftwf_execute(f->plan); // NB the plan already includes copying data to f->outbuf #elif SC_FFT_VDSP vDSP_ctoz((COMPLEX*) f->indata, 2, &splitBuf, 1, f->nfull >> 1); vDSP_fft_zrip(fftSetup[f->log2nfull], &splitBuf, 1, f->log2nfull, FFT_INVERSE); vDSP_ztoc(&splitBuf, 1, (DSPComplex*) f->outdata, 2, f->nfull >> 1); #elif SC_FFT_GREEN float *trbuf = f->trbuf; size_t bytesize = f->nfull * sizeof(float); memcpy(trbuf, f->indata, bytesize); // Green FFT is in-place riffts(trbuf, f->log2nfull, 1, cosTable[f->log2nfull]); // Copy to public buffer memcpy(f->outdata, trbuf, f->nwin * sizeof(float)); #endif scfft_dowindowing(f->outdata, f->nwin, f->nfull, f->log2nwin, f->wintype, f->scalefac); }
void scfft_dofft(scfft *f){ // Data goes to transform buf memcpy(f->trbuf, f->indata, f->nwin * sizeof(float)); scfft_dowindowing(f->trbuf, f->nwin, f->nfull, f->log2nfull, f->wintype, f->scalefac); #if SC_FFT_FFTW fftwf_execute(f->plan); // Rearrange output data onto public buffer memcpy(f->outdata, f->trbuf, f->nfull * sizeof(float)); f->outdata[1] = f->trbuf[f->nfull]; // Pack nyquist val in #elif SC_FFT_VDSP // Perform even-odd split vDSP_ctoz((COMPLEX*) f->trbuf, 2, &splitBuf, 1, f->nfull >> 1); // Now the actual FFT vDSP_fft_zrip(fftSetup[f->log2nfull], &splitBuf, 1, f->log2nfull, FFT_FORWARD); // Copy the data to the public output buf, transforming it back out of "split" representation vDSP_ztoc(&splitBuf, 1, (DSPComplex*) f->outdata, 2, f->nfull >> 1); #endif }