ComSquare
DSP.hpp
Go to the documentation of this file.
1 //
2 // Created by Melefo on 28/01/2020.
3 //
4 
5 #pragma once
6 
7 #include <cstdint>
8 #include <array>
9 #include "Renderer/IRenderer.hpp"
10 #include "Memory/AMemory.hpp"
11 
12 namespace ComSquare::APU
13 {
14  class APU;
15  struct MemoryMap;
16 }
17 
18 namespace ComSquare::APU::DSP
19 {
21  enum Envelope : uint {
30  };
31 
32  struct Master {
34  std::array<uint8_t, 2> volume;
36  bool mute : 1;
38  bool reset : 1;
40  std::array<uint16_t, 2> output;
42  uint8_t unused;
43  };
44 
45  struct Echo {
47  std::array<uint8_t , 2> volume;
49  uint8_t feedback;
51  std::array<uint8_t, 8> FIR;
53  uint8_t data;
55  uint16_t offset;
57  uint16_t length;
59  uint8_t delay;
61  bool enabled = true;
63  bool toggle;
65  std::array<std::array<int16_t, 8>, 2> history;
67  uint8_t historyOffset;
69  uint16_t address;
71  uint8_t value;
73  std::array<uint16_t, 2> input;
75  std::array<uint16_t, 2> output;
76  };
77 
78  struct Noise {
80  uint8_t clock : 5;
82  uint16_t lfsr = 0x4000;
83  };
84 
85  struct BRR {
87  uint8_t offset;
89  uint8_t offsetAddr;
91  uint16_t address;
93  uint16_t nextAddress;
95  uint8_t value;
97  uint8_t header;
99  uint8_t source;
100  };
101 
102  struct Latch {
104  uint8_t adsr1;
106  uint8_t envx;
108  uint8_t outx;
110  uint16_t pitch;
112  uint16_t output;
113  };
114 
115  struct Voice {
117  std::array<int8_t, 2> volume;
119  union {
120  struct {
122  uint8_t pitchL;
124  uint8_t pitchH;
125  };
126  uint16_t pitch;
127  };
129  uint8_t srcn;
130  union {
131  struct {
133  uint8_t adsr1;
135  uint8_t adsr2;
136  };
137  uint16_t adsr;
138  };
140  uint8_t gain;
142  uint8_t envx;
144  uint8_t outx;
146  bool endx : 1;
147 
149  bool kon : 1;
151  bool kof : 1;
153  bool pmon : 1;
155  bool non : 1;
157  bool eon : 1;
158 
160  uint8_t konDelay;
162  bool echo;
164  bool loop;
166  uint16_t brrAddress;
168  uint8_t brrOffset = 1;
170  bool prevPmon : 1;
172  bool tempNon : 1;
174  bool tempKon : 1;
176  bool tempKof : 1;
178  std::array<uint16_t, 12> samples;
180  uint8_t sampleOffset;
182  uint16_t envelope;
184  uint16_t hiddenEnvelope;
188  uint16_t gaussOffset;
189  };
190 
192  struct State
193  {
194  State(std::array<int16_t, 0x10000> &array, uint32_t size)
195  : buffer(array), bufferSize(size)
196  {};
197 
199  uint8_t voice = 0;
201  std::array<int16_t, 0x10000> &buffer;
203  uint32_t bufferSize;
205  uint32_t bufferOffset = 0;
206  };
207 
208  struct Timer {
210  uint16_t counter;
212  bool sample = true;
213  };
214 
215  class DSP {
216  private:
218  std::array<uint16_t, 32> _rateModulus = {
219  0, 2048, 1536, 1280, 1024, 768,
220  640, 512, 384, 320, 256, 192,
221  160, 128, 96, 80, 64, 48,
222  40, 32, 24, 20, 16, 12,
223  10, 8, 6, 5, 4, 3,
224  2, 1
225  };
226 
228  std::array<uint16_t, 32> _counterOffset = {
229  0, 0, 1040, 536, 0, 1040,
230  536, 0, 1040, 536, 0, 1040,
231  536, 0, 1040, 536, 0, 1040,
232  536, 0, 1040, 536, 0, 1040,
233  536, 0, 1040, 536, 0, 1040,
234  0,0
235  };
236 
238  std::array<int16_t, 512> _gauss = {
239  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
240  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
241  2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5,
242  6, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10,
243  11, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 15, 16, 16, 17, 17,
244  18, 19, 19, 20, 20, 21, 21, 22, 23, 23, 24, 24, 25, 26, 27, 27,
245  28, 29, 29, 30, 31, 32, 32, 33, 34, 35, 36, 36, 37, 38, 39, 40,
246  41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
247  58, 59, 60, 61, 62, 64, 65, 66, 67, 69, 70, 71, 73, 74, 76, 77,
248  78, 80, 81, 83, 84, 86, 87, 89, 90, 92, 94, 95, 97, 99, 100, 102,
249  104, 106, 107, 109, 111, 113, 115, 117, 118, 120, 122, 124, 126, 128, 130, 132,
250  134, 137, 139, 141, 143, 145, 147, 150, 152, 154, 156, 159, 161, 163, 166, 168,
251  171, 173, 175, 178, 180, 183, 186, 188, 191, 193, 196, 199, 201, 204, 207, 210,
252  212, 215, 218, 221, 224, 227, 230, 233, 236, 239, 242, 245, 248, 251, 254, 257,
253  260, 263, 267, 270, 273, 276, 280, 283, 286, 290, 293, 297, 300, 304, 307, 311,
254  314, 318, 321, 325, 328, 332, 336, 339, 343, 347, 351, 354, 358, 362, 366, 370,
255  374, 378, 381, 385, 389, 393, 397, 401, 405, 410, 414, 418, 422, 426, 430, 434,
256  439, 443, 447, 451, 456, 460, 464, 469, 473, 477, 482, 486, 491, 495, 499, 504,
257  508, 513, 517, 522, 527, 531, 536, 540, 545, 550, 554, 559, 563, 568, 573, 577,
258  582, 587, 592, 596, 601, 606, 611, 615, 620, 625, 630, 635, 640, 644, 649, 654,
259  659, 664, 669, 674, 678, 683, 688, 693, 698, 703, 708, 713, 718, 723, 728, 732,
260  737, 742, 747, 752, 757, 762, 767, 772, 777, 782, 787, 792, 797, 802, 806, 811,
261  816, 821, 826, 831, 836, 841, 846, 851, 855, 860, 865, 870, 875, 880, 884, 889,
262  894, 899, 904, 908, 913, 918, 923, 927, 932, 937, 941, 946, 951, 955, 960, 965,
263  969, 974, 978, 983, 988, 992, 997, 1001, 1005, 1010, 1014, 1019, 1023, 1027, 1032, 1036,
264  1040, 1045, 1049, 1053, 1057, 1061, 1066, 1070, 1074, 1078, 1082, 1086, 1090, 1094, 1098, 1102,
265  1106, 1109, 1113, 1117, 1121, 1125, 1128, 1132, 1136, 1139, 1143, 1146, 1150, 1153, 1157, 1160,
266  1164, 1167, 1170, 1174, 1177, 1180, 1183, 1186, 1190, 1193, 1196, 1199, 1202, 1205, 1207, 1210,
267  1213, 1216, 1219, 1221, 1224, 1227, 1229, 1232, 1234, 1237, 1239, 1241, 1244, 1246, 1248, 1251,
268  1253, 1255, 1257, 1259, 1261, 1263, 1265, 1267, 1269, 1270, 1272, 1274, 1275, 1277, 1279, 1280,
269  1282, 1283, 1284, 1286, 1287, 1288, 1290, 1291, 1292, 1293, 1294, 1295, 1296, 1297, 1297, 1298,
270  1299, 1300, 1300, 1301, 1302, 1302, 1303, 1303, 1303, 1304, 1304, 1304, 1304, 1304, 1305, 1305
271  };
272 
274  std::array<int16_t, 0x10000> _soundBuffer = {};
276  std::array<Voice, 8> _voices {};
280  BRR _brr {};
284 
285  void voiceOutput(Voice &voice, bool channel);
286  void voice1(Voice &voice);
287  void voice2(Voice &voice);
288  void voice3(Voice &voice);
289  void voice3a(Voice &voice);
290  void voice3b(Voice &voice);
291  void voice3c(Voice &voice);
292  void voice4(Voice &voice);
293  void voice5(Voice &voice);
294  void voice6(Voice &voice);
295  void voice7(Voice &voice);
296  void voice8(Voice &voice);
297  void voice9(Voice &voice);
298  void echo22();
299  void echo23();
300  void echo24();
301  void echo25();
302  void echo26();
303  void echo27();
304  void echo28();
305  void echo29();
306  void echo30();
307  void misc27();
308  void misc28();
309  void misc29();
310  void misc30();
311 
313  int32_t interpolate(const Voice &voice);
315  void runEnvelope(Voice &voice);
316 
317  int32_t loadFIR(bool channel, int fir);
318  void loadEcho(bool channel);
319  int16_t outputEcho(bool channel);
320  void writeEcho(bool channel);
321 
323  void timerTick();
325  bool timerPoll(uint32_t rate);
326 
328  void decodeBRR(Voice &voice);
329 
332 
335 
337  uint8_t _readRAM(uint24_t addr);
339  void _writeRAM(uint24_t addr, uint8_t data);
340  public:
341  DSP(Renderer::IRenderer &renderer, MemoryMap &map);
342  DSP(const DSP &) = default;
343  DSP &operator=(const DSP &) = delete;
344  ~DSP() = default;
345 
347  [[nodiscard]] const std::array<Voice, 8> &getVoices() const;
348  [[nodiscard]] const Master &getMaster() const;
349  [[nodiscard]] const Echo &getEcho() const;
350  [[nodiscard]] const Noise &getNoise() const;
351  [[nodiscard]] const BRR &getBrr() const;
352  [[nodiscard]] const Latch &getLatch() const;
353 
358  [[nodiscard]] uint8_t read(uint24_t addr) const;
363  void write(uint24_t addr, uint8_t data);
364 
366  [[nodiscard]] std::string getName() const;
368  void update();
369 
371  [[nodiscard]] Component getComponent() const;
372 
375  [[nodiscard]] uint24_t getSize() const;
377  [[nodiscard]] int32_t getSamplesCount() const;
378  };
379 }
ComSquare::APU::DSP::DSP::_brr
BRR _brr
Definition: DSP.hpp:280
ComSquare::APU::DSP::DSP::timerTick
void timerTick()
Remove one tick from timer.
Definition: Timer.cpp:9
ComSquare::APU::DSP::Voice::pitchL
uint8_t pitchL
Lower 8 bits of pitch register.
Definition: DSP.hpp:122
ComSquare::APU::DSP::DSP::echo25
void echo25()
Definition: Echo.cpp:71
ComSquare::APU::DSP::Latch::adsr1
uint8_t adsr1
Current voice's adsr1 in use.
Definition: DSP.hpp:104
ComSquare::APU::DSP::DSP::_timer
Timer _timer
Definition: DSP.hpp:283
ComSquare::Component
Component
Definition: Components.hpp:9
ComSquare::APU::DSP::DSP::voice3c
void voice3c(Voice &voice)
Definition: Voice.cpp:57
ComSquare::APU::DSP::DSP::getBrr
const BRR & getBrr() const
Definition: DSP.cpp:793
ComSquare::APU::DSP::Attack
@ Attack
The voice is keyed on.
Definition: DSP.hpp:25
ComSquare::APU::DSP::DSP::misc29
void misc29()
Definition: Echo.cpp:144
ComSquare::APU::DSP::BRR::nextAddress
uint16_t nextAddress
Next address of the BRR in APU's RAM.
Definition: DSP.hpp:93
ComSquare::APU::DSP::DSP::echo24
void echo24()
Definition: Echo.cpp:65
ComSquare::APU::DSP::DSP::interpolate
int32_t interpolate(const Voice &voice)
Interpolate voice samples with gauss table.
Definition: Gauss.cpp:11
ComSquare::APU::DSP::Voice::brrAddress
uint16_t brrAddress
Current BRR associated with this voice.
Definition: DSP.hpp:166
ComSquare::APU::DSP::Echo::enabled
bool enabled
Echo enabled (5th bit FLG)
Definition: DSP.hpp:61
ComSquare::APU::DSP::Echo::output
std::array< uint16_t, 2 > output
Current sound echoed produced.
Definition: DSP.hpp:75
ComSquare::APU::DSP::Echo
Definition: DSP.hpp:45
ComSquare::APU::DSP::Master::unused
uint8_t unused
Not used register.
Definition: DSP.hpp:42
ComSquare::APU::DSP::DSP::_voices
std::array< Voice, 8 > _voices
8x voices of sample used to make sound
Definition: DSP.hpp:276
ComSquare::APU::DSP::DSP::operator=
DSP & operator=(const DSP &)=delete
ComSquare::APU::DSP::DSP::DSP
DSP(Renderer::IRenderer &renderer, MemoryMap &map)
Definition: DSP.cpp:11
ComSquare::APU::DSP::DSP::voice3b
void voice3b(Voice &voice)
Definition: Voice.cpp:51
ComSquare::APU::DSP::DSP::voice6
void voice6(Voice &voice)
Definition: Voice.cpp:137
ComSquare::APU::DSP::DSP::getLatch
const Latch & getLatch() const
Definition: DSP.cpp:798
ComSquare::APU::DSP::Voice::echo
bool echo
Check if the output will be echoed.
Definition: DSP.hpp:162
ComSquare::APU::DSP::Voice::adsr
uint16_t adsr
Definition: DSP.hpp:137
ComSquare::APU::DSP::State::bufferOffset
uint32_t bufferOffset
Current position in the buffer of samples.
Definition: DSP.hpp:205
ComSquare::APU::DSP::Voice::adsr2
uint8_t adsr2
Envelope controllers register (ADSR)
Definition: DSP.hpp:135
ComSquare::APU::DSP::Envelope
Envelope
The 4 states of volume envelope adjustment.
Definition: DSP.hpp:21
ComSquare::APU::DSP::DSP::writeEcho
void writeEcho(bool channel)
Definition: Echo.cpp:26
ComSquare::APU::DSP::DSP::echo22
void echo22()
Definition: Echo.cpp:46
ComSquare::APU::DSP::DSP::decodeBRR
void decodeBRR(Voice &voice)
Transform BRR value to samples.
Definition: BRR.cpp:10
ComSquare::APU::DSP::DSP::voice3a
void voice3a(Voice &voice)
Definition: Voice.cpp:46
ComSquare::APU::DSP::Latch::outx
uint8_t outx
Wave height register (OUTX)
Definition: DSP.hpp:108
ComSquare::APU::DSP::DSP::_writeRAM
void _writeRAM(uint24_t addr, uint8_t data)
Write into APU RAM.
Definition: DSP.cpp:587
ComSquare::APU::DSP::DSP::echo30
void echo30()
Definition: Echo.cpp:126
AMemory.hpp
ComSquare::APU::DSP::Echo::length
uint16_t length
offset maximum
Definition: DSP.hpp:57
ComSquare::APU::DSP::BRR::address
uint16_t address
Current address of the BRR in APU's RAM.
Definition: DSP.hpp:91
ComSquare::APU::DSP::Voice::envx
uint8_t envx
envelope associated with this voice
Definition: DSP.hpp:142
ComSquare::APU::DSP::Voice::sampleOffset
uint8_t sampleOffset
Offset of current sample in samples buffer.
Definition: DSP.hpp:180
ComSquare::APU::DSP::DSP::_soundBuffer
std::array< int16_t, 0x10000 > _soundBuffer
Buffer containing samples to be played.
Definition: DSP.hpp:274
ComSquare::APU
Definition: APU.cpp:12
ComSquare::APU::DSP::Master
Definition: DSP.hpp:32
ComSquare::APU::DSP::DSP::_latch
Latch _latch
Definition: DSP.hpp:281
ComSquare::APU::DSP::BRR::source
uint8_t source
Current value of Voice ADSR1 loaded.
Definition: DSP.hpp:99
ComSquare::APU::DSP::DSP::read
uint8_t read(uint24_t addr) const
Read from the internal DSP register.
Definition: DSP.cpp:17
ComSquare::APU::DSP::Echo::volume
std::array< uint8_t, 2 > volume
Echo Volume register (EVOL)
Definition: DSP.hpp:47
ComSquare::APU::DSP::Voice::non
bool non
Noise enable register (NON)
Definition: DSP.hpp:155
ComSquare::APU::DSP::DSP::getComponent
Component getComponent() const
Get the component of this accessor (used for debug purpose)
uint24_t
unsigned uint24_t
Definition: Ints.hpp:10
ComSquare::APU::DSP::DSP::_counterOffset
std::array< uint16_t, 32 > _counterOffset
Counter offset.
Definition: DSP.hpp:228
ComSquare::APU::DSP::Voice::prevPmon
bool prevPmon
Previous modulation.
Definition: DSP.hpp:170
ComSquare::APU::DSP::BRR::header
uint8_t header
Current header of BRR.
Definition: DSP.hpp:97
ComSquare::APU::DSP::DSP::outputEcho
int16_t outputEcho(bool channel)
Definition: Echo.cpp:38
ComSquare::APU::DSP::Master::volume
std::array< uint8_t, 2 > volume
Main Volume register (MVOL)
Definition: DSP.hpp:34
ComSquare::APU::DSP::Voice::tempKof
bool tempKof
temporary Key Off register value
Definition: DSP.hpp:176
ComSquare::APU::DSP::BRR::value
uint8_t value
Current value inside BRR.
Definition: DSP.hpp:95
ComSquare::APU::DSP::Noise
Definition: DSP.hpp:78
ComSquare::APU::DSP::Latch::output
uint16_t output
Output currently being modified.
Definition: DSP.hpp:112
ComSquare::APU::DSP::Echo::toggle
bool toggle
Application of enabled to channels.
Definition: DSP.hpp:63
ComSquare::APU::DSP::DSP::loadFIR
int32_t loadFIR(bool channel, int fir)
Definition: Echo.cpp:9
ComSquare::APU::DSP::Echo::history
std::array< std::array< int16_t, 8 >, 2 > history
Last sound produced for each voice in each channel.
Definition: DSP.hpp:65
ComSquare::APU::DSP::Voice
Definition: DSP.hpp:115
ComSquare::APU::DSP::Voice::tempKon
bool tempKon
temporary Key On register value
Definition: DSP.hpp:174
ComSquare::APU::DSP::Voice::envelopeMode
Envelope envelopeMode
current envelope Mode
Definition: DSP.hpp:186
ComSquare::APU::DSP::DSP::voiceOutput
void voiceOutput(Voice &voice, bool channel)
Definition: Voice.cpp:11
ComSquare::APU::DSP::Voice::adsr1
uint8_t adsr1
Envelope register (ADSR)
Definition: DSP.hpp:133
ComSquare::APU::DSP::DSP::loadEcho
void loadEcho(bool channel)
Definition: Echo.cpp:16
ComSquare::APU::DSP::Master::mute
bool mute
Mutes all channel (6th bit FLG)
Definition: DSP.hpp:36
ComSquare::APU::DSP::Decay
@ Decay
When the Envelope adjustment method bits exceeds 0x7ff.
Definition: DSP.hpp:27
ComSquare::APU::DSP::DSP::getEcho
const Echo & getEcho() const
Definition: DSP.cpp:783
ComSquare::APU::DSP::DSP::getNoise
const Noise & getNoise() const
Definition: DSP.cpp:788
ComSquare::APU::DSP::Master::reset
bool reset
Soft reset DSP (7th bit FLG)
Definition: DSP.hpp:38
ComSquare::APU::DSP::DSP::_noise
Noise _noise
Definition: DSP.hpp:279
ComSquare::APU::DSP::Echo::offset
uint16_t offset
Offset position after data start.
Definition: DSP.hpp:55
ComSquare::APU::DSP::DSP::echo27
void echo27()
Definition: Echo.cpp:85
ComSquare::APU::DSP::Voice::gain
uint8_t gain
Gain register (GAIN)
Definition: DSP.hpp:140
ComSquare::APU::DSP::DSP::timerPoll
bool timerPoll(uint32_t rate)
Check if timer value is equal to rate value.
Definition: Timer.cpp:16
ComSquare::APU::DSP::Echo::data
uint8_t data
Echo data start register (ESA)
Definition: DSP.hpp:53
ComSquare::APU::DSP::Latch::pitch
uint16_t pitch
Current voice's pitch in use.
Definition: DSP.hpp:110
ComSquare::APU::DSP::DSP::getVoices
const std::array< Voice, 8 > & getVoices() const
Return all 8 voices from DSP.
Definition: DSP.cpp:773
ComSquare::APU::DSP::BRR::offset
uint8_t offset
Offset pointing to sample directory in external RAM (DIR)
Definition: DSP.hpp:87
ComSquare::APU::DSP::State::voice
uint8_t voice
Current voice modification to do.
Definition: DSP.hpp:199
ComSquare::APU::DSP::Noise::clock
uint8_t clock
Frequency of white noise (the first 4 bits FLG)
Definition: DSP.hpp:80
ComSquare::APU::DSP::DSP::_state
State _state
Definition: DSP.hpp:282
ComSquare::APU::DSP::DSP::voice8
void voice8(Voice &voice)
Definition: Voice.cpp:147
ComSquare::APU::DSP::DSP::voice9
void voice9(Voice &voice)
Definition: Voice.cpp:152
ComSquare::APU::DSP::Voice::kof
bool kof
Key Off register (KOF)
Definition: DSP.hpp:151
ComSquare::APU::DSP::DSP::voice7
void voice7(Voice &voice)
Definition: Voice.cpp:142
ComSquare::APU::DSP::DSP::voice4
void voice4(Voice &voice)
Definition: Voice.cpp:106
ComSquare::APU::DSP::DSP::voice2
void voice2(Voice &voice)
Definition: Voice.cpp:27
ComSquare::APU::DSP::Voice::pitchH
uint8_t pitchH
Higher 8 bits of pitch register.
Definition: DSP.hpp:124
ComSquare::APU::DSP::Voice::konDelay
uint8_t konDelay
Check if voice is in setup phase.
Definition: DSP.hpp:160
ComSquare::APU::DSP::DSP::_master
Master _master
Definition: DSP.hpp:277
ComSquare::APU::DSP::DSP::_rateModulus
std::array< uint16_t, 32 > _rateModulus
Number of samples per counter event.
Definition: DSP.hpp:218
ComSquare::APU::DSP::DSP::write
void write(uint24_t addr, uint8_t data)
Write data to the internal DSP register.
Definition: DSP.cpp:255
ComSquare::APU::DSP::Noise::lfsr
uint16_t lfsr
Linear feedback shift register used to shift final output.
Definition: DSP.hpp:82
ComSquare::APU::DSP::Latch
Definition: DSP.hpp:102
ComSquare::APU::DSP::DSP::getSize
uint24_t getSize() const
Get the size of the data. This size can be lower than the mapped data.
Definition: DSP.cpp:768
ComSquare::APU::DSP::Sustain
@ Sustain
When the upper 3 bits of Envelope adjustment method bits equal the Sustain Level.
Definition: DSP.hpp:29
ComSquare::APU::DSP::State
Current state of the DSP.
Definition: DSP.hpp:192
ComSquare::APU::DSP::DSP::misc28
void misc28()
Definition: Echo.cpp:137
ComSquare::APU::DSP::Echo::value
uint8_t value
Current of value of the echo.
Definition: DSP.hpp:71
ComSquare::APU::DSP::State::buffer
std::array< int16_t, 0x10000 > & buffer
Current buffer of samples.
Definition: DSP.hpp:201
ComSquare::APU::DSP::Voice::pmon
bool pmon
Pitch modulation register (PMON)
Definition: DSP.hpp:153
ComSquare::APU::DSP::Voice::outx
uint8_t outx
Wave height associated with this voice.
Definition: DSP.hpp:144
ComSquare::APU::DSP::Voice::samples
std::array< uint16_t, 12 > samples
all samples Decoded from BRR
Definition: DSP.hpp:178
ComSquare::APU::DSP::Voice::brrOffset
uint8_t brrOffset
Current Offset in the BRR block.
Definition: DSP.hpp:168
ComSquare::APU::DSP::Voice::pitch
uint16_t pitch
Definition: DSP.hpp:126
ComSquare::APU::DSP::DSP::~DSP
~DSP()=default
ComSquare::APU::DSP::DSP::echo28
void echo28()
Definition: Echo.cpp:105
ComSquare::APU::DSP::DSP::_readRAM
uint8_t _readRAM(uint24_t addr)
Read inside APU RAM.
Definition: DSP.cpp:571
ComSquare::APU::DSP::Latch::envx
uint8_t envx
Envelope value register (ENVX)
Definition: DSP.hpp:106
ComSquare::APU::DSP::Voice::envelope
uint16_t envelope
Current envelope level.
Definition: DSP.hpp:182
ComSquare::APU::DSP::Voice::loop
bool loop
Check if this voice will be looped.
Definition: DSP.hpp:164
ComSquare::Renderer::IRenderer
Definition: IRenderer.hpp:15
ComSquare::APU::DSP::DSP::echo29
void echo29()
Definition: Echo.cpp:110
ComSquare::APU::DSP::BRR
Definition: DSP.hpp:85
ComSquare::APU::DSP::BRR::offsetAddr
uint8_t offsetAddr
Address of the offset.
Definition: DSP.hpp:89
ComSquare::APU::DSP::Release
@ Release
The voice is keyed off or a BRR end-without-loop block is reached.
Definition: DSP.hpp:23
ComSquare::APU::DSP::DSP::_echo
Echo _echo
Definition: DSP.hpp:278
ComSquare::APU::DSP::Voice::eon
bool eon
Echo enable register (EON)
Definition: DSP.hpp:157
ComSquare::APU::DSP::DSP::echo26
void echo26()
Definition: Echo.cpp:77
ComSquare::APU::DSP::DSP::getMaster
const Master & getMaster() const
Definition: DSP.cpp:778
ComSquare::APU::DSP::DSP::runEnvelope
void runEnvelope(Voice &voice)
Modify voice samples with its envelope.
Definition: Envelope.cpp:9
ComSquare::APU::DSP::Voice::volume
std::array< int8_t, 2 > volume
Volume register (VOL)
Definition: DSP.hpp:117
ComSquare::APU::DSP::Timer
Definition: DSP.hpp:208
ComSquare::APU::DSP::State::bufferSize
uint32_t bufferSize
Size of buffer.
Definition: DSP.hpp:203
ComSquare::APU::DSP::Echo::historyOffset
uint8_t historyOffset
Current position inside history.
Definition: DSP.hpp:67
ComSquare::APU::DSP::Voice::endx
bool endx
Sample end register (ENDX)
Definition: DSP.hpp:146
ComSquare::APU::DSP::DSP::misc30
void misc30()
Definition: Echo.cpp:153
ComSquare::APU::DSP::Voice::hiddenEnvelope
uint16_t hiddenEnvelope
Second envelope level used to make "special" waveforms.
Definition: DSP.hpp:184
ComSquare::APU::DSP::Echo::input
std::array< uint16_t, 2 > input
Current sound to echo.
Definition: DSP.hpp:73
ComSquare::APU::DSP::Echo::FIR
std::array< uint8_t, 8 > FIR
Echo FIR filter coefficients (COEF)
Definition: DSP.hpp:51
ComSquare::APU::DSP::Master::output
std::array< uint16_t, 2 > output
Current sound produced.
Definition: DSP.hpp:40
ComSquare::APU::DSP::Voice::srcn
uint8_t srcn
Source number register (SRCN)
Definition: DSP.hpp:129
ComSquare::APU::DSP::DSP
Definition: DSP.hpp:215
ComSquare::APU::DSP::DSP::getSamplesCount
int32_t getSamplesCount() const
Return the number of samples written.
Definition: DSP.cpp:803
ComSquare::APU::DSP::DSP::_renderer
Renderer::IRenderer & _renderer
Renderer used to play sounds.
Definition: DSP.hpp:334
ComSquare::APU::MemoryMap
Definition: APU.hpp:121
ComSquare::APU::DSP::DSP::echo23
void echo23()
Definition: Echo.cpp:57
ComSquare::APU::DSP::Echo::feedback
uint8_t feedback
Echo feedback register (EFB)
Definition: DSP.hpp:49
ComSquare::APU::DSP::DSP::voice5
void voice5(Voice &voice)
Definition: Voice.cpp:128
ComSquare::APU::DSP::Echo::address
uint16_t address
Address of the current echo.
Definition: DSP.hpp:69
ComSquare::APU::DSP::Voice::kon
bool kon
Key On register (KON)
Definition: DSP.hpp:149
ComSquare::APU::DSP::DSP::_map
MemoryMap & _map
Whole APU RAM map.
Definition: DSP.hpp:331
ComSquare::APU::DSP::Echo::delay
uint8_t delay
Echo delay size register (EDL)
Definition: DSP.hpp:59
ComSquare::APU::DSP
Definition: BRR.cpp:8
ComSquare::APU::DSP::DSP::update
void update()
Execute current voice transformation.
Definition: DSP.cpp:607
ComSquare::APU::DSP::DSP::getName
std::string getName() const
Get the name of this accessor (used for debug purpose)
IRenderer.hpp
ComSquare::APU::DSP::DSP::_gauss
std::array< int16_t, 512 > _gauss
Gaussian table used for making waves.
Definition: DSP.hpp:238
ComSquare::APU::DSP::Timer::counter
uint16_t counter
Ticks remaining in the timer.
Definition: DSP.hpp:210
ComSquare::APU::DSP::State::State
State(std::array< int16_t, 0x10000 > &array, uint32_t size)
Definition: DSP.hpp:194
ComSquare::APU::DSP::DSP::voice3
void voice3(Voice &voice)
Definition: Voice.cpp:39
ComSquare::APU::DSP::DSP::misc27
void misc27()
Definition: Echo.cpp:131
ComSquare::APU::DSP::Voice::tempNon
bool tempNon
temporary NON register value
Definition: DSP.hpp:172
ComSquare::APU::DSP::Voice::gaussOffset
uint16_t gaussOffset
Relative fractional position in sample.
Definition: DSP.hpp:188
ComSquare::APU::DSP::DSP::voice1
void voice1(Voice &voice)
Definition: Voice.cpp:21
ComSquare::APU::DSP::Timer::sample
bool sample
output every samples
Definition: DSP.hpp:212