libsidplayfp 2.7.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 "FilterModelConfig.h"
27
28#include <memory>
29
30#include "Dac.h"
31
32#include "sidcxx11.h"
33
34namespace reSIDfp
35{
36
37class Integrator6581;
38
43{
44private:
45 static constexpr unsigned int DAC_BITS = 11;
46
47private:
48 static std::unique_ptr<FilterModelConfig6581> instance;
49 // This allows access to the private constructor
50#ifdef HAVE_CXX11
51 friend std::unique_ptr<FilterModelConfig6581>::deleter_type;
52#else
53 friend class std::auto_ptr<FilterModelConfig6581>;
54#endif
55
57
58 const double WL_vcr;
59 const double WL_snake;
61
63
64 const double dac_zero;
65 const double dac_scale;
67
69 Dac dac;
70
72
73 unsigned short vcr_nVg[1 << 16];
74 double vcr_n_Ids_term[1 << 16];
76
77private:
78 double getDacZero(double adjustment) const { return dac_zero + (1. - adjustment); }
79
81 ~FilterModelConfig6581() DEFAULT;
82
83public:
84 static FilterModelConfig6581* getInstance();
85
86 void setFilterRange(double adjustment);
87
96 unsigned short* getDAC(double adjustment) const;
97
103 Integrator* buildIntegrator() override;
104
105 inline unsigned short getVcr_nVg(int i) const { return vcr_nVg[i]; }
106 inline unsigned short getVcr_n_Ids_term(int i) const
107 {
108 const double tmp = vcr_n_Ids_term[i] * uCox;
109 assert(tmp > -0.5 && tmp < 65535.5);
110 return static_cast<unsigned short>(tmp + 0.5);
111 }
112 // only used if SLOPE_FACTOR is defined
113 inline double getUt() const { return Ut; }
114 inline double getN16() const { return N16; }
115};
116
117} // namespace reSIDfp
118
119#endif
Definition Dac.h:76
Definition FilterModelConfig6581.h:43
unsigned short * getDAC(double adjustment) const
Definition FilterModelConfig6581.cpp:272
Integrator * buildIntegrator() override
Definition FilterModelConfig6581.cpp:287
Definition FilterModelConfig.h:40
const double Ut
Thermal voltage: Ut = kT/q = 8.61734315e-5*T ~ 26mV.
Definition FilterModelConfig.h:49
double uCox
Transconductance coefficient: u*Cox.
Definition FilterModelConfig.h:50
const double N16
Fixed point scaling for 16 bit op-amp output.
Definition FilterModelConfig.h:59
Definition Integrator.h:30