libsidplayfp 2.15.0
Integrator8580.h
1/*
2 * This file is part of libsidplayfp, a SID player engine.
3 *
4 * Copyright 2011-2023 Leandro Nini <drfiemost@users.sourceforge.net>
5 * Copyright 2007-2010 Antti Lankila
6 * Copyright 2004, 2010 Dag Lem <resid@nimrod.no>
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 INTEGRATOR8580_H
24#define INTEGRATOR8580_H
25
26#include "Integrator.h"
27#include "FilterModelConfig8580.h"
28
29#include <stdint.h>
30#include <cassert>
31
32#include "siddefs-fp.h"
33
34namespace reSIDfp
35{
36
56{
57private:
58 unsigned short nVgt;
59 unsigned short n_dac;
60
62
63public:
65 fmc(fmc)
66 {
67 setV(1.5);
68 }
69
73 void setFc(double wl)
74 {
75 // Normalized current factor, 1 cycle at 1MHz.
76 n_dac = fmc.getNormalizedCurrentFactor<17>(wl);
77 }
78
82 void setV(double v)
83 {
84 // Gate voltage is controlled by the switched capacitor voltage divider
85 // Ua = Ue * v = 4.75v 1<v<2
86 assert(v > 1.0 && v < 2.0);
87 const double Vg = fmc.getVref() * v;
88 const double Vgt = Vg - fmc.getVth();
89
90 // Vg - Vth, normalized so that translated values can be subtracted:
91 // Vgt - x = (Vgt - t) - (x - t)
92 nVgt = fmc.getNormalizedValue(Vgt);
93 }
94
95 int solve(int vi) const override;
96};
97
98} // namespace reSIDfp
99
100#endif
Definition FilterModelConfig8580.h:41
Definition Integrator8580.h:56
void setFc(double wl)
Definition Integrator8580.h:73
void setV(double v)
Definition Integrator8580.h:82
Definition Integrator.h:30