libsidplayfp  0.3.5
Filter.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  * Filter distortion code written by Antti S. Lankila 2007 - 2008.
20  *
21  * @author Ken Händel
22  * Ported to c++ by Leandro Nini
23  *
24  */
25 
26 #ifndef FILTER_H
27 #define FILTER_H
28 
29 namespace reSIDfp
30 {
31 
40 class Filter {
41 
42 private:
46  bool enabled;
47 
51  char filt;
52 
53 protected:
54 
59 
63  int fc;
64 
68  int res;
69 
73  int vol;
74 
78  bool filt1, filt2, filt3, filtE;
79 
83  bool voice3off;
84 
88  bool hp, bp, lp;
89 
90 protected:
94  virtual void updatedCenterFrequency()=0;
95 
99  virtual void updatedResonance()=0;
100 
104  virtual void updatedMixing()=0;
105 
106 public:
107  Filter() :
108  enabled(true),
109  filt(0),
110  clockFrequency(0.),
111  fc(0),
112  res(0),
113  vol(0),
114  filt1(false),
115  filt2(false),
116  filt3(false),
117  filtE(false),
118  voice3off(false),
119  hp(false),
120  bp(false),
121  lp(false) {}
122 
123  virtual ~Filter() {}
124 
134  virtual int clock(const int v1, const int v2, const int v3)=0;
135 
141  void enable(const bool enable);
142 
143  void setClockFrequency(const double clock);
144 
148  void reset();
149 
155  void writeFC_LO(const unsigned char fc_lo);
156 
162  void writeFC_HI(const unsigned char fc_hi);
163 
169  void writeRES_FILT(const unsigned char res_filt);
170 
176  void writeMODE_VOL(const unsigned char mode_vol);
177 
178  virtual void input(const int input)=0;
179 };
180 
181 } // namespace reSIDfp
182 
183 #endif