c@127: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ c@127: /* c@127: Constant-Q library c@127: Copyright (c) 2013-2014 Queen Mary, University of London c@127: c@127: Permission is hereby granted, free of charge, to any person c@127: obtaining a copy of this software and associated documentation c@127: files (the "Software"), to deal in the Software without c@127: restriction, including without limitation the rights to use, copy, c@127: modify, merge, publish, distribute, sublicense, and/or sell copies c@127: of the Software, and to permit persons to whom the Software is c@127: furnished to do so, subject to the following conditions: c@127: c@127: The above copyright notice and this permission notice shall be c@127: included in all copies or substantial portions of the Software. c@127: c@127: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, c@127: EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF c@127: MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND c@127: NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY c@127: CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF c@127: CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION c@127: WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. c@127: c@127: Except as contained in this notice, the names of the Centre for c@127: Digital Music; Queen Mary, University of London; and Chris Cannam c@127: shall not be used in advertising or otherwise to promote the sale, c@127: use or other dealings in this Software without prior written c@127: authorization. c@127: */ c@127: c@127: #ifndef CQ_PARAMETERS_H c@127: #define CQ_PARAMETERS_H c@127: c@149: /** c@149: * Common parameters for constructing Constant-Q implementation c@149: * objects (both forward and inverse transforms). c@149: */ c@127: class CQParameters c@127: { c@127: public: c@127: enum WindowType { c@127: SqrtBlackmanHarris, c@127: SqrtBlackman, c@127: SqrtHann, c@127: BlackmanHarris, c@127: Blackman, c@127: Hann, c@127: }; c@127: c@176: enum DecimatorType { c@176: BetterDecimator, c@176: FasterDecimator c@176: }; c@176: c@149: /** c@149: * Construct a set of parameters with the given input signal c@149: * sample rate, frequency range, and number of bins per c@149: * octave. The remaining parameters will take their usual c@149: * defaults; if you want to change them, just assign the c@149: * respective data members after construction. c@149: */ c@127: CQParameters(double _sampleRate, c@127: double _minFrequency, c@127: double _maxFrequency, c@127: int _binsPerOctave) : c@127: sampleRate(_sampleRate), c@127: minFrequency(_minFrequency), c@127: maxFrequency(_maxFrequency), c@127: binsPerOctave(_binsPerOctave), c@176: q(1.0), // Q scaling factor c@176: atomHopFactor(0.25), // hop size of shortest temporal atom c@176: threshold(0.0005), // sparsity threshold for resulting kernel c@176: window(SqrtBlackmanHarris), // window shape c@176: decimator(BetterDecimator) // decimator quality setting c@127: { } c@127: c@149: /** c@149: * Sampling rate of input signal. c@149: */ c@127: double sampleRate; c@149: c@149: /** c@149: * Minimum frequency desired to include in Constant-Q output. The c@149: * actual minimum will normally be calculated as a round number of c@149: * octaves below the maximum frequency, and may differ from this. c@149: */ c@127: double minFrequency; c@149: c@149: /** c@149: * Maximum frequency to include in Constant-Q output. c@149: */ c@127: double maxFrequency; c@149: c@149: /** c@149: * Number of output frequency bins per octave. c@149: */ c@127: int binsPerOctave; c@127: c@149: /** c@149: * Spectral atom bandwidth scaling factor. q == 1 is optimal for c@149: * reconstruction, q < 1 increases redundancy (smearing) in the c@149: * frequency domain but improves time resolution. c@149: */ c@127: double q; c@149: c@149: /** c@149: * Hop size between temporal atoms, where 1 == no overlap and c@149: * smaller values indicate overlapping atoms. c@149: */ c@127: double atomHopFactor; c@149: c@149: /** c@149: * Sparsity threshold for Constant-Q kernel: values with magnitude c@149: * smaller than this are truncated to zero. c@149: */ c@127: double threshold; c@149: c@149: /** c@149: * Window shape to use for the Constant-Q kernel atoms. c@149: */ c@127: WindowType window; c@176: c@176: /** c@176: * Quality setting for the sample rate decimator. c@176: */ c@176: DecimatorType decimator; c@127: }; c@127: c@127: #endif c@127: