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 CQBASE_H Chris@366: #define CQBASE_H Chris@366: Chris@366: #include Chris@366: #include Chris@366: Chris@366: /** Chris@366: * Interface class for Constant-Q implementations, containing common Chris@366: * type declarations and means to query configuration parameters. Chris@366: */ Chris@366: class CQBase Chris@366: { Chris@366: public: Chris@366: /// A single complex-valued sample. Chris@366: typedef std::complex Complex; Chris@366: Chris@366: /// A series of real-valued samples ordered in time. Chris@366: typedef std::vector RealSequence; Chris@366: Chris@366: /// A series of real-valued samples ordered by bin (frequency or similar). Chris@366: typedef std::vector RealColumn; Chris@366: Chris@366: /// A series of complex-valued samples ordered in time. Chris@366: typedef std::vector ComplexSequence; Chris@366: Chris@366: /// A series of complex-valued samples ordered by bin (frequency or similar). Chris@366: typedef std::vector ComplexColumn; Chris@366: Chris@366: /// A matrix of real-valued samples, indexed by time then bin number. Chris@366: typedef std::vector RealBlock; Chris@366: Chris@366: /// A matrix of complex-valued samples, indexed by time then bin number. Chris@366: typedef std::vector ComplexBlock; Chris@366: Chris@366: /** Chris@366: * Return true if the Constant-Q implementation was successfully Chris@366: * constructed, with a valid set of initialisation parameters. Chris@366: */ Chris@366: virtual bool isValid() const = 0; Chris@366: Chris@366: /** Chris@366: * Return the sample rate used when constructing the specific Chris@366: * Constant-Q implementation. Chris@366: */ Chris@366: virtual double getSampleRate() const = 0; Chris@366: Chris@366: /** Chris@366: * Return the number of bins per octave specified when Chris@366: * constructing the Constant-Q implementation. Chris@366: */ Chris@366: virtual int getBinsPerOctave() const = 0; Chris@366: Chris@366: /** Chris@366: * Return the number of octaves spanned by the Constant-Q Chris@366: * transform. Chris@366: */ Chris@366: virtual int getOctaves() const = 0; Chris@366: Chris@366: /** Chris@366: * Return the total number of bins in each Constant-Q column Chris@366: * (i.e. bins-per-octave times number of octaves). Chris@366: */ Chris@366: virtual int getTotalBins() const = 0; Chris@366: Chris@366: /** Chris@366: * Return the spacing, in samples at the sample rate returned from Chris@366: * getSampleRate(), between one column and the next. Chris@366: */ Chris@366: virtual int getColumnHop() const = 0; Chris@366: Chris@366: /** Chris@366: * Return the latency of Constant-Q calculation, in samples at the Chris@366: * sample rate returned from getSampleRate(). Chris@366: */ Chris@366: virtual int getLatency() const = 0; Chris@366: Chris@366: /** Chris@366: * Return the maximum frequency of the Constant-Q output, i.e. the Chris@366: * frequency of the highest bin in the output. This will normally Chris@366: * be the same as the maximum frequency passed to the constructor Chris@366: * of the specific Constant-Q implementation. Chris@366: */ Chris@366: virtual double getMaxFrequency() const = 0; Chris@366: Chris@366: /** Chris@366: * Return the minimum frequency of the Constant-Q output, i.e. the Chris@366: * frequency of the lowest bin in the output. This is derived from Chris@366: * the maximum frequency and octave count, and is not necessarily Chris@366: * the same as any minimum frequency requested when constructing Chris@366: * the Constant-Q implementation. Chris@366: */ Chris@366: virtual double getMinFrequency() const = 0; Chris@366: Chris@366: /** Chris@366: * Return the frequency of a given bin in the Constant-Q Chris@366: * output. This actually maps a continuous "bin scale" value to Chris@366: * frequency: the bin parameter does not have to be an integer. Chris@366: */ Chris@366: virtual double getBinFrequency(double bin) const = 0; Chris@366: }; Chris@366: Chris@366: #endif