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