annotate dsp/transforms/FFT.h @ 355:3c7338aff6a8

Drop in kissfft to replace the "old" fft, and add tests for newly-supported sizes
author Chris Cannam <c.cannam@qmul.ac.uk>
date Tue, 15 Oct 2013 11:38:18 +0100
parents 9c8ee77db9de
children a586888bc06c
rev   line source
c@225 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
c@225 2
c@225 3 /*
c@225 4 QM DSP Library
c@225 5
c@225 6 Centre for Digital Music, Queen Mary, University of London.
c@225 7 */
c@225 8
c@225 9 #ifndef FFT_H
c@225 10 #define FFT_H
c@225 11
c@225 12 class FFT
c@225 13 {
c@225 14 public:
c@339 15 /**
c@339 16 * Construct an FFT object to carry out complex-to-complex
c@355 17 * transforms of size nsamples. nsamples does not have to be a
c@355 18 * power of two.
c@339 19 */
c@339 20 FFT(int nsamples);
c@289 21 ~FFT();
c@225 22
c@339 23 /**
c@339 24 * Carry out a forward or inverse transform (depending on the
c@339 25 * value of inverse) of size nsamples, where nsamples is the value
c@339 26 * provided to the constructor above.
c@339 27 *
c@339 28 * realIn and (where present) imagIn should contain nsamples each,
c@339 29 * and realOut and imagOut should point to enough space to receive
c@339 30 * nsamples each.
c@339 31 *
c@339 32 * imagIn may be NULL if the signal is real, but the other
c@339 33 * pointers must be valid.
c@339 34 *
c@339 35 * The inverse transform is scaled by 1/nsamples.
c@339 36 */
c@289 37 void process(bool inverse,
c@289 38 const double *realIn, const double *imagIn,
c@289 39 double *realOut, double *imagOut);
c@289 40
c@289 41 private:
c@355 42 class D;
c@355 43 D *m_d;
c@225 44 };
c@225 45
c@289 46 class FFTReal
c@289 47 {
c@289 48 public:
c@339 49 /**
c@339 50 * Construct an FFT object to carry out real-to-complex transforms
c@355 51 * of size nsamples. nsamples does not have to be a power of two,
c@355 52 * but it does have to be even. (A std::invalid_argument exception
c@355 53 * will be thrown if nsamples is odd.)
c@339 54 */
c@339 55 FFTReal(int nsamples);
c@289 56 ~FFTReal();
c@289 57
c@339 58 /**
c@339 59 * Carry out a forward real-to-complex transform of size nsamples,
c@339 60 * where nsamples is the value provided to the constructor above.
c@339 61 *
c@339 62 * realIn, realOut, and imagOut must point to (enough space for)
c@339 63 * nsamples values. For consistency with the FFT class above, and
c@339 64 * compatibility with existing code, the conjugate half of the
c@339 65 * output is returned even though it is redundant.
c@339 66 */
c@339 67 void forward(const double *realIn,
c@289 68 double *realOut, double *imagOut);
c@289 69
c@339 70 /**
c@339 71 * Carry out an inverse real transform (i.e. complex-to-real) of
c@339 72 * size nsamples, where nsamples is the value provided to the
c@339 73 * constructor above.
c@339 74 *
c@339 75 * realIn and imagIn should point to at least nsamples/2+1 values;
c@339 76 * if more are provided, only the first nsamples/2+1 values of
c@339 77 * each will be used (the conjugate half will always be deduced
c@339 78 * from the first nsamples/2+1 rather than being read from the
c@339 79 * input data). realOut should point to enough space to receive
c@339 80 * nsamples values.
c@339 81 *
c@339 82 * The inverse transform is scaled by 1/nsamples.
c@339 83 */
c@339 84 void inverse(const double *realIn, const double *imagIn,
c@339 85 double *realOut);
c@339 86
c@289 87 private:
c@355 88 class D;
c@355 89 D *m_d;
c@289 90 };
c@289 91
c@225 92 #endif