libsidplayfp  2.0.2
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 
38 class sidbuilder;
39 
40 namespace libsidplayfp
41 {
42 
46 class sidemu : public c64sid
47 {
48 public:
52  enum
53  {
54  OUTPUTBUFFERSIZE = 5000
55  };
56 
57 private:
58  sidbuilder* const m_builder;
59 
60 protected:
61  static const char ERR_UNSUPPORTED_FREQ[];
62  static const char ERR_INVALID_SAMPLING[];
63  static const char ERR_INVALID_CHIP[];
64 
65 protected:
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 
81 public:
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
libsidplayfp::sidemu
Definition: sidemu.h:47
libsidplayfp::sidemu::unlock
virtual void unlock()
Definition: sidemu.cpp:43
libsidplayfp::sidemu::buffer
short * buffer() const
Definition: sidemu.h:150
libsidplayfp::sidemu::m_bufferpos
int m_bufferpos
Current position in buffer.
Definition: sidemu.h:74
SidConfig::sampling_method_t
sampling_method_t
Sampling method.
Definition: SidConfig.h:75
libsidplayfp::EventScheduler
Definition: EventScheduler.h:62
libsidplayfp::sidemu::bufferpos
int bufferpos() const
Definition: sidemu.h:140
libsidplayfp::sidemu::clock
virtual void clock()=0
libsidplayfp::sidemu::sampling
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
libsidplayfp::sidemu::model
virtual void model(SidConfig::sid_model_t model, bool digiboost)=0
libsidplayfp::sidemu::error
const char * error() const
Definition: sidemu.h:133
libsidplayfp::sidemu::bufferpos
void bufferpos(int pos)
Definition: sidemu.h:145
libsidplayfp::sidemu::voice
virtual void voice(unsigned int num, bool mute)=0
sidbuilder
Definition: sidbuilder.h:41
libsidplayfp::sidemu::m_buffer
short * m_buffer
The sample buffer.
Definition: sidemu.h:71
libsidplayfp::sidemu::lock
virtual bool lock(EventScheduler *scheduler)
Definition: sidemu.cpp:32
libsidplayfp::c64sid
Definition: c64sid.h:37
SidConfig::sid_model_t
sid_model_t
SID chip model.
Definition: SidConfig.h:51