Debian Codegraph @

src/engine/platform/powernoise.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 _POWERNOISE_H
21 #define _POWERNOISE_H
22
23 #include "../dispatch.h"
24 #include "../../../extern/pwrnoise/pwrnoise.h"
25
26 class DivPlatformPowerNoise: public DivDispatch {
27 struct SlopePortion {
28 unsigned char len, offset;
29 bool clip, reset, dir;
30
31 SlopePortion(unsigned char l, unsigned char o, bool c, bool r, bool d):
32 len(l),
33 offset(o),
34 clip(c),
35 reset(r),
36 dir(d) {}
37
38 SlopePortion():
39 len(0),
40 offset(0),
41 clip(false),
42 reset(false),
43 dir(false) {}
44 };
45
46 struct Channel: public SharedChannel<signed char> {
47 int fNum;
48 unsigned short initLFSR;
49 unsigned char octave, pan, tapA, tapB, octaveOff;
50 bool slope, am, tapBEnable, keyOn, keyOff;
51 SlopePortion slopeA, slopeB;
52
53 Channel():
54 SharedChannel<signed char>(15),
55 fNum(0),
56 initLFSR(0x5555),
57 octave(0),
58 pan(255),
59 tapA(1),
60 tapB(2),
61 octaveOff(0),
62 slope(false),
63 am(false),
64 tapBEnable(false),
65 keyOn(false),
66 keyOff(false),
67 slopeA(255,1,false,false,false),
68 slopeB() {}
69 };
70
71 Channel chan[4];
72 DivDispatchOscBuffer* oscBuf[4];
73 bool isMuted[4];
74 unsigned char regPool[32];
75
76 int coreQuality;
77 power_noise_t pn;
78
79 friend void putDispatchChip(void*,int);
80 friend void putDispatchChan(void*,int,int);
81 public:
82 void acquire(short** buf, size_t len);
83 int dispatch(DivCommand c);
84 void* getChanState(int chan);
85 DivMacroInt* getChanMacroInt(int ch);
86 unsigned short getPan(int chan);
87 DivChannelModeHints getModeHints(int chan);
88 bool getDCOffRequired();
89 DivDispatchOscBuffer* getOscBuffer(int chan);
90 unsigned char* getRegisterPool();
91 int getRegisterPoolSize();
92 void reset();
93 void forceIns();
94 void tick(bool sysTick=true);
95 void muteChannel(int ch, bool mute);
96 int getOutputCount();
97 bool keyOffAffectsArp(int ch);
98 void setFlags(const DivConfig& flags);
99 void notifyWaveChange(int wave);
100 void notifyInsDeletion(void* ins);
101 void poke(unsigned int addr, unsigned short val);
102 void poke(std::vector<DivRegWrite>& wlist);
103 const char** getRegisterSheet();
104 void setCoreQuality(unsigned char q);
105 int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
106 void quit();
107 ~DivPlatformPowerNoise();
108 };
109
110 #endif