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