libresidfp 0.9.3
FilterModelConfig6581.h
1/*
2 * This file is part of libsidplayfp, a SID player engine.
3 *
4 * Copyright 2011-2026 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 "FilterModelConfig.h"
27
28#include <memory>
29
30#include "Dac.h"
31
32#include "siddefs-fp.h"
33
34namespace reSIDfp
35{
36
37class Integrator6581;
38
43{
44private:
45 static std::unique_ptr<FilterModelConfig6581> instance;
46 // This allows access to the private constructor
47 friend std::unique_ptr<FilterModelConfig6581>::deleter_type;
48
49private:
50 static constexpr unsigned int DAC_BITS = 11;
51
55 static constexpr double VOLTAGE_SKEW = 1.015;
56
58
59 const double WL_vcr;
60 const double WL_snake;
62
64
65 const double dac_zero;
66 const double dac_scale;
68
70 Dac dac;
71
73
74 unsigned short vcr_nVg[1 << 16];
75 double vcr_n_Ids_term[1 << 16];
77
78 double vcr_mult;
79 bool m_oldCaps;
80
81 // Voice DC offset LUT
82 double voiceDC[256];
83
84private:
85 double getDacZero(double adjustment) const { return dac_zero + 3. * adjustment - 1.; }
86
87 void updateParams();
88
90 ~FilterModelConfig6581() = default;
91
92protected:
97 inline double getVoiceDC(unsigned int env) const override
98 {
99 return voiceDC[env];
100 }
101
102public:
103 static FilterModelConfig6581* getInstance();
104
105 void setFilterRange(double adjustment);
106
107 void enableOldCaps(bool enable);
108
117 unsigned short* getDAC(double adjustment) const;
118
119 inline double getWL_snake() const { return WL_snake; }
120
121 inline unsigned short getVcr_nVg(int i) const { return vcr_nVg[i]; }
122 inline unsigned short getVcr_n_Ids_term(int i) const
123 {
124 return to_ushort(vcr_n_Ids_term[i] * vcr_mult);
125 }
126 // only used if SLOPE_FACTOR is defined
127 static inline constexpr double getUt() { return Ut; }
128 inline double getN16() const { return N16; }
129};
130
131} // namespace reSIDfp
132
133#endif
Definition Dac.h:76
Definition FilterModelConfig6581.h:43
double getVoiceDC(unsigned int env) const override
Definition FilterModelConfig6581.h:97
unsigned short * getDAC(double adjustment) const
Definition FilterModelConfig6581.cpp:301
Definition FilterModelConfig.h:40
const double N16
Fixed point scaling for 16 bit op-amp output.
Definition FilterModelConfig.h:119