Debian Codegraph @

src/resid-fp/extfiltfp.h

raw symbols SCIP
1 // ---------------------------------------------------------------------------cxx . . $ `<file>/src/resid-fp/extfiltfp.h`/
2 // This file is part of reSID, a MOS6581 SID emulator engine.
3 // Copyright (C) 2004 Dag Lem <[email protected]>
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
20 #ifndef __EXTFILTFP_H__
21 #define __EXTFILTFP_H__cxx . . $ `src/resid-fp/extfiltfp.h:21:9`!
22
23 #include <math.h>
24
25 #include "siddefsfp.h"cxx . . $ `<file>/src/resid-fp/siddefsfp.h`/
26
27 // ----------------------------------------------------------------------------
28 // The audio output stage in a Commodore 64 consists of two STC networks,
29 // a low-pass filter with 3-dB frequency 16kHz followed by a high-pass
30 // filter with 3-dB frequency 16Hz (the latter provided an audio equipment
31 // input impedance of 1kOhm).
32 // The STC networks are connected with a BJT supposedly meant to act as
33 // a unity gain buffer, which is not really how it works. A more elaborate
34 // model would include the BJT, however DC circuit analysis yields BJT
35 // base-emitter and emitter-base impedances sufficiently low to produce
36 // additional low-pass and high-pass 3dB-frequencies in the order of hundreds
37 // of kHz. This calls for a sampling frequency of several MHz, which is far
38 // too high for practical use.
39 // ----------------------------------------------------------------------------
40 class ExternalFilterFPcxx . . $ ExternalFilterFP#
41 {
42 public:
43 ExternalFilterFPcxx . . $ ExternalFilterFP#ExternalFilterFP(49f6e7a06ebc5aa8).();
44
45 void set_clock_frequencycxx . . $ ExternalFilterFP#set_clock_frequency(9364e6e7bff7660).(float);
46
47 inline void clockcxx . . $ ExternalFilterFP#clock(9364e6e7bff7660).(float Vi);
48 void resetcxx . . $ ExternalFilterFP#reset(49f6e7a06ebc5aa8).();
49
50 // Audio output (20 bits).
51 inline float outputcxx . . $ ExternalFilterFP#output(9b8c9e39889c762c).();
52
53 private:
54 inline void nuke_denormalscxx . . $ ExternalFilterFP#nuke_denormals(49f6e7a06ebc5aa8).();
55
56 // State of filters.
57 float Vlpcxx . . $ ExternalFilterFP#Vlp.; // lowpass
58 float Vhpcxx . . $ ExternalFilterFP#Vhp.; // highpass
59
60 // Cutoff frequencies.
61 float w0lpcxx . . $ ExternalFilterFP#w0lp.;
62 float w0hpcxx . . $ ExternalFilterFP#w0hp.;
63
64 friend class SIDFPcxx . . $ SIDFP#;
65 };
66
67 // ----------------------------------------------------------------------------
68 // SID clocking - 1 cycle.
69 // ----------------------------------------------------------------------------
70 inline
71 void ExternalFilterFPcxx . . $ ExternalFilterFP#::clockcxx . . $ ExternalFilterFP#clock(9364e6e7bff7660).(float Vi)
72 {
73 float dVlp = w0lpcxx . . $ ExternalFilterFP#w0lp. * (Vi - Vlpcxx . . $ ExternalFilterFP#Vlp.);
74 float dVhp = w0hpcxx . . $ ExternalFilterFP#w0hp. * (Vlpcxx . . $ ExternalFilterFP#Vlp. - Vhpcxx . . $ ExternalFilterFP#Vhp.);
75 Vlpcxx . . $ ExternalFilterFP#Vlp. += dVlp;
76 Vhpcxx . . $ ExternalFilterFP#Vhp. += dVhp;
77 }
78
79 // ----------------------------------------------------------------------------
80 // Audio output (19.5 bits).
81 // ----------------------------------------------------------------------------
82 inline
83 float ExternalFilterFPcxx . . $ ExternalFilterFP#::outputcxx . . $ ExternalFilterFP#output(9b8c9e39889c762c).()
84 {
85 return Vlpcxx . . $ ExternalFilterFP#Vlp. - Vhpcxx . . $ ExternalFilterFP#Vhp.;
86 }
87
88 inline
89 void ExternalFilterFPcxx . . $ ExternalFilterFP#::nuke_denormalscxx . . $ ExternalFilterFP#nuke_denormals(49f6e7a06ebc5aa8).()
90 {
91 if (Vhpcxx . . $ ExternalFilterFP#Vhp. > -1e-12f && Vhpcxx . . $ ExternalFilterFP#Vhp. < 1e-12f)
92 Vhpcxx . . $ ExternalFilterFP#Vhp. = 0;
93 if (Vlpcxx . . $ ExternalFilterFP#Vlp. > -1e-12f && Vlpcxx . . $ ExternalFilterFP#Vlp. < 1e-12f)
94 Vlpcxx . . $ ExternalFilterFP#Vlp. = 0;
95 }
96
97 #endif // not __EXTFILTFP_H__