libsidplayfp 2.3.0
FilterModelConfig6581.h
1/*
2 * This file is part of libsidplayfp, a SID player engine.
3 *
4 * Copyright 2011-2020 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 FILTERMODELCONFIG6581_H
24#define FILTERMODELCONFIG6581_H
25
26#include <memory>
27
28#include "Dac.h"
29#include "Spline.h"
30
31#include "sidcxx11.h"
32
33namespace reSIDfp
34{
35
36class Integrator6581;
37
42{
43private:
44 static const unsigned int DAC_BITS = 11;
45
46private:
47 static std::unique_ptr<FilterModelConfig6581> instance;
48 // This allows access to the private constructor
49#ifdef HAVE_CXX11
50 friend std::unique_ptr<FilterModelConfig6581>::deleter_type;
51#else
52 friend class std::auto_ptr<FilterModelConfig6581>;
53#endif
54
55 const double voice_voltage_range;
56 const double voice_DC_voltage;
57
59 const double C;
60
62
63 const double Vdd;
64 const double Vth;
65 const double Ut;
66 const double uCox;
67 const double WL_vcr;
68 const double WL_snake;
69 const double Vddt;
71
73
74 const double dac_zero;
75 const double dac_scale;
77
78 // Derived stuff
79 const double vmin, vmax;
80 const double denorm, norm;
81
83 const double N16;
84
86
87 unsigned short* mixer[8];
88 unsigned short* summer[5];
89 unsigned short* gain[16];
91
93 Dac dac;
94
96
97 unsigned short vcr_Vg[1 << 16];
98 unsigned short vcr_n_Ids_term[1 << 16];
100
102 unsigned short opamp_rev[1 << 16];
103
104private:
105 double getDacZero(double adjustment) const { return dac_zero + (1. - adjustment); }
106
109
110public:
111 static FilterModelConfig6581* getInstance();
112
117 int getVoiceScaleS11() const { return static_cast<int>((norm * ((1 << 11) - 1)) * voice_voltage_range); }
118
122 int getVoiceDC() const { return static_cast<int>(N16 * (voice_DC_voltage - vmin)); }
123
124 unsigned short** getGain() { return gain; }
125
126 unsigned short** getSummer() { return summer; }
127
128 unsigned short** getMixer() { return mixer; }
129
138 unsigned short* getDAC(double adjustment) const;
139
145 std::unique_ptr<Integrator6581> buildIntegrator();
146};
147
148} // namespace reSIDfp
149
150#endif
Definition Dac.h:76
Definition FilterModelConfig6581.h:42
int getVoiceDC() const
Definition FilterModelConfig6581.h:122
unsigned short * getDAC(double adjustment) const
Definition FilterModelConfig6581.cpp:277
int getVoiceScaleS11() const
Definition FilterModelConfig6581.h:117
std::unique_ptr< Integrator6581 > buildIntegrator()
Definition FilterModelConfig6581.cpp:294