libsidplayfp  0.3.5
WaveformCalculator.h
1 /*
2  * This file is part of reSID, a MOS6581 SID emulator engine.
3  * Copyright (C) 2004 Dag Lem <resid@nimrod.no>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * @author Ken Händel
20  *
21  */
22 
23 #ifndef WAVEFORMCALCULATOR_h
24 #define WAVEFORMCALCULATOR_h
25 
26 #include "siddefs-fp.h"
27 #include "array.h"
28 
29 #include <map>
30 
31 
32 namespace reSIDfp
33 {
34 
35 typedef struct {
36  float bias;
37  float pulsestrength;
38  float topbit;
39  float distance;
40  float stmix;
42 
49 
50 private:
51  std::map<const CombinedWaveformConfig*, array<short> > CACHE;
52 
53  /*
54  * the "bits wrong" figures below are not directly comparable. 0 bits are very easy to predict, and waveforms that are mostly zero have low scores. More comparable scores would be found by
55  * dividing with the count of 1-bits, or something.
56  */
57  static const CombinedWaveformConfig config[2][4];
58 
68  short calculateCombinedWaveform(CombinedWaveformConfig config, const int waveform, const int accumulator) const;
69 
71 
72 public:
73  static WaveformCalculator* getInstance();
74 
92  array<short>* buildTable(const ChipModel model);
93 };
94 
95 } // namespace reSIDfp
96 
97 #endif