libsidplayfp  2.4.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 "sidcxx14.h"
33 
34 namespace reSIDfp
35 {
36 
37 class Integrator6581;
38 
43 {
44 private:
45  static const unsigned int DAC_BITS = 11;
46 
47 private:
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  unsigned short vcr_n_Ids_term[1 << 16];
76 
77 private:
78  double getDacZero(double adjustment) const { return dac_zero + (1. - adjustment); }
79 
81  ~FilterModelConfig6581() DEFAULT;
82 
83 public:
84  static FilterModelConfig6581* getInstance();
85 
94  unsigned short* getDAC(double adjustment) const;
95 
101  std::unique_ptr<Integrator6581> buildIntegrator();
102 
103  inline unsigned short getVcr_nVg(int i) const { return vcr_nVg[i]; }
104  inline unsigned short getVcr_n_Ids_term(int i) const { return vcr_n_Ids_term[i]; }
105  // only used if SLOPE_FACTOR is defined
106  inline double getUt() const { return Ut; }
107  inline double getN16() const { return N16; }
108 };
109 
110 } // namespace reSIDfp
111 
112 #endif
Definition: Dac.h:76
Definition: FilterModelConfig6581.h:43
unsigned short * getDAC(double adjustment) const
Definition: FilterModelConfig6581.cpp:243
std::unique_ptr< Integrator6581 > buildIntegrator()
Definition: FilterModelConfig6581.cpp:258
Definition: FilterModelConfig.h:37
const double Ut
Thermal voltage: Ut = kT/q = 8.61734315e-5*T ~ 26mV.
Definition: FilterModelConfig.h:49
const double N16
Fixed point scaling for 16 bit op-amp output.
Definition: FilterModelConfig.h:59