| 1 | // --------------------------------------------------------------------------- |
| 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 | #include "extfiltfp.h" |
| 21 | |
| 22 | const float pass_frequency = 15915.6f; |
| 23 | |
| 24 | // ---------------------------------------------------------------------------- |
| 25 | // Constructor. |
| 26 | // ---------------------------------------------------------------------------- |
| 27 | ExternalFilterFP::ExternalFilterFP() |
| 28 | { |
| 29 | reset(); |
| 30 | set_clock_frequency(1e6f); |
| 31 | } |
| 32 | |
| 33 | // ---------------------------------------------------------------------------- |
| 34 | // Setup of the external filter sampling parameters. |
| 35 | // ---------------------------------------------------------------------------- |
| 36 | void ExternalFilterFP::set_clock_frequency(float clock_frequency) |
| 37 | { |
| 38 | // Low-pass: R = 10kOhm, C = 1000pF; w0l = 1/RC = 1/(1e4*1e-9) = 100000 |
| 39 | // High-pass: R = 1kOhm, C = 10uF; w0h = 1/RC = 1/(1e3*1e-5) = 100 |
| 40 | w0hp = 100.f / clock_frequency; |
| 41 | w0lp = pass_frequency * 2.f * static_cast<float>(M_PI) / clock_frequency; |
| 42 | } |
| 43 | |
| 44 | // ---------------------------------------------------------------------------- |
| 45 | // SID reset. |
| 46 | // ---------------------------------------------------------------------------- |
| 47 | void ExternalFilterFP::reset() |
| 48 | { |
| 49 | // State of filter. |
| 50 | Vlp = 0; |
| 51 | Vhp = 0; |
| 52 | } |