libsidplayfp  1.1.0
OpAmp.h
1 /*
2  * This file is part of libsidplayfp, a SID player engine.
3  *
4  * Copyright 2011-2013 Leandro Nini <drfiemost@users.sourceforge.net>
5  * Copyright 2007-2010 Antti Lankila
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  */
21 
22 #ifndef OPAMP_H
23 #define OPAMP_H
24 
25 #include "Spline.h"
26 
27 namespace reSIDfp
28 {
29 
38 class OpAmp
39 {
40 private:
41  static const double EPSILON;
42 
44  double x;
45 
46  const double Vddt, vmin, vmax;
47 
48  Spline* opamp;
49 
50  double out[2];
51 
52 public:
60  OpAmp(const double opamp[][2], int opamplength, double Vddt) :
61  x(0.),
62  Vddt(Vddt),
63  vmin(opamp[0][0]),
64  vmax(opamp[opamplength - 1][0]),
65  opamp(new Spline(opamp, opamplength)) {}
66 
67  ~OpAmp() { delete opamp; }
68 
69  void reset()
70  {
71  x = vmin;
72  }
73 
81  double solve(double n, double vi);
82 };
83 
84 } // namespace reSIDfp
85 
86 #endif