17
17
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
18
// ---------------------------------------------------------------------------
20
#define __EXTFILT_CC__
21
20
#include "extfilt.h"
22
const float pass_frequency = 15915.6f;
23
24
// ----------------------------------------------------------------------------
26
27
ExternalFilterFP::ExternalFilterFP()
30
set_chip_model(MOS6581FP);
31
30
set_clock_frequency(1e6f);
32
set_sampling_parameter(15915.6f);
36
// ----------------------------------------------------------------------------
38
// ----------------------------------------------------------------------------
39
void ExternalFilterFP::enable_filter(bool enable)
44
33
// ----------------------------------------------------------------------------
45
34
// Setup of the external filter sampling parameters.
46
35
// ----------------------------------------------------------------------------
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()
36
void ExternalFilterFP::set_clock_frequency(float clock_frequency)
61
38
// Low-pass: R = 10kOhm, C = 1000pF; w0l = 1/RC = 1/(1e4*1e-9) = 100000
62
39
// High-pass: R = 1kOhm, C = 10uF; w0h = 1/RC = 1/(1e3*1e-5) = 100
63
40
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.
41
w0lp = pass_frequency * 2.f * static_cast<float>(M_PI) / clock_frequency;
85
44
// ----------------------------------------------------------------------------