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