annotate constant-q-cpp/cq/CQBase.h @ 372:af71cbdab621 tip

Update bqvec code
author Chris Cannam
date Tue, 19 Nov 2019 10:13:32 +0000
parents 5d0a2ebb4d17
children
rev   line source
Chris@366 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@366 2 /*
Chris@366 3 Constant-Q library
Chris@366 4 Copyright (c) 2013-2014 Queen Mary, University of London
Chris@366 5
Chris@366 6 Permission is hereby granted, free of charge, to any person
Chris@366 7 obtaining a copy of this software and associated documentation
Chris@366 8 files (the "Software"), to deal in the Software without
Chris@366 9 restriction, including without limitation the rights to use, copy,
Chris@366 10 modify, merge, publish, distribute, sublicense, and/or sell copies
Chris@366 11 of the Software, and to permit persons to whom the Software is
Chris@366 12 furnished to do so, subject to the following conditions:
Chris@366 13
Chris@366 14 The above copyright notice and this permission notice shall be
Chris@366 15 included in all copies or substantial portions of the Software.
Chris@366 16
Chris@366 17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
Chris@366 18 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Chris@366 19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Chris@366 20 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
Chris@366 21 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
Chris@366 22 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
Chris@366 23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Chris@366 24
Chris@366 25 Except as contained in this notice, the names of the Centre for
Chris@366 26 Digital Music; Queen Mary, University of London; and Chris Cannam
Chris@366 27 shall not be used in advertising or otherwise to promote the sale,
Chris@366 28 use or other dealings in this Software without prior written
Chris@366 29 authorization.
Chris@366 30 */
Chris@366 31
Chris@366 32 #ifndef CQBASE_H
Chris@366 33 #define CQBASE_H
Chris@366 34
Chris@366 35 #include <vector>
Chris@366 36 #include <complex>
Chris@366 37
Chris@366 38 /**
Chris@366 39 * Interface class for Constant-Q implementations, containing common
Chris@366 40 * type declarations and means to query configuration parameters.
Chris@366 41 */
Chris@366 42 class CQBase
Chris@366 43 {
Chris@366 44 public:
Chris@366 45 /// A single complex-valued sample.
Chris@366 46 typedef std::complex<double> Complex;
Chris@366 47
Chris@366 48 /// A series of real-valued samples ordered in time.
Chris@366 49 typedef std::vector<double> RealSequence;
Chris@366 50
Chris@366 51 /// A series of real-valued samples ordered by bin (frequency or similar).
Chris@366 52 typedef std::vector<double> RealColumn;
Chris@366 53
Chris@366 54 /// A series of complex-valued samples ordered in time.
Chris@366 55 typedef std::vector<Complex> ComplexSequence;
Chris@366 56
Chris@366 57 /// A series of complex-valued samples ordered by bin (frequency or similar).
Chris@366 58 typedef std::vector<Complex> ComplexColumn;
Chris@366 59
Chris@366 60 /// A matrix of real-valued samples, indexed by time then bin number.
Chris@366 61 typedef std::vector<RealColumn> RealBlock;
Chris@366 62
Chris@366 63 /// A matrix of complex-valued samples, indexed by time then bin number.
Chris@366 64 typedef std::vector<ComplexColumn> ComplexBlock;
Chris@366 65
Chris@366 66 /**
Chris@366 67 * Return true if the Constant-Q implementation was successfully
Chris@366 68 * constructed, with a valid set of initialisation parameters.
Chris@366 69 */
Chris@366 70 virtual bool isValid() const = 0;
Chris@366 71
Chris@366 72 /**
Chris@366 73 * Return the sample rate used when constructing the specific
Chris@366 74 * Constant-Q implementation.
Chris@366 75 */
Chris@366 76 virtual double getSampleRate() const = 0;
Chris@366 77
Chris@366 78 /**
Chris@366 79 * Return the number of bins per octave specified when
Chris@366 80 * constructing the Constant-Q implementation.
Chris@366 81 */
Chris@366 82 virtual int getBinsPerOctave() const = 0;
Chris@366 83
Chris@366 84 /**
Chris@366 85 * Return the number of octaves spanned by the Constant-Q
Chris@366 86 * transform.
Chris@366 87 */
Chris@366 88 virtual int getOctaves() const = 0;
Chris@366 89
Chris@366 90 /**
Chris@366 91 * Return the total number of bins in each Constant-Q column
Chris@366 92 * (i.e. bins-per-octave times number of octaves).
Chris@366 93 */
Chris@366 94 virtual int getTotalBins() const = 0;
Chris@366 95
Chris@366 96 /**
Chris@366 97 * Return the spacing, in samples at the sample rate returned from
Chris@366 98 * getSampleRate(), between one column and the next.
Chris@366 99 */
Chris@366 100 virtual int getColumnHop() const = 0;
Chris@366 101
Chris@366 102 /**
Chris@366 103 * Return the latency of Constant-Q calculation, in samples at the
Chris@366 104 * sample rate returned from getSampleRate().
Chris@366 105 */
Chris@366 106 virtual int getLatency() const = 0;
Chris@366 107
Chris@366 108 /**
Chris@366 109 * Return the maximum frequency of the Constant-Q output, i.e. the
Chris@366 110 * frequency of the highest bin in the output. This will normally
Chris@366 111 * be the same as the maximum frequency passed to the constructor
Chris@366 112 * of the specific Constant-Q implementation.
Chris@366 113 */
Chris@366 114 virtual double getMaxFrequency() const = 0;
Chris@366 115
Chris@366 116 /**
Chris@366 117 * Return the minimum frequency of the Constant-Q output, i.e. the
Chris@366 118 * frequency of the lowest bin in the output. This is derived from
Chris@366 119 * the maximum frequency and octave count, and is not necessarily
Chris@366 120 * the same as any minimum frequency requested when constructing
Chris@366 121 * the Constant-Q implementation.
Chris@366 122 */
Chris@366 123 virtual double getMinFrequency() const = 0;
Chris@366 124
Chris@366 125 /**
Chris@366 126 * Return the frequency of a given bin in the Constant-Q
Chris@366 127 * output. This actually maps a continuous "bin scale" value to
Chris@366 128 * frequency: the bin parameter does not have to be an integer.
Chris@366 129 */
Chris@366 130 virtual double getBinFrequency(double bin) const = 0;
Chris@366 131 };
Chris@366 132
Chris@366 133 #endif