libsidplayfp  1.5.3
SincResampler.h
1 /*
2  * This file is part of libsidplayfp, a SID player engine.
3  *
4  * Copyright 2011-2013 Leandro Nini <drfiemost@users.sourceforge.net>
5  * Copyright 2007-2010 Antti Lankila
6  * Copyright 2004 Dag Lem <resid@nimrod.no>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef SINCRESAMPLER_H
24 #define SINCRESAMPLER_H
25 
26 #include "Resampler.h"
27 
28 #include <string>
29 #include <map>
30 
31 #include "../array.h"
32 
33 namespace reSIDfp
34 {
35 
51 class SincResampler : public Resampler
52 {
53 private:
54  typedef std::map<std::string, matrix_t> fir_cache_t;
55 
56 private:
57  static const int RINGSIZE = 2048;
58 
59  static const int BITS = 16;
60 
61  matrix_t* firTable;
62 
63  int sampleIndex;
64 
65  int firRES, firN;
66 
67  const int cyclesPerSample;
68 
69  int sampleOffset;
70 
71  int outputValue;
72 
73  short sample[RINGSIZE * 2];
74 
76  static fir_cache_t FIR_CACHE;
77 
79  static const double I0E;
80 
81 private:
90  static double I0(double x);
91 
100  static int convolve(const short* a, const short* b, int bLength);
101 
102  int fir(int subcycle);
103 
104 public:
125  SincResampler(double clockFrequency, double samplingFrequency, double highestAccurateFrequency);
126 
127  bool input(int input);
128 
129  int output() const { return outputValue; }
130 
131  void reset();
132 };
133 
134 } // namespace reSIDfp
135 
136 #endif
Definition: SincResampler.h:51
Definition: array.h:41
bool input(int input)
Definition: SincResampler.cpp:212
Definition: Resampler.h:32
SincResampler(double clockFrequency, double samplingFrequency, double highestAccurateFrequency)
Definition: SincResampler.cpp:124