annotate cq/ConstantQ.h @ 196:da283326bcd3 tip master

Update plugin versions in RDF
author Chris Cannam <cannam@all-day-breakfast.com>
date Fri, 28 Feb 2020 09:43:02 +0000
parents 705be3bb9472
children
rev   line source
c@116 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
c@116 2 /*
c@116 3 Constant-Q library
c@116 4 Copyright (c) 2013-2014 Queen Mary, University of London
c@116 5
c@116 6 Permission is hereby granted, free of charge, to any person
c@116 7 obtaining a copy of this software and associated documentation
c@116 8 files (the "Software"), to deal in the Software without
c@116 9 restriction, including without limitation the rights to use, copy,
c@116 10 modify, merge, publish, distribute, sublicense, and/or sell copies
c@116 11 of the Software, and to permit persons to whom the Software is
c@116 12 furnished to do so, subject to the following conditions:
c@116 13
c@116 14 The above copyright notice and this permission notice shall be
c@116 15 included in all copies or substantial portions of the Software.
c@116 16
c@116 17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
c@116 18 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
c@116 19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
c@116 20 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
c@116 21 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
c@116 22 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
c@116 23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
c@116 24
c@116 25 Except as contained in this notice, the names of the Centre for
c@116 26 Digital Music; Queen Mary, University of London; and Chris Cannam
c@116 27 shall not be used in advertising or otherwise to promote the sale,
c@116 28 use or other dealings in this Software without prior written
c@116 29 authorization.
c@116 30 */
c@116 31
c@116 32 #ifndef CONSTANTQ_H
c@116 33 #define CONSTANTQ_H
c@116 34
c@116 35 #include "CQBase.h"
c@127 36 #include "CQParameters.h"
c@116 37 #include "CQKernel.h"
c@116 38
c@116 39 class Resampler;
c@116 40 class FFTReal;
c@116 41
c@116 42 /**
c@116 43 * Calculate a complex sparse constant-Q representation from
c@147 44 * time-domain input. The input of each \ref process call is a single
c@147 45 * frame of time-domain samples; the output is a series of columns of
c@147 46 * varying height. See \ref process for details.
c@116 47 *
c@147 48 * For a real (magnitude-only) interpolated dense representation, see
c@116 49 * CQSpectrogram.
c@116 50 */
c@116 51 class ConstantQ : public CQBase
c@116 52 {
c@116 53 public:
c@147 54 /**
c@147 55 * Construct a complex Constant-Q transform object using the given
c@147 56 * transform parameters.
c@147 57 */
c@127 58 ConstantQ(CQParameters params);
c@116 59 virtual ~ConstantQ();
c@116 60
c@147 61 // CQBase methods, see CQBase.h for documentation
c@147 62 virtual bool isValid() const { return m_kernel && m_kernel->isValid(); }
c@116 63 virtual double getSampleRate() const { return m_sampleRate; }
c@116 64 virtual int getBinsPerOctave() const { return m_binsPerOctave; }
c@116 65 virtual int getOctaves() const { return m_octaves; }
c@116 66 virtual int getTotalBins() const { return m_octaves * m_binsPerOctave; }
c@116 67 virtual int getColumnHop() const { return m_p.fftHop / m_p.atomsPerFrame; }
c@116 68 virtual int getLatency() const { return m_outputLatency; }
c@116 69 virtual double getMaxFrequency() const { return m_p.maxFrequency; }
c@116 70 virtual double getMinFrequency() const;
c@145 71 virtual double getBinFrequency(double bin) const; // bin may be nonintegral
c@116 72
c@116 73 /**
c@116 74 * Given a series of time-domain samples, return a series of
c@116 75 * constant-Q columns. Any samples left over (that did not fit
c@116 76 * into a constant-Q processing block) are saved for the next call
c@147 77 * to process or getRemainingBlocks.
c@116 78 *
c@147 79 * The input is assumed to be a single frame of time-domain sample
c@147 80 * values, such that consecutive calls to \ref process receive
c@147 81 * contiguous frames from the source signal. Each frame may be of
c@147 82 * any length in samples.
c@116 83 *
c@147 84 * Each output column contains a series of constant-Q bin values
c@147 85 * ordered from highest to lowest frequency.
c@147 86 *
c@147 87 * Output columns are of varying height: each will contain at
c@147 88 * least getBinsPerOctave() values, because the highest-frequency
c@147 89 * octave is always present, but a second octave (if requested)
c@147 90 * will appear only in alternate columns, a third octave only in
c@147 91 * every fourth column, and so on.
c@116 92 *
c@116 93 * If you need a format in which all columns are of equal height
c@147 94 * and every bin contains a value, use \ref CQSpectrogram instead
c@147 95 * of ConstantQ.
c@116 96 */
c@116 97 ComplexBlock process(const RealSequence &);
c@116 98
c@116 99 /**
c@116 100 * Return the remaining constant-Q columns following the end of
c@116 101 * processing. Any buffered input is padded so as to ensure that
c@116 102 * all input provided to process() will have been returned.
c@116 103 */
c@116 104 ComplexBlock getRemainingOutput();
c@116 105
c@116 106 private:
c@127 107 const CQParameters m_inparams;
c@127 108 const double m_sampleRate;
c@127 109 const double m_maxFrequency;
c@127 110 const double m_minFrequency;
c@127 111 const int m_binsPerOctave;
c@127 112
c@116 113 int m_octaves;
c@116 114 CQKernel *m_kernel;
c@116 115 CQKernel::Properties m_p;
c@116 116 int m_bigBlockSize;
c@116 117
c@116 118 std::vector<Resampler *> m_decimators;
c@116 119 std::vector<RealSequence> m_buffers;
c@116 120
c@116 121 int m_outputLatency;
c@116 122
c@116 123 FFTReal *m_fft;
c@116 124
c@116 125 void initialise();
c@116 126 ComplexBlock processOctaveBlock(int octave);
cannam@194 127
cannam@194 128 // Not provided
cannam@194 129 ConstantQ(const ConstantQ &);
cannam@194 130 ConstantQ &operator=(const ConstantQ &);
c@116 131 };
c@116 132
c@116 133 #endif
c@116 134