libsidplayfp 2.9.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 = nullptr;
62
63 event_clock_t m_accessClk = 0;
64
66 short *m_buffer = nullptr;
67
69 int m_bufferpos = 0;
70
71 bool m_status = true;
72 bool isLocked = false;
73
74 std::string m_error;
75
76public:
77 sidemu(sidbuilder *builder) :
78 m_builder(builder),
79 m_error("N/A") {}
80 ~sidemu() override = default;
81
85 virtual void clock() = 0;
86
90 virtual bool lock(EventScheduler *scheduler);
91
95 virtual void unlock();
96
97 // Standard SID functions
98
102 virtual void voice(unsigned int num, bool mute) = 0;
103
107 virtual void model(SidConfig::sid_model_t model, bool digiboost) = 0;
108
117 virtual void sampling(float systemfreq SID_UNUSED, float outputfreq SID_UNUSED,
118 SidConfig::sampling_method_t method SID_UNUSED, bool fast SID_UNUSED) {}
119
123 const char* error() const { return m_error.c_str(); }
124
125 sidbuilder* builder() const { return m_builder; }
126
130 int bufferpos() const { return m_bufferpos; }
131
135 void bufferpos(int pos) { m_bufferpos = pos; }
136
140 short *buffer() const { return m_buffer; }
141};
142
143}
144
145#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:123
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:117
int bufferpos() const
Definition sidemu.h:130
void bufferpos(int pos)
Definition sidemu.h:135
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:140
Definition sidbuilder.h:41