-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathplayer.h
More file actions
285 lines (239 loc) · 6.32 KB
/
Copy pathplayer.h
File metadata and controls
285 lines (239 loc) · 6.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
/*
* This file is part of sidplayfp, a console SID player.
*
* Copyright 2011-2024 Leandro Nini
* Copyright 2000-2001 Simon White
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef PLAYER_H
#define PLAYER_H
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <sidplayfp/SidTune.h>
#include <sidplayfp/sidplayfp.h>
#include <sidplayfp/SidConfig.h>
#include <sidplayfp/SidTuneInfo.h>
#include <sidplayfp/SidDatabase.h>
#include "audio/IAudio.h"
#include "audio/AudioConfig.h"
#include "audio/null/null.h"
#include "IniConfig.h"
#include "sidlib_features.h"
#include <string>
#include <bitset>
#include <thread>
#include <atomic>
#ifdef HAVE_TSID
# if HAVE_TSID > 1
# include <tsid2/tsid2.h>
# define TSID TSID2
# else
# include <tsid/tsid.h>
# endif
#endif
enum class color_t
{
black,
red,
green,
yellow,
blue,
magenta,
cyan,
white
};
enum class table_t
{
start,
middle,
separator,
end
};
typedef enum
{
playerError = 0,
playerRunning,
playerPaused,
playerStopped,
playerRestart,
playerExit,
playerFast = 128,
playerFastRestart = playerRestart | playerFast,
playerFastExit = playerExit | playerFast
} player_state_t;
typedef enum
{
/* Same as EMU_DEFAULT except no soundcard.
Still allows wav generation */
EMU_NONE = 0,
/* The following require a soundcard */
EMU_DEFAULT,
EMU_RESIDFP,
EMU_RESID,
/* The following should disable the soundcard */
EMU_HARDSID,
EMU_EXSID,
EMU_SIDSTATION,
EMU_COMMODORE,
EMU_SIDSYN,
EMU_END
} SIDEMUS;
enum class output_t
{
/* Define possible output sources */
NONE,
/* Hardware */
SOUNDCARD,
/* File creation support */
WAV,
AU,
END
};
// Songlength DB.
enum class sldb_t
{
NONE,
TXT,
MD5
};
// Grouped global variables
class ConsolePlayer
{
private:
#ifdef HAVE_SIDPLAYFP_BUILDERS_RESIDFP_H
static const char RESIDFP_ID[];
#endif
#ifdef HAVE_SIDPLAYFP_BUILDERS_RESID_H
static const char RESID_ID[];
#endif
#ifdef HAVE_SIDPLAYFP_BUILDERS_HARDSID_H
static const char HARDSID_ID[];
#endif
#ifdef HAVE_SIDPLAYFP_BUILDERS_EXSID_H
static const char EXSID_ID[];
#endif
#ifdef HAVE_TSID
TSID m_tsid;
#endif
const char* const m_name;
sidplayfp m_engine;
SidConfig m_engCfg;
SidTune m_tune;
std::atomic<player_state_t> m_state;
const char* m_outfile;
std::string m_filename;
IniConfig m_iniCfg;
SidDatabase m_database;
double m_fcurve;
#ifdef FEAT_FILTER_RANGE
double m_frange;
#endif
#ifdef FEAT_CW_STRENGTH
SidConfig::sid_cw_t m_combinedWaveformsStrength;
#endif
uint8_t m_registers[3][32];
uint16_t* m_freqTable;
// Display parameters
uint_least8_t m_quietLevel;
uint_least8_t m_verboseLevel;
sldb_t songlengthDB;
bool m_cpudebug;
bool m_autofilter;
std::bitset<9> m_mute_channel;
#ifdef FEAT_SAMPLE_MUTE
std::bitset<3> m_mute_samples;
#endif
int m_channels;
int m_precision;
int m_buffer_size;
std::thread *m_thread = nullptr;
struct m_filter_t
{
// Filter parameter for reSID
double bias;
// Filter parameters for reSIDfp
double filterCurve6581;
#ifdef FEAT_FILTER_RANGE
double filterRange6581;
#endif
double filterCurve8580;
bool enabled;
} m_filter;
struct m_driver_t
{
output_t output; // Selected output type
SIDEMUS sid; // Sid emulation
bool file; // File based driver
bool info; // File metadata
AudioConfig cfg;
IAudio* selected; // Selected Output Driver
IAudio* device; // HW/File Driver
Audio_Null null; // Used for everything
} m_driver;
struct m_timer_t
{ // secs
uint_least32_t start;
std::atomic<uint_least32_t> current;
uint_least32_t stop;
uint_least32_t length;
bool valid;
bool starting;
} m_timer;
struct m_track_t
{
uint_least16_t first;
uint_least16_t selected;
uint_least16_t songs;
bool loop;
bool single;
} m_track;
struct m_speed_t
{
uint_least8_t current;
uint_least8_t max;
} m_speed;
private:
// Console
void consoleColour (color_t colour, bool bold);
void consoleTable (table_t table);
void consoleRestore (void);
// Command line args
void displayArgs (const char *arg = nullptr);
bool createOutput (output_t driver, const SidTuneInfo *tuneInfo);
bool createSidEmu (SIDEMUS emu, const SidTuneInfo *tuneInfo);
void decodeKeys (void);
void updateDisplay();
void emuflush (void);
void menu (void);
void refreshRegDump ();
uint_least32_t getBufSize();
const char *getNote(uint16_t freq);
std::string getFileName(const SidTuneInfo *tuneInfo, const char* ext);
inline bool tryOpenTune(const char *hvscBase);
inline bool tryOpenDatabase(const char *hvscBase, const char *suffix);
public:
ConsolePlayer (const char * const name);
virtual ~ConsolePlayer() = default;
void displayError(const char *error);
int args (int argc, const char *argv[]);
bool open (void);
void close (void);
bool play (void);
void stop (void);
player_state_t state (void) const { return m_state; }
};
#endif // PLAYER_H