libsidplayfp 3.0.0
player.h
1/*
2 * This file is part of libsidplayfp, a SID player engine.
3 *
4 * Copyright 2011-2025 Leandro Nini <drfiemost@users.sourceforge.net>
5 * Copyright 2007-2010 Antti Lankila
6 * Copyright 2000-2001 Simon White
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
24#ifndef PLAYER_H
25#define PLAYER_H
26
27#include <cstdint>
28#include <cstdio>
29
30#include "sidplayfp/siddefs.h"
31#include "sidplayfp/SidConfig.h"
32#include "sidplayfp/SidTuneInfo.h"
33
34#include "SidInfoImpl.h"
35#include "sidrandom.h"
36#include "simpleMixer.h"
37#include "c64/c64.h"
38
39#ifdef HAVE_CONFIG_H
40# include "config.h"
41#endif
42
43#include <atomic>
44#include <memory>
45#include <vector>
46
47class SidTune;
48class SidInfo;
49class sidbuilder;
50
51
52namespace libsidplayfp
53{
54
55class sidemu;
56
57class Player
58{
59private:
61 c64 m_c64;
62
64 SidTune *m_tune;
65
67 SidInfoImpl m_info;
68
70 SidConfig m_cfg;
71
73 std::string m_errorString;
74
75 sidrandom m_rand;
76
77 uint_least32_t m_startTime = 0;
78
80 uint8_t m_videoSwitch;
81
82 std::vector<sidemu*> m_chips;
83
84 std::unique_ptr<SimpleMixer> m_simpleMixer;
85
86private:
93 c64::model_t c64model(SidConfig::c64_model_t defaultModel, bool forced);
94
100 void initialise();
101
105 void sidRelease();
106
112 void sidCreate(sidbuilder *builder, SidConfig::sid_model_t defaultModel, bool digiboost,
113 bool forced, const std::vector<unsigned int> &extraSidAddresses);
114
122 void sidParams(double cpuFreq, int frequency,
124
125 inline void run(unsigned int events);
126
127public:
128 Player();
129 ~Player() = default;
130
131 const SidConfig &config() const { return m_cfg; }
132
133 const SidInfo &info() const { return m_info; }
134
135 bool config(const SidConfig &cfg, bool force=false);
136
137 bool load(SidTune *tune);
138
139 void buffers(short** buffers) const;
140
141 int play(unsigned int cycles);
142
143 uint_least32_t timeMs() const { return m_c64.getTimeMs() - m_startTime; }
144
145 void debug(const bool enable, FILE *out) { m_c64.debug(enable, out); }
146
147 void mute(unsigned int sidNum, unsigned int voice, bool enable);
148
149 void filter(unsigned int sidNum, bool enable);
150
151 const char *error() const { return m_errorString.c_str(); }
152
153 void setKernal(const uint8_t* rom);
154 void setBasic(const uint8_t* rom);
155 void setChargen(const uint8_t* rom);
156
157 uint_least16_t getCia1TimerA() const { return m_c64.getCia1TimerA(); }
158
159 bool getSidStatus(unsigned int sidNum, uint8_t regs[32]);
160
161 unsigned int installedSIDs() const { return m_chips.size(); }
162
163 void initMixer(bool stereo);
164
165 unsigned int mix(short *buffer, unsigned int samples);
166
167 bool reset();
168
169 int getBufSize(unsigned int cycles);
170};
171
172}
173
174#endif // PLAYER_H
Definition SidConfig.h:40
sid_model_t
SID chip model.
Definition SidConfig.h:44
sampling_method_t
Sampling method.
Definition SidConfig.h:77
c64_model_t
C64 model.
Definition SidConfig.h:67
Definition SidInfoImpl.h:51
Definition SidInfo.h:35
Definition SidTune.h:43
Definition c64.h:73
Definition sidemu.h:47
Definition sidrandom.h:31
Definition sidbuilder.h:41