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 EXTERNALFILTER_H 00024 #define EXTERNALFILTER_H 00025 00026 #include "siddefs-fp.h" 00027 00028 namespace reSIDfp 00029 { 00030 00051 class ExternalFilter 00052 { 00053 private: 00057 int Vlp; 00058 00062 int Vhp; 00063 00064 int w0lp_1_s7; 00065 00066 int w0hp_1_s17; 00067 00068 public: 00074 int clock(int Vi); 00075 00079 ExternalFilter(); 00080 00086 void setClockFrequency(double frequency); 00087 00091 void reset(); 00092 }; 00093 00094 } // namespace reSIDfp 00095 00096 #if RESID_INLINING || defined(EXTERNALFILTER_CPP) 00097 00098 namespace reSIDfp 00099 { 00100 00101 RESID_INLINE 00102 int ExternalFilter::clock(int Vi) 00103 { 00104 const int dVlp = (w0lp_1_s7 * ((Vi << 11) - Vlp) >> 7); 00105 const int dVhp = (w0hp_1_s17 * (Vlp - Vhp) >> 17); 00106 Vlp += dVlp; 00107 Vhp += dVhp; 00108 return (Vlp - Vhp) >> 11; 00109 } 00110 00111 } // namespace reSIDfp 00112 00113 #endif 00114 00115 #endif