Mercurial > hg > silvet
comparison constant-q-cpp/cq/CQParameters.h @ 366:5d0a2ebb4d17
Bring dependent libraries in to repo
author | Chris Cannam |
---|---|
date | Fri, 24 Jun 2016 14:47:45 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
365:112766f4c34b | 366:5d0a2ebb4d17 |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 /* | |
3 Constant-Q library | |
4 Copyright (c) 2013-2014 Queen Mary, University of London | |
5 | |
6 Permission is hereby granted, free of charge, to any person | |
7 obtaining a copy of this software and associated documentation | |
8 files (the "Software"), to deal in the Software without | |
9 restriction, including without limitation the rights to use, copy, | |
10 modify, merge, publish, distribute, sublicense, and/or sell copies | |
11 of the Software, and to permit persons to whom the Software is | |
12 furnished to do so, subject to the following conditions: | |
13 | |
14 The above copyright notice and this permission notice shall be | |
15 included in all copies or substantial portions of the Software. | |
16 | |
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
18 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
20 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | |
21 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | |
22 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |
23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
24 | |
25 Except as contained in this notice, the names of the Centre for | |
26 Digital Music; Queen Mary, University of London; and Chris Cannam | |
27 shall not be used in advertising or otherwise to promote the sale, | |
28 use or other dealings in this Software without prior written | |
29 authorization. | |
30 */ | |
31 | |
32 #ifndef CQ_PARAMETERS_H | |
33 #define CQ_PARAMETERS_H | |
34 | |
35 /** | |
36 * Common parameters for constructing Constant-Q implementation | |
37 * objects (both forward and inverse transforms). | |
38 */ | |
39 class CQParameters | |
40 { | |
41 public: | |
42 enum WindowType { | |
43 SqrtBlackmanHarris, | |
44 SqrtBlackman, | |
45 SqrtHann, | |
46 BlackmanHarris, | |
47 Blackman, | |
48 Hann, | |
49 }; | |
50 | |
51 enum DecimatorType { | |
52 BetterDecimator, | |
53 FasterDecimator | |
54 }; | |
55 | |
56 /** | |
57 * Construct a set of parameters with the given input signal | |
58 * sample rate, frequency range, and number of bins per | |
59 * octave. The remaining parameters will take their usual | |
60 * defaults; if you want to change them, just assign the | |
61 * respective data members after construction. | |
62 */ | |
63 CQParameters(double _sampleRate, | |
64 double _minFrequency, | |
65 double _maxFrequency, | |
66 int _binsPerOctave) : | |
67 sampleRate(_sampleRate), | |
68 minFrequency(_minFrequency), | |
69 maxFrequency(_maxFrequency), | |
70 binsPerOctave(_binsPerOctave), | |
71 q(1.0), // Q scaling factor | |
72 atomHopFactor(0.25), // hop size of shortest temporal atom | |
73 threshold(0.0005), // sparsity threshold for resulting kernel | |
74 window(SqrtBlackmanHarris), // window shape | |
75 decimator(BetterDecimator) // decimator quality setting | |
76 { } | |
77 | |
78 /** | |
79 * Sampling rate of input signal. | |
80 */ | |
81 double sampleRate; | |
82 | |
83 /** | |
84 * Minimum frequency desired to include in Constant-Q output. The | |
85 * actual minimum will normally be calculated as a round number of | |
86 * octaves below the maximum frequency, and may differ from this. | |
87 */ | |
88 double minFrequency; | |
89 | |
90 /** | |
91 * Maximum frequency to include in Constant-Q output. | |
92 */ | |
93 double maxFrequency; | |
94 | |
95 /** | |
96 * Number of output frequency bins per octave. | |
97 */ | |
98 int binsPerOctave; | |
99 | |
100 /** | |
101 * Spectral atom bandwidth scaling factor. q == 1 is optimal for | |
102 * reconstruction, q < 1 increases redundancy (smearing) in the | |
103 * frequency domain but improves time resolution. | |
104 */ | |
105 double q; | |
106 | |
107 /** | |
108 * Hop size between temporal atoms, where 1 == no overlap and | |
109 * smaller values indicate overlapping atoms. | |
110 */ | |
111 double atomHopFactor; | |
112 | |
113 /** | |
114 * Sparsity threshold for Constant-Q kernel: values with magnitude | |
115 * smaller than this are truncated to zero. | |
116 */ | |
117 double threshold; | |
118 | |
119 /** | |
120 * Window shape to use for the Constant-Q kernel atoms. | |
121 */ | |
122 WindowType window; | |
123 | |
124 /** | |
125 * Quality setting for the sample rate decimator. | |
126 */ | |
127 DecimatorType decimator; | |
128 }; | |
129 | |
130 #endif | |
131 |