libsidplayfp  1.0.3
Filter.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 FILTER_H
24 #define FILTER_H
25 
26 namespace reSIDfp
27 {
28 
37 class Filter
38 {
39 private:
43  bool enabled;
44 
48  char filt;
49 
50 protected:
51 
56 
60  int fc;
61 
65  int res;
66 
70  int vol;
71 
75  bool filt1, filt2, filt3, filtE;
76 
80  bool voice3off;
81 
85  bool hp, bp, lp;
86 
87 protected:
91  virtual void updatedCenterFrequency() = 0;
92 
96  virtual void updatedResonance() = 0;
97 
101  virtual void updatedMixing() = 0;
102 
103 public:
104  Filter() :
105  enabled(true),
106  filt(0),
107  clockFrequency(0.),
108  fc(0),
109  res(0),
110  vol(0),
111  filt1(false),
112  filt2(false),
113  filt3(false),
114  filtE(false),
115  voice3off(false),
116  hp(false),
117  bp(false),
118  lp(false) {}
119 
120  virtual ~Filter() {}
121 
130  virtual int clock(int v1, int v2, int v3) = 0;
131 
137  void enable(bool enable);
138 
139  void setClockFrequency(double clock);
140 
144  void reset();
145 
151  void writeFC_LO(unsigned char fc_lo);
152 
158  void writeFC_HI(unsigned char fc_hi);
159 
165  void writeRES_FILT(unsigned char res_filt);
166 
172  void writeMODE_VOL(unsigned char mode_vol);
173 
174  virtual void input(int input) = 0;
175 };
176 
177 } // namespace reSIDfp
178 
179 #endif