libsidplayfp
1.0.3
|
00001 /* 00002 * This file is part of libsidplayfp, a SID player engine. 00003 * 00004 * Copyright 2011-2013 Leandro Nini <drfiemost@users.sourceforge.net> 00005 * Copyright 2007-2010 Antti Lankila 00006 * Copyright 2004 Dag Lem <resid@nimrod.no> 00007 * 00008 * This program is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #ifndef SINCRESAMPLER_H 00024 #define SINCRESAMPLER_H 00025 00026 #include "Resampler.h" 00027 00028 #include <string> 00029 #include <map> 00030 00031 #include "../array.h" 00032 00033 namespace reSIDfp 00034 { 00035 00070 class SincResampler : public Resampler 00071 { 00072 private: 00073 static const int RINGSIZE = 2048; 00074 00075 static const int BITS = 16; 00076 00077 array<short>* firTable; 00078 00079 int sampleIndex; 00080 00081 int firRES, firN; 00082 00083 const int cyclesPerSample; 00084 00085 int sampleOffset; 00086 00087 int outputValue; 00088 00089 short sample[RINGSIZE * 2]; 00090 00094 static std::map<std::string, array<short> > FIR_CACHE; 00095 00097 static const double I0E; 00098 00107 static double I0(double x); 00108 00117 static int convolve(const short* a, const short* b, int bLength); 00118 00119 int fir(int subcycle); 00120 00121 public: 00142 SincResampler(double clockFrequency, double samplingFrequency, double highestAccurateFrequency); 00143 00144 bool input(int input); 00145 00146 int output() const { return outputValue; } 00147 00148 void reset(); 00149 }; 00150 00151 } // namespace reSIDfp 00152 00153 #endif