Debian Codegraph @

src/engine/platform/qsound.h

raw
1 /**
2 * Furnace Tracker - multi-system chiptune tracker
3 * Copyright (C) 2021-2025 tildearrow and contributors
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef _QSOUND_H
21 #define _QSOUND_H
22
23 #include "../dispatch.h"
24 #include "sound/qsound.h"
25
26 class DivPlatformQSound: public DivDispatch {
27 struct Channel: public SharedChannel<int> {
28 int resVol;
29 int sample, wave;
30 int panning;
31 int echo;
32 int audPos;
33 bool useWave, surround, isNewQSound, setPos;
34 Channel():
35 SharedChannel<int>(255),
36 resVol(4095),
37 sample(-1),
38 wave(-1),
39 panning(0x10),
40 echo(0),
41 audPos(0),
42 useWave(false),
43 surround(true),
44 isNewQSound(false),
45 setPos(false) {}
46 };
47 Channel chan[19];
48 DivDispatchOscBuffer* oscBuf[19];
49 int echoDelay;
50 int echoFeedback;
51
52 unsigned char* sampleMem;
53 size_t sampleMemLen;
54 size_t sampleMemLenBS;
55 size_t sampleMemUsage;
56 bool* sampleLoaded;
57 bool* sampleLoadedBS;
58 struct qsound_chip chip;
59 unsigned short regPool[512];
60
61 unsigned int* offPCM;
62 unsigned int* offBS;
63
64 DivMemoryComposition memCompo;
65
66 friend void putDispatchChip(void*,int);
67 friend void putDispatchChan(void*,int,int);
68
69 public:
70 void acquire(short** buf, size_t len);
71 int dispatch(DivCommand c);
72 void* getChanState(int chan);
73 DivMacroInt* getChanMacroInt(int ch);
74 unsigned short getPan(int chan);
75 DivDispatchOscBuffer* getOscBuffer(int chan);
76 unsigned char* getRegisterPool();
77 int getRegisterPoolSize();
78 int getRegisterPoolDepth();
79 void reset();
80 void forceIns();
81 void tick(bool sysTick=true);
82 void muteChannel(int ch, bool mute);
83 int getOutputCount();
84 bool keyOffAffectsArp(int ch);
85 void setFlags(const DivConfig& flags);
86 void notifyInsChange(int ins);
87 void notifyWaveChange(int wave);
88 void notifyInsDeletion(void* ins);
89 void poke(unsigned int addr, unsigned short val);
90 void poke(std::vector<DivRegWrite>& wlist);
91 const char** getRegisterSheet();
92 const void* getSampleMem(int index = 0);
93 const char* getSampleMemName(int index=0);
94 size_t getSampleMemCapacity(int index = 0);
95 size_t getSampleMemUsage(int index = 0);
96 bool isSampleLoaded(int index, int sample);
97 const DivMemoryComposition* getMemCompo(int index);
98 void renderSamples(int chipID);
99 int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
100 void quit();
101 DivPlatformQSound();
102 ~DivPlatformQSound();
103 };
104
105 #endif