Mercurial > hg > constant-q-cpp
comparison src/test.cpp @ 116:6deec2a51d13
Moving to standalone library layout
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Thu, 15 May 2014 12:04:00 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
115:93be4aa255e5 | 116:6deec2a51d13 |
---|---|
1 /* | |
2 Constant-Q library | |
3 Copyright (c) 2013-2014 Queen Mary, University of London | |
4 | |
5 Permission is hereby granted, free of charge, to any person | |
6 obtaining a copy of this software and associated documentation | |
7 files (the "Software"), to deal in the Software without | |
8 restriction, including without limitation the rights to use, copy, | |
9 modify, merge, publish, distribute, sublicense, and/or sell copies | |
10 of the Software, and to permit persons to whom the Software is | |
11 furnished to do so, subject to the following conditions: | |
12 | |
13 The above copyright notice and this permission notice shall be | |
14 included in all copies or substantial portions of the Software. | |
15 | |
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
17 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
18 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
19 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | |
20 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | |
21 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |
22 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
23 | |
24 Except as contained in this notice, the names of the Centre for | |
25 Digital Music; Queen Mary, University of London; and Chris Cannam | |
26 shall not be used in advertising or otherwise to promote the sale, | |
27 use or other dealings in this Software without prior written | |
28 authorization. | |
29 */ | |
30 | |
31 #include "CQSpectrogram.h" | |
32 | |
33 #include <iostream> | |
34 #include <vector> | |
35 | |
36 using std::vector; | |
37 using std::cerr; | |
38 using std::cout; | |
39 using std::endl; | |
40 | |
41 #include <cstdio> | |
42 | |
43 int main(int argc, char **argv) | |
44 { | |
45 vector<double> in; | |
46 | |
47 for (int i = 0; i < 64; ++i) { | |
48 // if (i == 0) in.push_back(1); | |
49 // else in.push_back(0); | |
50 in.push_back(sin(i * M_PI / 2.0)); | |
51 } | |
52 | |
53 CQSpectrogram k(8, 1, 4, 4, CQSpectrogram::InterpolateZeros); | |
54 | |
55 vector<vector<double> > out = k.process(in); | |
56 vector<vector<double> > rest = k.getRemainingOutput(); | |
57 | |
58 out.insert(out.end(), rest.begin(), rest.end()); | |
59 | |
60 cerr << "got " << out.size() << " back (" << out[0].size() << " in each?)" << endl; | |
61 | |
62 for (int b = 0; b < (int)out.size() / 8; ++b) { | |
63 printf("\nColumns %d to %d:\n\n", b * 8, b * 8 + 7); | |
64 for (int j = int(out[0].size()) - 1; j >= 0; --j) { | |
65 for (int i = 0; i < 8; ++i) { | |
66 if (i + b * 8 < (int)out.size()) { | |
67 double v = out[i + b * 8][j]; | |
68 if (v < 0.0001) printf(" 0 "); | |
69 else printf(" %.4f ", out[i + b * 8][j]); | |
70 } | |
71 } | |
72 printf("\n"); | |
73 } | |
74 } | |
75 } | |
76 |