libsidplayfp 2.8.0
sidemu.h
1/*
2 * This file is part of libsidplayfp, a SID player engine.
3 *
4 * Copyright 2011-2019 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#ifndef SIDEMU_H
24#define SIDEMU_H
25
26#include <string>
27
28#include "sidplayfp/SidConfig.h"
29#include "sidplayfp/siddefs.h"
30#include "Event.h"
31#include "EventScheduler.h"
32
33#include "c64/c64sid.h"
34
35#include "sidcxx11.h"
36
37
38class sidbuilder;
39
40namespace libsidplayfp
41{
42
46class sidemu : public c64sid
47{
48public:
50 static constexpr unsigned int OUTPUTBUFFERSIZE = 5000;
51
52private:
53 sidbuilder* const m_builder;
54
55protected:
56 static const char ERR_UNSUPPORTED_FREQ[];
57 static const char ERR_INVALID_SAMPLING[];
58 static const char ERR_INVALID_CHIP[];
59
60protected:
61 EventScheduler *eventScheduler;
62
63 event_clock_t m_accessClk;
64
66 short *m_buffer;
67
70
71 bool m_status;
72 bool isLocked;
73
74 std::string m_error;
75
76public:
77 sidemu(sidbuilder *builder) :
78 m_builder(builder),
79 eventScheduler(nullptr),
80 m_buffer(nullptr),
81 m_bufferpos(0),
82 m_status(true),
83 isLocked(false),
84 m_error("N/A") {}
85 ~sidemu() override = default;
86
90 virtual void clock() = 0;
91
95 virtual bool lock(EventScheduler *scheduler);
96
100 virtual void unlock();
101
102 // Standard SID functions
103
107 virtual void voice(unsigned int num, bool mute) = 0;
108
112 virtual void model(SidConfig::sid_model_t model, bool digiboost) = 0;
113
122 virtual void sampling(float systemfreq SID_UNUSED, float outputfreq SID_UNUSED,
123 SidConfig::sampling_method_t method SID_UNUSED, bool fast SID_UNUSED) {}
124
128 const char* error() const { return m_error.c_str(); }
129
130 sidbuilder* builder() const { return m_builder; }
131
135 int bufferpos() const { return m_bufferpos; }
136
140 void bufferpos(int pos) { m_bufferpos = pos; }
141
145 short *buffer() const { return m_buffer; }
146};
147
148}
149
150#endif // SIDEMU_H
sid_model_t
SID chip model.
Definition SidConfig.h:51
sampling_method_t
Sampling method.
Definition SidConfig.h:84
Definition EventScheduler.h:62
Definition c64sid.h:38
Definition sidemu.h:47
short * m_buffer
The sample buffer.
Definition sidemu.h:66
virtual bool lock(EventScheduler *scheduler)
Definition sidemu.cpp:32
virtual void unlock()
Definition sidemu.cpp:43
virtual void clock()=0
int m_bufferpos
Current position in buffer.
Definition sidemu.h:69
const char * error() const
Definition sidemu.h:128
virtual void sampling(float systemfreq SID_UNUSED, float outputfreq SID_UNUSED, SidConfig::sampling_method_t method SID_UNUSED, bool fast SID_UNUSED)
Definition sidemu.h:122
int bufferpos() const
Definition sidemu.h:135
void bufferpos(int pos)
Definition sidemu.h:140
static constexpr unsigned int OUTPUTBUFFERSIZE
Buffer size. 5000 is roughly 5 ms at 96 kHz.
Definition sidemu.h:50
virtual void voice(unsigned int num, bool mute)=0
virtual void model(SidConfig::sid_model_t model, bool digiboost)=0
short * buffer() const
Definition sidemu.h:145
Definition sidbuilder.h:41