22 #ifndef TOWNS_PC98_FMSYNTH_H 23 #define TOWNS_PC98_FMSYNTH_H 25 #include "audio/audiostream.h" 26 #include "audio/mixer.h" 27 #include "common/mutex.h" 28 #include "common/func.h" 29 #include "common/array.h" 38 #define DISABLE_PC98_RHYTHM_CHANNEL 53 class TownsPC98_FmSynthOperator;
54 class TownsPC98_FmSynthSquareWaveSource;
55 #ifndef DISABLE_PC98_RHYTHM_CHANNEL 56 class TownsPC98_FmSynthPercussionSource;
81 void writeReg(uint8 part, uint8 regAddress, uint8 value);
82 uint8 readReg(uint8 part, uint8 regAddress);
85 int readBuffer(int16 *buffer,
const int numSamples);
95 virtual void nextTickEx(int32 *buffer, uint32 bufferSize) {}
97 virtual void timerCallbackA() = 0;
98 virtual void timerCallbackB() = 0;
105 void setVolumeIntern(
int volA,
int volB);
106 void setVolumeChannelMasks(
int channelMaskA,
int channelMaskB);
109 void setLevelSSG(
int vol);
113 const bool _hasPercussion;
116 int _mixerThreadLockCounter;
119 void generateTables();
120 void writeRegInternal(uint8 part, uint8 regAddress, uint8 value);
121 void nextTick(int32 *buffer, uint32 bufferSize);
123 #ifdef ENABLE_SNDTOWNS98_WAITCYCLES 124 void startWaitCycle();
127 struct ChanInternal {
131 void ampModSensitivity(uint32 value) {
132 ampModSvty = (1 << (3 - value)) - (((value >> 1) & 1) | (value & 1));
134 void frqModSensitivity(uint32 value) {
135 frqModSvty = value << 5;
138 feedbuf[0] = feedbuf[1] = feedbuf[2] = 0;
143 bool updateEnvelopeParameters;
150 TownsPC98_FmSynthOperator *opr[4];
153 TownsPC98_FmSynthSquareWaveSource *_ssg;
154 #ifndef DISABLE_PC98_RHYTHM_CHANNEL 155 TownsPC98_FmSynthPercussionSource *_prc;
157 ChanInternal *_chanInternal;
160 uint8 *_oprRateshift;
161 uint8 *_oprAttackDecay;
168 ChipTimerProc *_timerProcIdle;
169 ChipTimerProc *_timerProcA;
170 ChipTimerProc *_timerProcB;
171 void idleTimerCallback() {}
185 ChipTimer _timers[2];
187 int _volMaskA, _volMaskB;
188 uint16 _volumeA, _volumeB;
190 int32 *_renderBuffer;
191 int _renderBufferSize;
198 const int _internalRate;
199 const int _outputRate;
201 #ifdef ENABLE_SNDTOWNS98_WAITCYCLES 202 int _waitCycleRemainder;
203 const int _samplesPerWaitCycle;
206 RegEntry(uint8 p, uint8 r, uint8 v) : part(p), reg(r), val(v) {}
215 uint8 _registers[255][2];
220 #ifndef DISABLE_PC98_RHYTHM_CHANNEL 221 static const uint8 _percussionData[];
223 static const uint32 _adtStat[];
224 static const uint8 _detSrc[];
225 static const int _ssgTables[];
Definition: audiostream.h:50
int readBuffer(int16 *buffer, const int numSamples)
Definition: towns_pc98_fmsynth.h:67