c@116: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ c@116: /* c@116: Constant-Q library c@116: Copyright (c) 2013-2014 Queen Mary, University of London c@116: c@116: Permission is hereby granted, free of charge, to any person c@116: obtaining a copy of this software and associated documentation c@116: files (the "Software"), to deal in the Software without c@116: restriction, including without limitation the rights to use, copy, c@116: modify, merge, publish, distribute, sublicense, and/or sell copies c@116: of the Software, and to permit persons to whom the Software is c@116: furnished to do so, subject to the following conditions: c@116: c@116: The above copyright notice and this permission notice shall be c@116: included in all copies or substantial portions of the Software. c@116: c@116: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, c@116: EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF c@116: MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND c@116: NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY c@116: CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF c@116: CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION c@116: WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. c@116: c@116: Except as contained in this notice, the names of the Centre for c@116: Digital Music; Queen Mary, University of London; and Chris Cannam c@116: shall not be used in advertising or otherwise to promote the sale, c@116: use or other dealings in this Software without prior written c@116: authorization. c@116: */ c@116: c@116: #ifndef CQBASE_H c@116: #define CQBASE_H c@116: c@116: #include c@116: #include c@116: c@147: /** c@147: * Interface class for Constant-Q implementations, containing common c@147: * type declarations and means to query configuration parameters. c@147: */ c@147: class CQBase c@116: { c@116: public: c@147: /// A single complex-valued sample. c@116: typedef std::complex Complex; c@147: c@147: /// A series of real-valued samples ordered in time. c@116: typedef std::vector RealSequence; c@147: c@147: /// A series of real-valued samples ordered by bin (frequency or similar). c@116: typedef std::vector RealColumn; c@147: c@147: /// A series of complex-valued samples ordered in time. c@116: typedef std::vector ComplexSequence; c@147: c@147: /// A series of complex-valued samples ordered by bin (frequency or similar). c@116: typedef std::vector ComplexColumn; c@147: c@147: /// A matrix of real-valued samples, indexed by time then bin number. c@116: typedef std::vector RealBlock; c@147: c@147: /// A matrix of complex-valued samples, indexed by time then bin number. c@116: typedef std::vector ComplexBlock; c@116: c@147: /** c@147: * Return true if the Constant-Q implementation was successfully c@147: * constructed, with a valid set of initialisation parameters. c@147: */ c@147: virtual bool isValid() const = 0; c@147: c@147: /** c@147: * Return the sample rate used when constructing the specific c@147: * Constant-Q implementation. c@147: */ c@116: virtual double getSampleRate() const = 0; c@147: c@147: /** c@147: * Return the number of bins per octave specified when c@147: * constructing the Constant-Q implementation. c@147: */ c@116: virtual int getBinsPerOctave() const = 0; c@147: c@147: /** c@147: * Return the number of octaves spanned by the Constant-Q c@147: * transform. c@147: */ c@116: virtual int getOctaves() const = 0; c@147: c@147: /** c@147: * Return the total number of bins in each Constant-Q column c@147: * (i.e. bins-per-octave times number of octaves). c@147: */ c@116: virtual int getTotalBins() const = 0; c@147: c@147: /** c@147: * Return the spacing, in samples at the sample rate returned from c@147: * getSampleRate(), between one column and the next. c@147: */ c@116: virtual int getColumnHop() const = 0; c@147: c@147: /** c@147: * Return the latency of Constant-Q calculation, in samples at the c@147: * sample rate returned from getSampleRate(). c@147: */ c@116: virtual int getLatency() const = 0; c@147: c@147: /** c@147: * Return the maximum frequency of the Constant-Q output, i.e. the c@147: * frequency of the highest bin in the output. This will normally c@147: * be the same as the maximum frequency passed to the constructor c@147: * of the specific Constant-Q implementation. c@147: */ c@116: virtual double getMaxFrequency() const = 0; c@147: c@147: /** c@147: * Return the minimum frequency of the Constant-Q output, i.e. the c@147: * frequency of the lowest bin in the output. This is derived from c@147: * the maximum frequency and octave count, and is not necessarily c@147: * the same as any minimum frequency requested when constructing c@147: * the Constant-Q implementation. c@147: */ c@147: virtual double getMinFrequency() const = 0; c@147: c@147: /** c@147: * Return the frequency of a given bin in the Constant-Q c@147: * output. This actually maps a continuous "bin scale" value to c@147: * frequency: the bin parameter does not have to be an integer. c@147: */ c@145: virtual double getBinFrequency(double bin) const = 0; c@116: }; c@116: c@116: #endif