Debian Codegraph @

src/engine/platform/pcmdac.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 _PCM_DAC_H
21 #define _PCM_DAC_H
22
23 #include "../dispatch.h"
24 #include "../waveSynth.h"
25
26 class DivPlatformPCMDAC: public DivDispatch {
27 struct Channel: public SharedChannel<int> {
28 bool audDir;
29 unsigned int audLoc;
30 unsigned short audLen;
31 short audDat[8];
32 int audPos;
33 int audSub;
34 int sample, wave;
35 int panL, panR;
36 bool useWave, setPos;
37 int envVol;
38 DivWaveSynth ws;
39 Channel():
40 SharedChannel<int>(255),
41 audDir(false),
42 audLoc(0),
43 audLen(0),
44 audDat{0,0,0,0,0,0,0,0},
45 audPos(0),
46 audSub(0),
47 sample(-1),
48 wave(-1),
49 panL(255),
50 panR(255),
51 useWave(false),
52 setPos(false),
53 envVol(64) {}
54 };
55 Channel chan[1];
56 DivDispatchOscBuffer* oscBuf;
57 bool isMuted;
58 int outDepth;
59 // valid values:
60 // - 0: none
61 // - 1: linear
62 // - 2: cubic spline
63 // - 3: sinc
64 int interp;
65 int volMax;
66 bool outStereo;
67
68 friend void putDispatchChip(void*,int);
69 friend void putDispatchChan(void*,int,int);
70
71 public:
72 void acquire(short** buf, size_t len);
73 int dispatch(DivCommand c);
74 void* getChanState(int chan);
75 DivDispatchOscBuffer* getOscBuffer(int chan);
76 void reset();
77 void forceIns();
78 void tick(bool sysTick=true);
79 void muteChannel(int ch, bool mute);
80 int getOutputCount();
81 DivMacroInt* getChanMacroInt(int ch);
82 unsigned short getPan(int chan);
83 DivSamplePos getSamplePos(int ch);
84 void setFlags(const DivConfig& flags);
85 void notifyInsChange(int ins);
86 void notifyWaveChange(int wave);
87 void notifyInsDeletion(void* ins);
88 int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
89 void quit();
90 };
91
92 #endif