libsidplayfp  1.3.0
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 
32 class Filter
33 {
34 private:
36  bool enabled;
37 
39  char filt;
40 
41 protected:
44 
46  int fc;
47 
49  int res;
50 
52  int vol;
53 
55  bool filt1, filt2, filt3, filtE;
56 
58  bool voice3off;
59 
61  bool hp, bp, lp;
62 
63 protected:
67  virtual void updatedCenterFrequency() = 0;
68 
72  virtual void updatedResonance() = 0;
73 
77  virtual void updatedMixing() = 0;
78 
79 public:
80  Filter() :
81  enabled(true),
82  filt(0),
83  clockFrequency(0.),
84  fc(0),
85  res(0),
86  vol(0),
87  filt1(false),
88  filt2(false),
89  filt3(false),
90  filtE(false),
91  voice3off(false),
92  hp(false),
93  bp(false),
94  lp(false) {}
95 
96  virtual ~Filter() {}
97 
106  virtual int clock(int v1, int v2, int v3) = 0;
107 
113  void enable(bool enable);
114 
115  void setClockFrequency(double clock);
116 
120  void reset();
121 
127  void writeFC_LO(unsigned char fc_lo);
128 
134  void writeFC_HI(unsigned char fc_hi);
135 
141  void writeRES_FILT(unsigned char res_filt);
142 
148  void writeMODE_VOL(unsigned char mode_vol);
149 
150  virtual void input(int input) = 0;
151 };
152 
153 } // namespace reSIDfp
154 
155 #endif
virtual void updatedMixing()=0
bool hp
Highpass, bandpass, and lowpass filter modes.
Definition: Filter.h:61
bool filt1
Routing to filter or outside filter.
Definition: Filter.h:55
virtual void updatedCenterFrequency()=0
void writeMODE_VOL(unsigned char mode_vol)
Definition: Filter.cpp:86
bool voice3off
Switch voice 3 off.
Definition: Filter.h:58
virtual int clock(int v1, int v2, int v3)=0
int vol
Current volume.
Definition: Filter.h:52
void writeRES_FILT(unsigned char res_filt)
Definition: Filter.cpp:68
double clockFrequency
Current clock frequency.
Definition: Filter.h:43
void reset()
Definition: Filter.cpp:48
int res
Filter resonance.
Definition: Filter.h:49
void writeFC_HI(unsigned char fc_hi)
Definition: Filter.cpp:62
void writeFC_LO(unsigned char fc_lo)
Definition: Filter.cpp:56
void enable(bool enable)
Definition: Filter.cpp:28
Definition: Filter.h:32
int fc
Filter cutoff frequency.
Definition: Filter.h:46
virtual void updatedResonance()=0