1
// ---------------------------------------------------------------------------
2
// This file is part of reSID, a MOS6581 SID emulator engine.
3
// Copyright (C) 2004 Dag Lem <resid@nimrod.no>
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.
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.
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
// ---------------------------------------------------------------------------
20
#define __EXTFILT_CC__
23
// ----------------------------------------------------------------------------
25
// ----------------------------------------------------------------------------
26
ExternalFilterFP::ExternalFilterFP()
30
set_chip_model(MOS6581FP);
31
set_clock_frequency(1e6f);
32
set_sampling_parameter(15915.6f);
36
// ----------------------------------------------------------------------------
38
// ----------------------------------------------------------------------------
39
void ExternalFilterFP::enable_filter(bool enable)
44
// ----------------------------------------------------------------------------
45
// Setup of the external filter sampling parameters.
46
// ----------------------------------------------------------------------------
47
void ExternalFilterFP::set_clock_frequency(float clock)
49
clock_frequency = clock;
50
_set_sampling_parameter();
53
void ExternalFilterFP::set_sampling_parameter(float freq)
55
pass_frequency = freq;
56
_set_sampling_parameter();
59
void ExternalFilterFP::_set_sampling_parameter()
61
// Low-pass: R = 10kOhm, C = 1000pF; w0l = 1/RC = 1/(1e4*1e-9) = 100000
62
// High-pass: R = 1kOhm, C = 10uF; w0h = 1/RC = 1/(1e3*1e-5) = 100
63
w0hp = 100.f / clock_frequency;
64
w0lp = pass_frequency * 2.f * M_PI_f / clock_frequency;
67
// ----------------------------------------------------------------------------
69
// ----------------------------------------------------------------------------
70
void ExternalFilterFP::set_chip_model(chip_model model)
72
if (model == MOS6581FP) {
73
// Approximate the DC output level to be removed if the external
74
// filter is turned off. (0x800 - wave_zero + voice DC) * maxenv * voices
76
mixer_DC = (-0x600 + 0x800) * 0xff * 3 - 0x20000;
79
// No DC offsets in the MOS8580.
85
// ----------------------------------------------------------------------------
87
// ----------------------------------------------------------------------------
88
void ExternalFilterFP::reset()