annotate dsp/transforms/DCT.h @ 436:2c11b8585dc2

Rename FFT back again, now we have our own project
author Chris Cannam <c.cannam@qmul.ac.uk>
date Mon, 05 Feb 2018 17:40:13 +0000
parents 4ae4229a074a
children 701233f8ed41
rev   line source
c@415 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
c@415 2
c@415 3 /*
c@415 4 QM DSP Library
c@415 5
c@415 6 Centre for Digital Music, Queen Mary, University of London.
c@415 7 This file by Chris Cannam.
c@415 8
c@415 9 This program is free software; you can redistribute it and/or
c@415 10 modify it under the terms of the GNU General Public License as
c@415 11 published by the Free Software Foundation; either version 2 of the
c@415 12 License, or (at your option) any later version. See the file
c@415 13 COPYING included with this distribution for more information.
c@415 14 */
c@415 15
c@415 16 #ifndef DCT_H
c@415 17 #define DCT_H
c@415 18
c@415 19 #include "FFT.h"
c@415 20
c@415 21 #include <vector>
c@415 22
c@415 23 class DCT
c@415 24 {
c@415 25 public:
c@415 26 /**
c@415 27 * Construct a DCT object to calculate the Discrete Cosine
c@415 28 * Transform given input of size n samples. The transform is
c@415 29 * implemented using an FFT of size 4n, for simplicity.
c@415 30 */
c@415 31 DCT(int n);
c@415 32
c@415 33 ~DCT();
c@415 34
c@415 35 /**
c@415 36 * Carry out a type-II DCT of size n, where n is the value
c@415 37 * provided to the constructor above.
c@415 38 *
c@415 39 * The in and out pointers must point to (enough space for) n
c@415 40 * values.
c@415 41 */
c@415 42 void forward(const double *in, double *out);
c@415 43
c@415 44 /**
c@415 45 * Carry out a type-II unitary DCT of size n, where n is the value
c@415 46 * provided to the constructor above. This is a scaled version of
c@415 47 * the type-II DCT corresponding to a transform with an orthogonal
c@415 48 * matrix. This is the transform implemented by the dct() function
c@415 49 * in MATLAB.
c@415 50 *
c@415 51 * The in and out pointers must point to (enough space for) n
c@415 52 * values.
c@415 53 */
c@415 54 void forwardUnitary(const double *in, double *out);
c@415 55
c@415 56 /**
c@415 57 * Carry out a type-III (inverse) DCT of size n, where n is the
c@415 58 * value provided to the constructor above.
c@415 59 *
c@415 60 * The in and out pointers must point to (enough space for) n
c@415 61 * values.
c@415 62 */
c@415 63 void inverse(const double *in, double *out);
c@415 64
c@415 65 /**
c@415 66 * Carry out a type-III (inverse) unitary DCT of size n, where n
c@415 67 * is the value provided to the constructor above. This is the
c@415 68 * inverse of forwardUnitary().
c@415 69 *
c@415 70 * The in and out pointers must point to (enough space for) n
c@415 71 * values.
c@415 72 */
c@415 73 void inverseUnitary(const double *in, double *out);
c@415 74
c@415 75 private:
c@415 76 int m_n;
c@415 77 double m_scale;
c@415 78 std::vector<double> m_scaled;
c@415 79 std::vector<double> m_time2;
c@415 80 std::vector<double> m_freq2r;
c@415 81 std::vector<double> m_freq2i;
c@415 82 FFTReal m_fft;
c@415 83 };
c@415 84
c@415 85 #endif