annotate cq/CQParameters.h @ 149:2705ca19245c

More docs
author Chris Cannam <c.cannam@qmul.ac.uk>
date Thu, 10 Jul 2014 15:27:09 +0100
parents 8996465e39fc
children 5b1a1bbd6e7f
rev   line source
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@149 51 /**
c@149 52 * Construct a set of parameters with the given input signal
c@149 53 * sample rate, frequency range, and number of bins per
c@149 54 * octave. The remaining parameters will take their usual
c@149 55 * defaults; if you want to change them, just assign the
c@149 56 * respective data members after construction.
c@149 57 */
c@127 58 CQParameters(double _sampleRate,
c@127 59 double _minFrequency,
c@127 60 double _maxFrequency,
c@127 61 int _binsPerOctave) :
c@127 62 sampleRate(_sampleRate),
c@127 63 minFrequency(_minFrequency),
c@127 64 maxFrequency(_maxFrequency),
c@127 65 binsPerOctave(_binsPerOctave),
c@127 66 q(1.0), // Q scaling factor
c@127 67 atomHopFactor(0.25), // hop size of shortest temporal atom
c@127 68 threshold(0.0005), // sparsity threshold for resulting kernel
c@127 69 window(SqrtBlackmanHarris) // window shape
c@127 70 { }
c@127 71
c@149 72 /**
c@149 73 * Sampling rate of input signal.
c@149 74 */
c@127 75 double sampleRate;
c@149 76
c@149 77 /**
c@149 78 * Minimum frequency desired to include in Constant-Q output. The
c@149 79 * actual minimum will normally be calculated as a round number of
c@149 80 * octaves below the maximum frequency, and may differ from this.
c@149 81 */
c@127 82 double minFrequency;
c@149 83
c@149 84 /**
c@149 85 * Maximum frequency to include in Constant-Q output.
c@149 86 */
c@127 87 double maxFrequency;
c@149 88
c@149 89 /**
c@149 90 * Number of output frequency bins per octave.
c@149 91 */
c@127 92 int binsPerOctave;
c@127 93
c@149 94 /**
c@149 95 * Spectral atom bandwidth scaling factor. q == 1 is optimal for
c@149 96 * reconstruction, q < 1 increases redundancy (smearing) in the
c@149 97 * frequency domain but improves time resolution.
c@149 98 */
c@127 99 double q;
c@149 100
c@149 101 /**
c@149 102 * Hop size between temporal atoms, where 1 == no overlap and
c@149 103 * smaller values indicate overlapping atoms.
c@149 104 */
c@127 105 double atomHopFactor;
c@149 106
c@149 107 /**
c@149 108 * Sparsity threshold for Constant-Q kernel: values with magnitude
c@149 109 * smaller than this are truncated to zero.
c@149 110 */
c@127 111 double threshold;
c@149 112
c@149 113 /**
c@149 114 * Window shape to use for the Constant-Q kernel atoms.
c@149 115 */
c@127 116 WindowType window;
c@127 117 };
c@127 118
c@127 119 #endif
c@127 120