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