cannam@0: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ cannam@0: /* cannam@0: QM DSP Library cannam@0: cannam@0: Centre for Digital Music, Queen Mary, University of London. Chris@84: Chris@84: This program is free software; you can redistribute it and/or Chris@84: modify it under the terms of the GNU General Public License as Chris@84: published by the Free Software Foundation; either version 2 of the Chris@84: License, or (at your option) any later version. See the file Chris@84: COPYING included with this distribution for more information. cannam@0: */ cannam@0: Chris@155: #ifndef DECIMATORB_H Chris@155: #define DECIMATORB_H Chris@155: Chris@155: #include cannam@0: Chris@150: /** Chris@155: * DecimatorB carries out a fast downsample by a power-of-two Chris@155: * factor. It only knows how to decimate by a factor of 2, and will Chris@155: * use repeated decimation for higher factors. A Butterworth filter of Chris@155: * order 6 is used for the lowpass filter. Chris@150: */ Chris@155: class DecimatorB cannam@0: { cannam@0: public: cannam@22: void process( const double* src, double* dst ); cannam@55: void process( const float* src, float* dst ); cannam@0: cannam@54: /** Chris@155: * Construct a DecimatorB to operate on input blocks of length cannam@54: * inLength, with decimation factor decFactor. inLength should be cannam@54: * a multiple of decFactor. Output blocks will be of length cannam@54: * inLength / decFactor. cannam@54: * Chris@155: * decFactor must be a power of two. cannam@54: */ Chris@155: DecimatorB(int inLength, int decFactor); Chris@155: virtual ~DecimatorB(); cannam@0: cannam@22: int getFactor() const { return m_decFactor; } cannam@22: cannam@0: private: cannam@0: void deInitialise(); Chris@155: void initialise(int inLength, int decFactor); Chris@155: void doAntiAlias(const double* src, double* dst, int length, int filteridx); Chris@155: void doProcess(); cannam@0: Chris@155: int m_inputLength; Chris@155: int m_outputLength; Chris@155: int m_decFactor; cannam@0: Chris@155: std::vector > m_o; cannam@0: Chris@155: double m_a[7]; Chris@155: double m_b[7]; cannam@0: Chris@155: double *m_aaBuffer; Chris@155: double *m_tmpBuffer; cannam@0: }; cannam@0: Chris@155: #endif Chris@155: