libsidplayfp 1.8.8
player.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 * 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 <stdint.h>
28#include <cstdio>
29
30#include "siddefs.h"
31#include "SidConfig.h"
32#include "SidTuneInfo.h"
33#include "SidInfoImpl.h"
34#include "sidrandom.h"
35#include "mixer.h"
36#include "event.h"
37#include "c64/c64.h"
38
39#ifdef HAVE_CONFIG_H
40# include "config.h"
41#endif
42
43#ifdef PC64_TESTSUITE
44# include <string>
45#endif
46
47class SidTune;
48class SidInfo;
49class sidbuilder;
50
51
52SIDPLAYFP_NAMESPACE_START
53
54class Player
55#ifdef PC64_TESTSUITE
56 : public testEnv
57#endif
58{
59private:
60 class configError
61 {
62 private:
63 const char* m_msg;
64
65 public:
66 configError(const char* msg) : m_msg(msg) {}
67 const char* message() const { return m_msg; }
68 };
69
70private:
71 c64 m_c64;
72
73 Mixer m_mixer;
74
75 SidTune *m_tune;
76 SidInfoImpl m_info;
77
78 // User Configuration Settings
79 SidConfig m_cfg;
80
81 const char *m_errorString;
82
83 volatile bool m_isPlaying;
84
85 sidrandom m_rand;
86
88 uint8_t videoSwitch;
89
90private:
91 c64::model_t c64model(SidConfig::c64_model_t defaultModel, bool forced);
92 void initialise();
93 void sidRelease();
94 void sidCreate(sidbuilder *builder, SidConfig::sid_model_t defaultModel,
95 bool forced, const std::vector<unsigned int> &extraSidAddresses);
96 void sidParams(double cpuFreq, int frequency,
97 SidConfig::sampling_method_t sampling, bool fastSampling);
98
99 static SidConfig::sid_model_t getModel (SidTuneInfo::model_t sidModel, SidConfig::sid_model_t defaultModel, bool forced);
100
101#ifdef PC64_TESTSUITE
102 void load(const char *file);
103#endif
104
105public:
106 Player();
107 ~Player() {}
108
109 const SidConfig &config() const { return m_cfg; }
110
111 const SidInfo &info() const { return m_info; }
112
113 bool config(const SidConfig &cfg);
114
115 bool fastForward(unsigned int percent);
116
117 bool load(SidTune *tune);
118
119 double cpuFreq() const { return m_c64.getMainCpuSpeed(); }
120
121 uint_least32_t play(short *buffer, uint_least32_t samples);
122
123 bool isPlaying() const { return m_isPlaying; }
124
125 void stop();
126
127 uint_least32_t time() const { return (uint_least32_t)(m_c64.getEventScheduler().getTime(EVENT_CLOCK_PHI1) / cpuFreq()); }
128
129 void debug(const bool enable, FILE *out) { m_c64.debug (enable, out); }
130
131 void mute(unsigned int sidNum, unsigned int voice, bool enable);
132
133 const char *error() const { return m_errorString; }
134
135 void setRoms(const uint8_t* kernal, const uint8_t* basic, const uint8_t* character);
136
137 EventContext *getEventScheduler() { return m_c64.getEventScheduler(); }
138
139 uint_least16_t getCia1TimerA() const { return m_c64.getCia1TimerA(); }
140};
141
142SIDPLAYFP_NAMESPACE_STOP
143
144#endif // PLAYER_H
Definition: event.h:108
event_clock_t getTime(event_phase_t phase) const
Definition: EventScheduler.h:129
Definition: mixer.h:38
Definition: player.h:58
Definition: SidConfig.h:40
Definition: SidInfoImpl.h:50
Definition: SidInfo.h:32
Definition: SidTune.h:39
Definition: c64.h:78
model_t
Definition: c64.h:81
double getMainCpuSpeed() const
Definition: c64.h:244
EventScheduler * getEventScheduler()
Definition: c64.h:220
Definition: sidbuilder.h:38
Definition: sidrandom.h:28