libsidplayfp  0.3.5
ExternalFilter.h
1 /*
2  * This file is part of reSID, a MOS6581 SID emulator engine.
3  * Copyright (C) 2004 Dag Lem <resid@nimrod.no>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * @author Ken Händel
20  *
21  */
22 
23 #ifndef EXTERNALFILTER_H
24 #define EXTERNALFILTER_H
25 
26 #include "siddefs-fp.h"
27 
28 namespace reSIDfp
29 {
30 
48 
49 private:
53  int Vlp;
54 
58  int Vhp;
59 
60  int w0lp_1_s7;
61 
62  int w0hp_1_s19;
63 
64 public:
70  int clock(const int Vi);
71 
76 
82  void setClockFrequency(const double frequency);
83 
87  void reset();
88 };
89 
90 } // namespace reSIDfp
91 
92 #if RESID_INLINING || defined(EXTERNALFILTER_CPP)
93 
94 namespace reSIDfp
95 {
96 
97 RESID_INLINE
98 int ExternalFilter::clock(const int Vi) {
99  const int dVlp = (w0lp_1_s7*((Vi << 11) - Vlp) >> 7);
100  const int dVhp = (w0hp_1_s19*(Vlp - Vhp) >> 19);
101  Vlp += dVlp;
102  Vhp += dVhp;
103  return (Vlp - Vhp) >> 11;
104 }
105 
106 } // namespace reSIDfp
107 
108 #endif
109 
110 #endif