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: This file 2005-2006 Christian Landone. 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: cannam@0: #ifndef DECIMATOR_H cannam@0: #define DECIMATOR_H cannam@0: Chris@150: /** Chris@150: * Decimator carries out a fast downsample by a power-of-two Chris@150: * factor. Only a limited number of factors are supported, from two to Chris@150: * whatever getHighestSupportedFactor() returns. This is much faster Chris@150: * than Resampler but has a worse signal-noise ratio. Chris@150: */ cannam@0: class Decimator cannam@0: { cannam@0: public: cannam@54: /** cannam@54: * Construct a Decimator 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: * cannam@54: * decFactor must be a power of two. The highest supported factor cannam@54: * is obtained through getHighestSupportedFactor(); for higher cannam@54: * factors, you will need to chain more than one decimator. cannam@54: */ cannam@0: Decimator( unsigned int inLength, unsigned int decFactor ); cannam@0: virtual ~Decimator(); cannam@0: Chris@163: /** Chris@163: * Process inLength samples (as supplied to constructor) from src Chris@163: * and write inLength / decFactor samples to dst. Note that src Chris@163: * and dst may be the same or overlap (an intermediate buffer is Chris@163: * used). Chris@163: */ Chris@163: void process( const double* src, double* dst ); Chris@163: Chris@163: /** Chris@163: * Process inLength samples (as supplied to constructor) from src Chris@163: * and write inLength / decFactor samples to dst. Note that src Chris@163: * and dst may be the same or overlap (an intermediate buffer is Chris@163: * used). Chris@163: */ Chris@163: void process( const float* src, float* dst ); Chris@163: cannam@22: int getFactor() const { return m_decFactor; } cannam@22: static int getHighestSupportedFactor() { return 8; } cannam@22: Chris@163: void resetFilter(); Chris@163: cannam@0: private: cannam@0: void deInitialise(); cannam@0: void initialise( unsigned int inLength, unsigned int decFactor ); cannam@55: void doAntiAlias( const double* src, double* dst, unsigned int length ); cannam@55: void doAntiAlias( const float* src, double* dst, unsigned int length ); cannam@0: cannam@0: unsigned int m_inputLength; cannam@0: unsigned int m_outputLength; cannam@0: unsigned int m_decFactor; cannam@0: cannam@0: double Input; cannam@0: double Output ; cannam@0: cannam@0: double o1,o2,o3,o4,o5,o6,o7; cannam@0: cannam@0: double a[ 9 ]; cannam@0: double b[ 9 ]; cannam@0: cannam@0: double* decBuffer; cannam@0: }; cannam@0: cannam@0: #endif //