1 // ---------------------------------------------------------------------------
2 // This file is part of reSID, a MOS6581 SID emulator engine.
3 // Copyright (C) 2010 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
20 #define RESID_EXTFILT_CC
21
22 #include "extfilt.h"
23
24 namespace reSID
25 {
26
27 // ----------------------------------------------------------------------------
28 // Constructor.
29 // ----------------------------------------------------------------------------
ExternalFilter()30 ExternalFilter::ExternalFilter()
31 {
32 reset();
33 enable_filter(true);
34
35 // Low-pass: R = 10 kOhm, C = 1000 pF; w0l = dt/(dt+RC) = 1e-6/(1e-6+1e4*1e-9) = 0.091
36 // High-pass: R = 1 kOhm, C = 10 uF; w0h = dt/(dt+RC) = 1e-6/(1e-6+1e3*1e-5) = 0.0000999
37
38 // Assume a 1MHz clock.
39 // Cutoff frequency accuracy (4 bits) is traded off for filter signal
40 // accuracy (27 bits). This is crucial since w0lp and w0hp are so far apart.
41 w0lp_1_s7 = int(1e-6/(1e-6+1e4*1e-9)*(1 << 7) + 0.5);
42 w0hp_1_s17 = int(1e-6/(1e-6+1e3*1e-5)*(1 << 17) + 0.5);
43 }
44
45
46 // ----------------------------------------------------------------------------
47 // Enable filter.
48 // ----------------------------------------------------------------------------
enable_filter(bool enable)49 void ExternalFilter::enable_filter(bool enable)
50 {
51 enabled = enable;
52 }
53
54
55 // ----------------------------------------------------------------------------
56 // SID reset.
57 // ----------------------------------------------------------------------------
reset()58 void ExternalFilter::reset()
59 {
60 // State of filter.
61 Vlp = 0;
62 Vhp = 0;
63 }
64
65 } // namespace reSID
66