c@415: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ c@415: c@415: /* c@415: QM DSP Library c@415: c@415: Centre for Digital Music, Queen Mary, University of London. c@415: This file by Chris Cannam. c@415: c@415: This program is free software; you can redistribute it and/or c@415: modify it under the terms of the GNU General Public License as c@415: published by the Free Software Foundation; either version 2 of the c@415: License, or (at your option) any later version. See the file c@415: COPYING included with this distribution for more information. c@415: */ c@415: cannam@489: #ifndef QM_DSP_DCT_H cannam@489: #define QM_DSP_DCT_H c@415: c@415: #include "FFT.h" c@415: c@415: #include c@415: c@415: class DCT c@415: { c@415: public: c@415: /** c@415: * Construct a DCT object to calculate the Discrete Cosine c@415: * Transform given input of size n samples. The transform is c@415: * implemented using an FFT of size 4n, for simplicity. c@415: */ c@415: DCT(int n); c@415: c@415: ~DCT(); c@415: c@415: /** c@415: * Carry out a type-II DCT of size n, where n is the value c@415: * provided to the constructor above. c@415: * c@415: * The in and out pointers must point to (enough space for) n c@415: * values. c@415: */ c@415: void forward(const double *in, double *out); c@415: c@415: /** c@415: * Carry out a type-II unitary DCT of size n, where n is the value c@415: * provided to the constructor above. This is a scaled version of c@415: * the type-II DCT corresponding to a transform with an orthogonal c@415: * matrix. This is the transform implemented by the dct() function c@415: * in MATLAB. c@415: * c@415: * The in and out pointers must point to (enough space for) n c@415: * values. c@415: */ c@415: void forwardUnitary(const double *in, double *out); c@415: c@415: /** c@415: * Carry out a type-III (inverse) DCT of size n, where n is the c@415: * value provided to the constructor above. c@415: * c@415: * The in and out pointers must point to (enough space for) n c@415: * values. c@415: */ c@415: void inverse(const double *in, double *out); c@415: c@415: /** c@415: * Carry out a type-III (inverse) unitary DCT of size n, where n c@415: * is the value provided to the constructor above. This is the c@415: * inverse of forwardUnitary(). c@415: * c@415: * The in and out pointers must point to (enough space for) n c@415: * values. c@415: */ c@415: void inverseUnitary(const double *in, double *out); c@415: c@415: private: c@415: int m_n; c@415: double m_scale; c@415: std::vector m_scaled; c@415: std::vector m_time2; c@415: std::vector m_freq2r; c@415: std::vector m_freq2i; c@415: FFTReal m_fft; c@415: }; c@415: c@415: #endif