annotate cq/CQSpectrogram.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 CQSPECTROGRAM_H
c@116 33 #define CQSPECTROGRAM_H
c@116 34
c@116 35 #include "ConstantQ.h"
c@116 36
c@147 37 /**
c@147 38 * Calculate a dense constant-Q magnitude spectrogram from time-domain
c@147 39 * input. The input of each \ref process call is a single frame of
c@147 40 * time-domain samples; the output is a series of fixed-height
c@147 41 * columns. See \ref process for details.
c@147 42 *
c@147 43 * If you need the full complex-valued constant-Q output, you must use
c@147 44 * the \ref ConstantQ class instead.
c@147 45 */
c@116 46 class CQSpectrogram : public CQBase
c@116 47 {
c@116 48 public:
c@116 49 enum Interpolation {
c@147 50 /// leave empty cells as zero
c@147 51 InterpolateZeros,
c@147 52 /// replace empty cells with a repeat of the previous column
c@147 53 InterpolateHold,
c@147 54 /// perform linear interpolation between consecutive time cells
c@147 55 InterpolateLinear,
c@116 56 };
c@116 57
c@147 58 /**
c@147 59 * Construct a Constant-Q magnitude spectrogram object using the
c@147 60 * given transform parameters.
c@147 61 */
c@127 62 CQSpectrogram(CQParameters params, Interpolation interpolation);
c@116 63 virtual ~CQSpectrogram();
c@116 64
c@147 65 // CQBase methods, see CQBase.h for documentation
c@147 66 virtual bool isValid() const { return m_cq.isValid(); }
c@116 67 virtual double getSampleRate() const { return m_cq.getSampleRate(); }
c@116 68 virtual int getBinsPerOctave() const { return m_cq.getBinsPerOctave(); }
c@116 69 virtual int getOctaves() const { return m_cq.getOctaves(); }
c@116 70 virtual int getTotalBins() const { return m_cq.getTotalBins(); }
c@116 71 virtual int getColumnHop() const { return m_cq.getColumnHop(); }
c@116 72 virtual int getLatency() const { return m_cq.getLatency(); }
c@116 73 virtual double getMaxFrequency() const { return m_cq.getMaxFrequency(); }
c@116 74 virtual double getMinFrequency() const { return m_cq.getMinFrequency(); }
c@145 75 virtual double getBinFrequency(double bin) const { return m_cq.getBinFrequency(bin); }
c@116 76
c@136 77 /**
c@136 78 * Given a series of time-domain samples, return a series of
c@136 79 * constant-Q magnitude columns. Any samples left over (that did
c@136 80 * not fit into a constant-Q processing block) are saved for the
c@136 81 * next call to process or getRemainingBlocks.
c@136 82 *
c@147 83 * The input is assumed to be a single frame of time-domain sample
c@147 84 * values, such that consecutive calls to \ref process receive
c@147 85 * contiguous frames from the source signal. Each frame may be of
c@147 86 * any length in samples.
c@147 87 *
c@147 88 * Each output column contains a series of constant-Q bin value
c@136 89 * magnitudes, ordered from highest to lowest frequency.
c@136 90 *
c@136 91 * The columns are all of the same height, but they might not all
c@136 92 * be populated, depending on the interpolation mode: in
c@136 93 * InterpolateZeros mode, the lower octaves (which are spaced more
c@136 94 * widely in the raw constant-Q than the highest octave) will
c@136 95 * contain zeros for the undefined values, but in the other
c@136 96 * interpolation modes every cell will be filled.
c@136 97 *
c@136 98 * To obtain raw, complex constant-Q bin values, use the ConstantQ
c@136 99 * class.
c@136 100 */
c@116 101 RealBlock process(const RealSequence &);
c@136 102
c@136 103 /**
c@136 104 * Return the remaining constant-Q magnitude columns following the
c@136 105 * end of processing. Any buffered input is padded so as to ensure
c@136 106 * that all input provided to process() will have been returned.
c@136 107 */
c@116 108 RealBlock getRemainingOutput();
c@116 109
c@116 110 private:
c@116 111 ConstantQ m_cq;
c@116 112 Interpolation m_interpolation;
c@116 113
c@116 114 RealBlock m_buffer;
c@116 115 RealBlock postProcess(const ComplexBlock &, bool insist);
c@116 116 RealBlock fetchHold(bool insist);
c@116 117 RealBlock fetchLinear(bool insist);
c@116 118 RealBlock linearInterpolated(const RealBlock &, int, int);
c@116 119 RealColumn m_prevColumn;
cannam@194 120
cannam@194 121 // Not provided (because ConstantQ isn't copyable)
cannam@194 122 CQSpectrogram(const CQSpectrogram &);
cannam@194 123 CQSpectrogram &operator=(const CQSpectrogram &);
c@116 124 };
c@116 125
c@116 126 #endif