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