c@225: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ c@225: c@225: /* c@225: QM DSP Library c@225: c@225: Centre for Digital Music, Queen Mary, University of London. c@225: */ c@225: c@225: #ifndef FFT_H c@225: #define FFT_H c@225: c@225: class FFT c@225: { c@225: public: c@339: /** c@339: * Construct an FFT object to carry out complex-to-complex c@355: * transforms of size nsamples. nsamples does not have to be a c@355: * power of two. c@339: */ c@339: FFT(int nsamples); c@289: ~FFT(); c@225: c@339: /** c@339: * Carry out a forward or inverse transform (depending on the c@339: * value of inverse) of size nsamples, where nsamples is the value c@339: * provided to the constructor above. c@339: * c@339: * realIn and (where present) imagIn should contain nsamples each, c@339: * and realOut and imagOut should point to enough space to receive c@339: * nsamples each. c@339: * c@339: * imagIn may be NULL if the signal is real, but the other c@339: * pointers must be valid. c@339: * c@339: * The inverse transform is scaled by 1/nsamples. c@339: */ c@289: void process(bool inverse, c@289: const double *realIn, const double *imagIn, c@289: double *realOut, double *imagOut); c@289: c@289: private: c@355: class D; c@355: D *m_d; c@225: }; c@225: c@289: class FFTReal c@289: { c@289: public: c@339: /** c@339: * Construct an FFT object to carry out real-to-complex transforms c@355: * of size nsamples. nsamples does not have to be a power of two, c@357: * but it does have to be even. (Use the complex-complex FFT above c@357: * if you need an odd FFT size. This constructor will throw c@357: * std::invalid_argument if nsamples is odd.) c@339: */ c@339: FFTReal(int nsamples); c@289: ~FFTReal(); c@289: c@339: /** c@339: * Carry out a forward real-to-complex transform of size nsamples, c@339: * where nsamples is the value provided to the constructor above. c@339: * c@339: * realIn, realOut, and imagOut must point to (enough space for) c@339: * nsamples values. For consistency with the FFT class above, and c@339: * compatibility with existing code, the conjugate half of the c@339: * output is returned even though it is redundant. c@339: */ c@339: void forward(const double *realIn, c@289: double *realOut, double *imagOut); c@289: c@339: /** c@357: * Carry out a forward real-to-complex transform of size nsamples, c@357: * where nsamples is the value provided to the constructor c@357: * above. Return only the magnitudes of the complex output values. c@357: * c@357: * realIn and magOut must point to (enough space for) nsamples c@357: * values. For consistency with the FFT class above, and c@357: * compatibility with existing code, the conjugate half of the c@357: * output is returned even though it is redundant. c@357: */ c@357: void forwardMagnitude(const double *realIn, double *magOut); c@357: c@357: /** c@339: * Carry out an inverse real transform (i.e. complex-to-real) of c@339: * size nsamples, where nsamples is the value provided to the c@339: * constructor above. c@339: * c@339: * realIn and imagIn should point to at least nsamples/2+1 values; c@339: * if more are provided, only the first nsamples/2+1 values of c@339: * each will be used (the conjugate half will always be deduced c@339: * from the first nsamples/2+1 rather than being read from the c@339: * input data). realOut should point to enough space to receive c@339: * nsamples values. c@339: * c@339: * The inverse transform is scaled by 1/nsamples. c@339: */ c@339: void inverse(const double *realIn, const double *imagIn, c@339: double *realOut); c@339: c@289: private: c@355: class D; c@355: D *m_d; c@289: }; c@289: c@225: #endif