28 #ifndef GOB_SOUND_ADLIB_H 29 #define GOB_SOUND_ADLIB_H 31 #include "common/mutex.h" 33 #include "audio/mixer.h" 44 AdLib(
int callbackFrequency);
47 bool isPlaying()
const;
48 int32 getRepeating()
const;
56 void setRepeating(int32 repCount);
82 kParamKeyScaleLevel = 0,
93 kParamKeyScaleRate = 11,
98 static const int kOperatorCount = 18;
99 static const int kParamCount = 14;
100 static const int kPitchStepCount = 25;
101 static const int kOctaveCount = 8;
102 static const int kHalfToneCount = 12;
104 static const int kOperatorsPerVoice = 2;
106 static const int kMelodyVoiceCount = 9;
107 static const int kPercussionVoiceCount = 5;
108 static const int kMaxVoiceCount = 11;
111 static const int kNoteCount = kHalfToneCount * kOctaveCount;
113 static const int kMaxVolume = 0x007F;
114 static const int kMaxPitch = 0x3FFF;
115 static const int kMidPitch = 0x2000;
117 static const int kStandardMidC = 60;
118 static const int kOPLMidC = 48;
123 void writeOPL(byte reg, byte val);
129 void end(
bool killRepeat =
false);
136 virtual uint32 pollMusic(
bool first) = 0;
139 virtual void rewind() = 0;
142 bool isPercussionMode()
const;
145 void setPercussionMode(
bool percussion);
151 void enableWaveSelect(
bool enable);
158 void setPitchRange(uint8 range);
164 void setTremoloDepth(
bool tremoloDepth);
170 void setVibratoDepth(
bool vibratoDepth);
173 void setKeySplit(
bool keySplit);
183 void setVoiceTimbre(uint8 voice,
const uint16 *params);
186 void setVoiceVolume(uint8 voice, uint8 volume);
194 void bendVoicePitch(uint8 voice, uint16 pitchBend);
201 void noteOn(uint8 voice, uint8 note);
204 void noteOff(uint8 voice);
209 void setTimerFrequency(
int timerFrequency);
214 static const uint8 kOperatorType [kOperatorCount];
215 static const uint8 kOperatorOffset[kOperatorCount];
216 static const uint8 kOperatorVoice [kOperatorCount];
218 static const uint8 kVoiceMelodyOperator [kOperatorsPerVoice][kMelodyVoiceCount];
219 static const uint8 kVoicePercussionOperator[kOperatorsPerVoice][kPercussionVoiceCount];
221 static const byte kPercussionMasks[kPercussionVoiceCount];
223 static const uint16 kPianoParams [kOperatorsPerVoice][kParamCount];
224 static const uint16 kBaseDrumParams [kOperatorsPerVoice][kParamCount];
226 static const uint16 kSnareDrumParams[kParamCount];
227 static const uint16 kTomParams [kParamCount];
228 static const uint16 kCymbalParams [kParamCount];
229 static const uint16 kHihatParams [kParamCount];
250 bool _enableWaveSelect;
252 bool _percussionMode;
253 byte _percussionBits;
256 uint16 _pitchRangeStep;
258 uint8 _voiceNote[kMaxVoiceCount];
259 uint8 _voiceOn [kMaxVoiceCount];
261 uint8 _operatorVolume[kOperatorCount];
263 byte _operatorParams[kOperatorCount][kParamCount];
265 uint16 _freqs[kPitchStepCount][kHalfToneCount];
266 uint16 *_freqPtr[kMaxVoiceCount];
268 int _halfToneOffset[kMaxVoiceCount];
278 void writeTremoloVibratoDepthPercMode();
279 void writeKeySplit();
282 void writeWaveSelect(uint8 oper);
283 void writeTremoloVibratoSustainingKeyScaleRateFreqMulti(uint8 oper);
284 void writeSustainRelease(uint8 oper);
285 void writeAttackDecay(uint8 oper);
286 void writeFeedbackFM(uint8 oper);
287 void writeKeyScaleLevelVolume(uint8 oper);
288 void writeAllParams(uint8 oper);
290 void initOperatorParams();
291 void initOperatorVolumes();
292 void setOperatorParams(uint8 oper,
const uint16 *params, uint8 wave);
294 void voiceOff(uint8 voice);
297 void setFreqs(uint16 *freqs, int32 num, int32 denom);
298 int32 calcFreq(int32 deltaDemiToneNum, int32 deltaDemiToneDenom);
301 void changePitch(uint8 voice, uint16 pitchBend);
303 void setFreq(uint8 voice, uint16 note,
bool on);
313 #endif // GOB_SOUND_ADLIB_H
kParam
Definition: adlib.h:81