diff options
author | Robin Gareus <robin@gareus.org> | 2016-10-06 00:16:44 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2016-10-06 00:57:53 +0200 |
commit | f68d2e06bcfb81efda107d3b4c3aa7dbc2d73bc2 (patch) | |
tree | 286d5b2b1c3573c2fbfc77b4d29b0b2a6bfa9686 /libs/qm-dsp/dsp/rateconversion/DecimatorB.h | |
parent | 2a27cc475867612afd261e5bf3b2a1a42b9c75cc (diff) |
update qm-dsp library
Diffstat (limited to 'libs/qm-dsp/dsp/rateconversion/DecimatorB.h')
-rw-r--r-- | libs/qm-dsp/dsp/rateconversion/DecimatorB.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/libs/qm-dsp/dsp/rateconversion/DecimatorB.h b/libs/qm-dsp/dsp/rateconversion/DecimatorB.h new file mode 100644 index 0000000000..8458e61061 --- /dev/null +++ b/libs/qm-dsp/dsp/rateconversion/DecimatorB.h @@ -0,0 +1,64 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ +/* + QM DSP Library + + Centre for Digital Music, Queen Mary, University of London. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + +#ifndef DECIMATORB_H +#define DECIMATORB_H + +#include <vector> + +/** + * DecimatorB carries out a fast downsample by a power-of-two + * factor. It only knows how to decimate by a factor of 2, and will + * use repeated decimation for higher factors. A Butterworth filter of + * order 6 is used for the lowpass filter. + */ +class DecimatorB +{ +public: + void process( const double* src, double* dst ); + void process( const float* src, float* dst ); + + /** + * Construct a DecimatorB to operate on input blocks of length + * inLength, with decimation factor decFactor. inLength should be + * a multiple of decFactor. Output blocks will be of length + * inLength / decFactor. + * + * decFactor must be a power of two. + */ + DecimatorB(int inLength, int decFactor); + virtual ~DecimatorB(); + + int getFactor() const { return m_decFactor; } + +private: + void deInitialise(); + void initialise(int inLength, int decFactor); + void doAntiAlias(const double* src, double* dst, int length, int filteridx); + void doProcess(); + + int m_inputLength; + int m_outputLength; + int m_decFactor; + + std::vector<std::vector<double> > m_o; + + double m_a[7]; + double m_b[7]; + + double *m_aaBuffer; + double *m_tmpBuffer; +}; + +#endif + |