~ubuntu-branches/ubuntu/quantal/vice/quantal

« 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: 2009-03-31 00:37:15 UTC
  • mfrom: (1.1.7 upstream) (9.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20090331003715-i5yisvcfv7mgz3eh
Tags: 2.1.dfsg-1
* New major upstream release (closes: #495937).
* Add desktop files (closes: #501181).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//  ---------------------------------------------------------------------------
 
2
//  This file is part of reSID, a MOS6581 SID emulator engine.
 
3
//  Copyright (C) 2004  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 __EXTFILT_CC__
 
21
#include "extfilt.h"
 
22
 
 
23
// ----------------------------------------------------------------------------
 
24
// Constructor.
 
25
// ----------------------------------------------------------------------------
 
26
ExternalFilterFP::ExternalFilterFP()
 
27
{
 
28
  reset();
 
29
  enable_filter(true);
 
30
  set_chip_model(MOS6581FP);
 
31
  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
}
 
43
 
 
44
// ----------------------------------------------------------------------------
 
45
// Setup of the external filter sampling parameters.
 
46
// ----------------------------------------------------------------------------
 
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()
 
60
{
 
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;
 
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
 
 
84
 
 
85
// ----------------------------------------------------------------------------
 
86
// SID reset.
 
87
// ----------------------------------------------------------------------------
 
88
void ExternalFilterFP::reset()
 
89
{
 
90
  // State of filter.
 
91
  Vlp = 0;
 
92
  Vhp = 0;
 
93
  Vo = 0;
 
94
}