annotate dsp/transforms/FFT.h @ 209:ccd2019190bf msvc

Some MSVC fixes, including (temporarily, probably) renaming the FFT source file to avoid getting it mixed up with the Vamp SDK one in our object dir
author Chris Cannam
date Thu, 01 Feb 2018 16:34:08 +0000
parents 857ca50ca25f
children 701233f8ed41
rev   line source
cannam@0 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
cannam@0 2
cannam@0 3 /*
cannam@0 4 QM DSP Library
cannam@0 5
cannam@0 6 Centre for Digital Music, Queen Mary, University of London.
Chris@191 7
Chris@191 8 This program is free software; you can redistribute it and/or
Chris@191 9 modify it under the terms of the GNU General Public License as
Chris@191 10 published by the Free Software Foundation; either version 2 of the
Chris@191 11 License, or (at your option) any later version. See the file
Chris@191 12 COPYING included with this distribution for more information.
cannam@0 13 */
cannam@0 14
cannam@0 15 #ifndef FFT_H
cannam@0 16 #define FFT_H
cannam@0 17
cannam@0 18 class FFT
cannam@0 19 {
cannam@0 20 public:
Chris@114 21 /**
Chris@114 22 * Construct an FFT object to carry out complex-to-complex
Chris@129 23 * transforms of size nsamples. nsamples does not have to be a
Chris@129 24 * power of two.
Chris@114 25 */
Chris@114 26 FFT(int nsamples);
cannam@64 27 ~FFT();
cannam@0 28
Chris@114 29 /**
Chris@114 30 * Carry out a forward or inverse transform (depending on the
Chris@114 31 * value of inverse) of size nsamples, where nsamples is the value
Chris@114 32 * provided to the constructor above.
Chris@114 33 *
Chris@114 34 * realIn and (where present) imagIn should contain nsamples each,
Chris@114 35 * and realOut and imagOut should point to enough space to receive
Chris@114 36 * nsamples each.
Chris@114 37 *
Chris@114 38 * imagIn may be NULL if the signal is real, but the other
Chris@114 39 * pointers must be valid.
Chris@114 40 *
Chris@114 41 * The inverse transform is scaled by 1/nsamples.
Chris@114 42 */
cannam@64 43 void process(bool inverse,
cannam@64 44 const double *realIn, const double *imagIn,
cannam@64 45 double *realOut, double *imagOut);
cannam@64 46
cannam@64 47 private:
Chris@129 48 class D;
Chris@129 49 D *m_d;
cannam@0 50 };
cannam@0 51
cannam@64 52 class FFTReal
cannam@64 53 {
cannam@64 54 public:
Chris@114 55 /**
Chris@114 56 * Construct an FFT object to carry out real-to-complex transforms
Chris@129 57 * of size nsamples. nsamples does not have to be a power of two,
Chris@131 58 * but it does have to be even. (Use the complex-complex FFT above
Chris@131 59 * if you need an odd FFT size. This constructor will throw
Chris@131 60 * std::invalid_argument if nsamples is odd.)
Chris@114 61 */
Chris@114 62 FFTReal(int nsamples);
cannam@64 63 ~FFTReal();
cannam@64 64
Chris@114 65 /**
Chris@114 66 * Carry out a forward real-to-complex transform of size nsamples,
Chris@114 67 * where nsamples is the value provided to the constructor above.
Chris@114 68 *
Chris@114 69 * realIn, realOut, and imagOut must point to (enough space for)
Chris@114 70 * nsamples values. For consistency with the FFT class above, and
Chris@114 71 * compatibility with existing code, the conjugate half of the
Chris@114 72 * output is returned even though it is redundant.
Chris@114 73 */
Chris@114 74 void forward(const double *realIn,
cannam@64 75 double *realOut, double *imagOut);
cannam@64 76
Chris@114 77 /**
Chris@131 78 * Carry out a forward real-to-complex transform of size nsamples,
Chris@131 79 * where nsamples is the value provided to the constructor
Chris@131 80 * above. Return only the magnitudes of the complex output values.
Chris@131 81 *
Chris@131 82 * realIn and magOut must point to (enough space for) nsamples
Chris@131 83 * values. For consistency with the FFT class above, and
Chris@131 84 * compatibility with existing code, the conjugate half of the
Chris@131 85 * output is returned even though it is redundant.
Chris@131 86 */
Chris@131 87 void forwardMagnitude(const double *realIn, double *magOut);
Chris@131 88
Chris@131 89 /**
Chris@114 90 * Carry out an inverse real transform (i.e. complex-to-real) of
Chris@114 91 * size nsamples, where nsamples is the value provided to the
Chris@114 92 * constructor above.
Chris@114 93 *
Chris@114 94 * realIn and imagIn should point to at least nsamples/2+1 values;
Chris@114 95 * if more are provided, only the first nsamples/2+1 values of
Chris@114 96 * each will be used (the conjugate half will always be deduced
Chris@114 97 * from the first nsamples/2+1 rather than being read from the
Chris@114 98 * input data). realOut should point to enough space to receive
Chris@114 99 * nsamples values.
Chris@114 100 *
Chris@114 101 * The inverse transform is scaled by 1/nsamples.
Chris@114 102 */
Chris@114 103 void inverse(const double *realIn, const double *imagIn,
Chris@114 104 double *realOut);
Chris@114 105
cannam@64 106 private:
Chris@129 107 class D;
Chris@129 108 D *m_d;
cannam@64 109 };
cannam@64 110
cannam@0 111 #endif