libsidplayfp  1.3.0
FilterModelConfig.h
1 /*
2  * This file is part of libsidplayfp, a SID player engine.
3  *
4  * Copyright 2011-2013 Leandro Nini <drfiemost@users.sourceforge.net>
5  * Copyright 2007-2010 Antti Lankila
6  * Copyright 2004,2010 Dag Lem
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef FILTERMODELCONFIG_H
24 #define FILTERMODELCONFIG_H
25 
26 #include <memory>
27 
28 namespace reSIDfp
29 {
30 
31 class Integrator;
32 
37 {
38 private:
39  static const unsigned int OPAMP_SIZE = 33;
40  static const unsigned int DAC_BITS = 11;
41 
42 private:
43  static std::auto_ptr<FilterModelConfig> instance;
44  // This allows access to the private constructor
45  friend class std::auto_ptr<FilterModelConfig>;
46 
47  static const double opamp_voltage[OPAMP_SIZE][2];
48 
49  const double voice_voltage_range;
50  const double voice_DC_voltage;
51 
53  const double C;
54 
56 
57  const double Vdd;
58  const double Vth;
59  const double Ut;
60  const double k;
61  const double uCox;
62  const double WL_vcr;
63  const double WL_snake;
64 
65 
67 
68  const double dac_zero;
69  const double dac_scale;
71 
72  // Derived stuff
73  const double vmin, norm;
74 
76 
77  unsigned short* mixer[8];
78  unsigned short* summer[5];
79  unsigned short* gain[16];
81 
83  double dac[DAC_BITS];
84 
86 
87  unsigned short vcr_kVg[1 << 16];
88  unsigned short vcr_n_Ids_term[1 << 16];
90 
92  int opamp_rev[1 << 16];
93 
94 private:
95  double getDacZero(double adjustment) const { return dac_zero - (adjustment - 0.5) * 2.; }
96 
97  FilterModelConfig();
98  ~FilterModelConfig();
99 
100 public:
101  static FilterModelConfig* getInstance();
102 
107  int getVoiceScaleS14() const { return (int)((norm * ((1L << 14) - 1)) * voice_voltage_range); }
108 
112  int getVoiceDC() const { return (int)((norm * ((1L << 16) - 1)) * (voice_DC_voltage - vmin)); }
113 
114  unsigned short** getGain() { return gain; }
115 
116  unsigned short** getSummer() { return summer; }
117 
118  unsigned short** getMixer() { return mixer; }
119 
128  unsigned int* getDAC(double adjustment) const;
129 
130  Integrator* buildIntegrator();
131 };
132 
133 } // namespace reSIDfp
134 
135 #endif
int getVoiceScaleS14() const
Definition: FilterModelConfig.h:107
Definition: FilterModelConfig.h:36
unsigned int * getDAC(double adjustment) const
Definition: FilterModelConfig.cpp:271
int getVoiceDC() const
Definition: FilterModelConfig.h:112