libsidplayfp 2.4.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:
52 enum
53 {
54 OUTPUTBUFFERSIZE = 5000
55 };
56
57private:
58 sidbuilder* const m_builder;
59
60protected:
61 static const char ERR_UNSUPPORTED_FREQ[];
62 static const char ERR_INVALID_SAMPLING[];
63 static const char ERR_INVALID_CHIP[];
64
65protected:
66 EventScheduler *eventScheduler;
67
68 event_clock_t m_accessClk;
69
71 short *m_buffer;
72
75
76 bool m_status;
77 bool isLocked;
78
79 std::string m_error;
80
81public:
82 sidemu(sidbuilder *builder) :
83 m_builder(builder),
84 eventScheduler(nullptr),
85 m_buffer(nullptr),
86 m_bufferpos(0),
87 m_status(true),
88 isLocked(false),
89 m_error("N/A") {}
90 virtual ~sidemu() {}
91
95 virtual void clock() = 0;
96
100 virtual bool lock(EventScheduler *scheduler);
101
105 virtual void unlock();
106
107 // Standard SID functions
108
112 virtual void voice(unsigned int num, bool mute) = 0;
113
117 virtual void model(SidConfig::sid_model_t model, bool digiboost) = 0;
118
127 virtual void sampling(float systemfreq SID_UNUSED, float outputfreq SID_UNUSED,
128 SidConfig::sampling_method_t method SID_UNUSED, bool fast SID_UNUSED) {}
129
133 const char* error() const { return m_error.c_str(); }
134
135 sidbuilder* builder() const { return m_builder; }
136
140 int bufferpos() const { return m_bufferpos; }
141
145 void bufferpos(int pos) { m_bufferpos = pos; }
146
150 short *buffer() const { return m_buffer; }
151};
152
153}
154
155#endif // SIDEMU_H
sid_model_t
SID chip model.
Definition: SidConfig.h:51
sampling_method_t
Sampling method.
Definition: SidConfig.h:76
Definition: EventScheduler.h:62
Definition: c64sid.h:38
Definition: sidemu.h:47
short * m_buffer
The sample buffer.
Definition: sidemu.h:71
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:74
const char * error() const
Definition: sidemu.h:133
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:127
int bufferpos() const
Definition: sidemu.h:140
void bufferpos(int pos)
Definition: sidemu.h:145
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:150
Definition: sidbuilder.h:41