annotate dsp/transforms/FFT.h @ 357:650bbacf8288

Add forwardMagnitude
author Chris Cannam <c.cannam@qmul.ac.uk>
date Tue, 15 Oct 2013 18:26:38 +0100
parents 3c7338aff6a8
children 857ca50ca25f
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@357 52 * but it does have to be even. (Use the complex-complex FFT above
c@357 53 * if you need an odd FFT size. This constructor will throw
c@357 54 * std::invalid_argument if nsamples is odd.)
c@339 55 */
c@339 56 FFTReal(int nsamples);
c@289 57 ~FFTReal();
c@289 58
c@339 59 /**
c@339 60 * Carry out a forward real-to-complex transform of size nsamples,
c@339 61 * where nsamples is the value provided to the constructor above.
c@339 62 *
c@339 63 * realIn, realOut, and imagOut must point to (enough space for)
c@339 64 * nsamples values. For consistency with the FFT class above, and
c@339 65 * compatibility with existing code, the conjugate half of the
c@339 66 * output is returned even though it is redundant.
c@339 67 */
c@339 68 void forward(const double *realIn,
c@289 69 double *realOut, double *imagOut);
c@289 70
c@339 71 /**
c@357 72 * Carry out a forward real-to-complex transform of size nsamples,
c@357 73 * where nsamples is the value provided to the constructor
c@357 74 * above. Return only the magnitudes of the complex output values.
c@357 75 *
c@357 76 * realIn and magOut must point to (enough space for) nsamples
c@357 77 * values. For consistency with the FFT class above, and
c@357 78 * compatibility with existing code, the conjugate half of the
c@357 79 * output is returned even though it is redundant.
c@357 80 */
c@357 81 void forwardMagnitude(const double *realIn, double *magOut);
c@357 82
c@357 83 /**
c@339 84 * Carry out an inverse real transform (i.e. complex-to-real) of
c@339 85 * size nsamples, where nsamples is the value provided to the
c@339 86 * constructor above.
c@339 87 *
c@339 88 * realIn and imagIn should point to at least nsamples/2+1 values;
c@339 89 * if more are provided, only the first nsamples/2+1 values of
c@339 90 * each will be used (the conjugate half will always be deduced
c@339 91 * from the first nsamples/2+1 rather than being read from the
c@339 92 * input data). realOut should point to enough space to receive
c@339 93 * nsamples values.
c@339 94 *
c@339 95 * The inverse transform is scaled by 1/nsamples.
c@339 96 */
c@339 97 void inverse(const double *realIn, const double *imagIn,
c@339 98 double *realOut);
c@339 99
c@289 100 private:
c@355 101 class D;
c@355 102 D *m_d;
c@289 103 };
c@289 104
c@225 105 #endif