~ubuntu-branches/ubuntu/precise/vice/precise

« back to all changes in this revision

Viewing changes to src/resid-fp/extfilt.cc

  • Committer: Bazaar Package Importer
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2010-02-11 18:30:16 UTC
  • mfrom: (1.1.8 upstream) (9.2.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100211183016-f6n8usn3tzp0u6dp
Tags: 2.2.dfsg-1
* New upstream release, C64 DTV is included so update package description
  and add it to the menu.
* Drop patch fixing build failure with gcc-4.4 , applied upstream.
* Fix some lintian problems and clean up debian/rules .

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
18
//  ---------------------------------------------------------------------------
19
19
 
20
 
#define __EXTFILT_CC__
21
20
#include "extfilt.h"
 
21
 
 
22
const float pass_frequency = 15915.6f;
22
23
 
23
24
// ----------------------------------------------------------------------------
24
25
// Constructor.
26
27
ExternalFilterFP::ExternalFilterFP()
27
28
{
28
29
  reset();
29
 
  enable_filter(true);
30
 
  set_chip_model(MOS6581FP);
31
30
  set_clock_frequency(1e6f);
32
 
  set_sampling_parameter(15915.6f);
33
 
}
34
 
 
35
 
 
36
 
// ----------------------------------------------------------------------------
37
 
// Enable filter.
38
 
// ----------------------------------------------------------------------------
39
 
void ExternalFilterFP::enable_filter(bool enable)
40
 
{
41
 
  enabled = enable;
42
31
}
43
32
 
44
33
// ----------------------------------------------------------------------------
45
34
// Setup of the external filter sampling parameters.
46
35
// ----------------------------------------------------------------------------
47
 
void ExternalFilterFP::set_clock_frequency(float clock)
48
 
{
49
 
  clock_frequency = clock;
50
 
  _set_sampling_parameter();
51
 
}
52
 
 
53
 
void ExternalFilterFP::set_sampling_parameter(float freq)
54
 
{
55
 
  pass_frequency = freq;
56
 
  _set_sampling_parameter();
57
 
}
58
 
 
59
 
void ExternalFilterFP::_set_sampling_parameter()
 
36
void ExternalFilterFP::set_clock_frequency(float clock_frequency)
60
37
{
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;
65
 
}
66
 
 
67
 
// ----------------------------------------------------------------------------
68
 
// Set chip model.
69
 
// ----------------------------------------------------------------------------
70
 
void ExternalFilterFP::set_chip_model(chip_model model)
71
 
{
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
75
 
    //  - extin offset...
76
 
    mixer_DC = (-0x600 + 0x800) * 0xff * 3 - 0x20000;
77
 
  }
78
 
  else {
79
 
    // No DC offsets in the MOS8580.
80
 
    mixer_DC = 0;
81
 
  }
82
 
}
83
 
 
 
41
  w0lp = pass_frequency * 2.f * static_cast<float>(M_PI) / clock_frequency;
 
42
}
84
43
 
85
44
// ----------------------------------------------------------------------------
86
45
// SID reset.
90
49
  // State of filter.
91
50
  Vlp = 0;
92
51
  Vhp = 0;
93
 
  Vo = 0;
94
52
}