summaryrefslogtreecommitdiff
path: root/libs/qm-dsp/dsp/rateconversion/DecimatorB.h
blob: 8458e610613307e6fe0e895fd5bd8e6138b23a49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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