libsidplayfp  2.0.2
Filter.h
1 /*
2  * This file is part of libsidplayfp, a SID player engine.
3  *
4  * Copyright 2011-2017 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 protected:
36  unsigned short* currentGain;
37 
39  unsigned short* currentMixer;
40 
42  unsigned short* currentSummer;
43 
45  unsigned short* currentResonance;
46 
48  int Vhp;
49 
51  int Vbp;
52 
54  int Vlp;
55 
57  int ve;
58 
60  unsigned int fc;
61 
63  bool filt1, filt2, filt3, filtE;
64 
66  bool voice3off;
67 
69  bool hp, bp, lp;
70 
72  unsigned char vol;
73 
74 private:
76  bool enabled;
77 
79  unsigned char filt;
80 
81 protected:
85  virtual void updatedCenterFrequency() = 0;
86 
90  virtual void updateResonance(unsigned char res) = 0;
91 
95  virtual void updatedMixing() = 0;
96 
97 public:
98  Filter() :
99  currentGain(nullptr),
100  currentMixer(nullptr),
101  currentSummer(nullptr),
102  currentResonance(nullptr),
103  Vhp(0),
104  Vbp(0),
105  Vlp(0),
106  ve(0),
107  fc(0),
108  filt1(false),
109  filt2(false),
110  filt3(false),
111  filtE(false),
112  voice3off(false),
113  hp(false),
114  bp(false),
115  lp(false),
116  vol(0),
117  enabled(true),
118  filt(0) {}
119 
120  virtual ~Filter() {}
121 
130  virtual int clock(int v1, int v2, int v3) = 0;
131 
137  void enable(bool enable);
138 
142  void reset();
143 
149  void writeFC_LO(unsigned char fc_lo);
150 
156  void writeFC_HI(unsigned char fc_hi);
157 
163  void writeRES_FILT(unsigned char res_filt);
164 
170  void writeMODE_VOL(unsigned char mode_vol);
171 
172  virtual void input(int input) = 0;
173 };
174 
175 } // namespace reSIDfp
176 
177 #endif
reSIDfp::Filter::ve
int ve
Filter external input.
Definition: Filter.h:57
reSIDfp::Filter::vol
unsigned char vol
Current volume.
Definition: Filter.h:72
reSIDfp::Filter::filt1
bool filt1
Routing to filter or outside filter.
Definition: Filter.h:63
reSIDfp::Filter::Vhp
int Vhp
Filter highpass state.
Definition: Filter.h:48
reSIDfp::Filter::Vlp
int Vlp
Filter lowpass state.
Definition: Filter.h:54
reSIDfp::Filter
Definition: Filter.h:33
reSIDfp::Filter::updatedMixing
virtual void updatedMixing()=0
reSIDfp::Filter::hp
bool hp
Highpass, bandpass, and lowpass filter modes.
Definition: Filter.h:69
reSIDfp::Filter::clock
virtual int clock(int v1, int v2, int v3)=0
reSIDfp::Filter::currentSummer
unsigned short * currentSummer
Filter input summer setting.
Definition: Filter.h:42
reSIDfp::Filter::updatedCenterFrequency
virtual void updatedCenterFrequency()=0
reSIDfp::Filter::writeMODE_VOL
void writeMODE_VOL(unsigned char mode_vol)
Definition: Filter.cpp:79
reSIDfp::Filter::writeRES_FILT
void writeRES_FILT(unsigned char res_filt)
Definition: Filter.cpp:62
reSIDfp::Filter::currentGain
unsigned short * currentGain
Current volume amplifier setting.
Definition: Filter.h:36
reSIDfp::Filter::voice3off
bool voice3off
Switch voice 3 off.
Definition: Filter.h:66
reSIDfp::Filter::Vbp
int Vbp
Filter bandpass state.
Definition: Filter.h:51
reSIDfp::Filter::reset
void reset()
Definition: Filter.cpp:42
reSIDfp::Filter::currentMixer
unsigned short * currentMixer
Current filter/voice mixer setting.
Definition: Filter.h:39
reSIDfp::Filter::writeFC_HI
void writeFC_HI(unsigned char fc_hi)
Definition: Filter.cpp:56
reSIDfp::Filter::writeFC_LO
void writeFC_LO(unsigned char fc_lo)
Definition: Filter.cpp:50
reSIDfp::Filter::currentResonance
unsigned short * currentResonance
Filter resonance value.
Definition: Filter.h:45
reSIDfp::Filter::enable
void enable(bool enable)
Definition: Filter.cpp:28
reSIDfp::Filter::fc
unsigned int fc
Filter cutoff frequency.
Definition: Filter.h:60
reSIDfp::Filter::updateResonance
virtual void updateResonance(unsigned char res)=0