annotate dsp/transforms/FFT.h @ 339:9c8ee77db9de

Tidy real-to-complex FFT -- forward and inverse have different arguments, so make them separate functions; document
author Chris Cannam <c.cannam@qmul.ac.uk>
date Wed, 02 Oct 2013 15:04:38 +0100
parents befe5aa6b450
children 6ec45e85ed81
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@339 17 * transforms of size nsamples. nsamples must be a power of two in
c@339 18 * this implementation.
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@339 42 int m_n;
c@225 43 };
c@225 44
c@289 45 class FFTReal
c@289 46 {
c@289 47 public:
c@339 48 /**
c@339 49 * Construct an FFT object to carry out real-to-complex transforms
c@339 50 * of size nsamples. nsamples must be a power of two in this
c@339 51 * implementation.
c@339 52 */
c@339 53 FFTReal(int nsamples);
c@289 54 ~FFTReal();
c@289 55
c@339 56 /**
c@339 57 * Carry out a forward real-to-complex transform of size nsamples,
c@339 58 * where nsamples is the value provided to the constructor above.
c@339 59 *
c@339 60 * realIn, realOut, and imagOut must point to (enough space for)
c@339 61 * nsamples values. For consistency with the FFT class above, and
c@339 62 * compatibility with existing code, the conjugate half of the
c@339 63 * output is returned even though it is redundant.
c@339 64 */
c@339 65 void forward(const double *realIn,
c@289 66 double *realOut, double *imagOut);
c@289 67
c@339 68 /**
c@339 69 * Carry out an inverse real transform (i.e. complex-to-real) of
c@339 70 * size nsamples, where nsamples is the value provided to the
c@339 71 * constructor above.
c@339 72 *
c@339 73 * realIn and imagIn should point to at least nsamples/2+1 values;
c@339 74 * if more are provided, only the first nsamples/2+1 values of
c@339 75 * each will be used (the conjugate half will always be deduced
c@339 76 * from the first nsamples/2+1 rather than being read from the
c@339 77 * input data). realOut should point to enough space to receive
c@339 78 * nsamples values.
c@339 79 *
c@339 80 * The inverse transform is scaled by 1/nsamples.
c@339 81 */
c@339 82 void inverse(const double *realIn, const double *imagIn,
c@339 83 double *realOut);
c@339 84
c@289 85 private:
c@339 86 int m_n;
c@339 87 FFT *m_fft;
c@339 88 double *m_r;
c@339 89 double *m_i;
c@339 90 double *m_discard;
c@289 91 };
c@289 92
c@225 93 #endif