22 #ifndef SCUMM_PLAYERS_PLAYER_MAC_INTERN_H 23 #define SCUMM_PLAYERS_PLAYER_MAC_INTERN_H 25 #include "audio/audiostream.h" 26 #include "audio/mixer.h" 27 #include "common/array.h" 28 #include "common/func.h" 34 MacSoundDriver(
Common::Mutex &mutex, uint32 deviceRate,
int activeChannels,
bool canInterpolate,
bool internal16Bit) : _mutex(mutex),
35 _smpSize(internal16Bit ? 2 : 1), _smpMin(internal16Bit ? -32768 : -128), _smpMax(internal16Bit ? 32767 : 127) {
36 for (
int i = 0; i < 4; ++i) {
37 _status[i].deviceRate = deviceRate;
38 _status[i].numExternalMixChannels = activeChannels;
39 _status[i].allowInterPolation = canInterpolate;
47 Status() : deviceRate(0), numExternalMixChannels(0), allowInterPolation(
false), flags(0) {}
49 int numExternalMixChannels;
50 bool allowInterPolation;
55 enum StatusFlag : uint8 {
56 kStatusPlaying = 1 << 0,
57 kStatusOverflow = 1 << 1,
58 kStatusStartup = 1 << 2,
77 PCMSound() : len(0), rate(0), loopst(0), loopend(0), baseFreq(0), stereo(
false), enc(0) {}
78 PCMSound(
Common::SharedPtr<const byte> a, uint32 b, uint32 c, uint32 d, uint32 e, byte f, byte g,
bool h) : data(a), len(b), rate(c), loopst(d), loopend(e), baseFreq(f), enc(g), stereo(h) {}
89 enum SynthType : byte {
96 enum ChanAttrib : byte {
99 kWaveInitChannel0 = 4,
100 kWaveInitChannel1 = 5,
101 kWaveInitChannel2 = 6,
102 kWaveInitChannel3 = 7,
109 enum ExecMode : byte {
114 typedef int ChanHandle;
119 virtual void sndChannelCallback(uint16 arg1,
const void *arg2) = 0;
129 ChanHandle createChannel(
Audio::Mixer::SoundType sndType, SynthType synthType, byte attributes, ChanCallback *callback);
130 void disposeChannel(ChanHandle handle);
132 void playSamples(ChanHandle handle, ExecMode mode,
const PCMSound *snd);
133 void playNote(ChanHandle handle, ExecMode mode, uint8 note, uint16 duration);
134 void quiet(ChanHandle handle, ExecMode mode);
135 void flush(ChanHandle handle, ExecMode mode);
136 void wait(ChanHandle handle, ExecMode mode, uint16 duration);
137 void loadWaveTable(ChanHandle handle, ExecMode mode,
const byte *data, uint16 dataSize);
138 void loadInstrument(ChanHandle handle, ExecMode mode,
const PCMSound *snd);
139 void setTimbre(ChanHandle handle, ExecMode mode, uint16 timbre);
140 void callback(ChanHandle handle, ExecMode mode, uint16 arg1,
const void *arg2);
142 uint8 getChannelStatus(ChanHandle handle)
const;
143 void clearChannelFlags(ChanHandle handle, uint8 flags);
147 MacSndChannel *findAndCheckChannel(ChanHandle h,
const char *caller, byte reqSynthType)
const;
148 MacSndChannel *findChannel(ChanHandle h)
const;
150 int _numInternalMixChannels;
151 int32 *_mixBuffer = 0;
152 uint32 _mixBufferSize;
158 virtual void vblCallback() = 0;
168 void initBuffers(uint32 feedBufferSize);
171 void setVblCallback(
const CallbackProc *proc);
177 int readBuffer(int16 *buffer,
const int numSamples)
override;
178 bool isStereo()
const override {
return _isStereo; }
179 int getRate()
const override {
return _outputRate; }
189 uint32 _vblSmpQtyRem;
190 uint32 _vblCountDown;
191 uint32 _vblCountDownRem;
192 const CallbackProc *_vblCbProc;
195 SmpBuffer() : start(0), pos(0), end(0), volume(0x10000), lastL(0), lastR(0), size(0), rateConvInt(0), rateConvFrac(0), rateConvAcc(-1) {}
208 const uint32 _outputRate;
209 const uint8 _frameSize;
211 const int _smpInternalSize;
213 const bool _isStereo;
216 class LegacyMusicDriver;
223 bool startDevices(uint32 outputRate, uint32 pcmDeviceRate, uint32 feedBufferSize,
bool enableInterpolation,
bool stereo,
bool internal16Bit);
225 void setMusicVolume(
int vol);
226 void setSfxVolume(
int vol);
227 void startSound(
int id);
228 void stopSound(
int id);
229 void stopAllSounds();
231 int getSoundStatus(
int id)
const;
232 void setQuality(
int qual);
234 void restoreAfterLoad();
235 void toggleMusic(
bool enable);
236 void toggleSoundEffects(
bool enable);
238 void vblCallback()
override;
243 void startSong(
int id);
244 void startSoundEffect(
int id);
246 void stopSoundEffect();
247 void stopActiveSound();
250 void updateSoundEffect();
252 void checkRestartSoundEffects();
255 bool isSong(
int id)
const;
256 bool isHiQuality()
const;
260 int _lastSoundEffectPrio;
261 int _soundEffectNumLoops;
263 bool _songUnfinished;
264 uint _activeChanCount;
265 byte _songTimerInternal;
269 bool _soundEffectPlaying;
270 bool _soundEffectReschedule;
277 MacLowLevelPCMDriver::ChanHandle _sfxChan;
287 const byte *_musicIDTable;
288 int _musicIDTableLen;
289 const int _idRangeMax;
291 LegacyMusicDriver *_mdrv;
304 void parseNextEvents();
305 void noteOn(uint16 duration, uint8 note);
306 uint16 checkPeriod()
const;
325 uint16 _modSensitivity;
327 uint16 _localVars[5];
332 typedef bool (Indy3MacSnd::MusicChannel::*CtrlProc)(
const byte *&);
334 bool ctrl_setShape(
const byte *&pos);
335 bool ctrl_modPara(
const byte *&pos);
336 bool ctrl_init(
const byte *&pos);
337 bool ctrl_returnFromSubroutine(
const byte *&pos);
338 bool ctrl_jumpToSubroutine(
const byte *&pos);
339 bool ctrl_initOther(
const byte *&pos);
340 bool ctrl_decrJumpIf(
const byte *&pos);
341 bool ctrl_writeVar(
const byte *&pos);
343 const CtrlProc *_ctrlProc;
346 uint16 &getMemberRef(
int pos);
350 uint16 &_savedOffset;
355 static MusicChannel *_ctrlChan;
357 static const uint32 _envShapes[98];
358 const uint8 *&_modShapes;
359 const uint32 &_modShapesTableSize;
361 bool ctrlProc(
int procId,
const byte *&arg);
362 void setFrameLen(uint8 len);
365 MusicChannel **_musicChannels;
366 const int _numMusicChannels;
367 const int _numMusicTracks;
370 MusicChannel *getMusicChannel(uint8
id)
const;
380 bool startDevice(uint32 outputRate, uint32 pcmDeviceRate, uint32 feedBufferSize,
bool enableInterpolation,
bool stereo,
bool internal16Bit);
382 void setMusicVolume(
int vol);
383 void setSfxVolume(
int vol);
384 void startSound(
int id,
int jumpToTick = 0);
385 void stopSound(
int id);
386 void stopAllSounds();
388 int getSoundStatus(
int id)
const;
389 void setQuality(
int qual);
391 void restoreAfterLoad();
392 void toggleMusic(
bool enable);
393 void toggleSoundEffects(
bool enable);
395 void vblCallback()
override;
399 void sndChannelCallback(uint16 arg1,
const void *arg2)
override;
402 void sendSoundCommands(
int timeStamp);
403 void stopActiveSound();
404 void setupChannels();
405 void disposeAllChannels();
406 void updateDisabledState();
408 void detectQuality();
409 bool isSoundCardType10()
const;
413 int _curSoundSaveVar;
416 byte _songTimerInternal;
417 byte *_chanConfigTable;
418 const int _idRangeMax;
419 const byte _saveVersionChange;
420 const byte _legacySaveUnits;
424 int _selectedQuality;
425 int _effectiveChanConfig;
426 int _defaultChanConfig;
430 MacLowLevelPCMDriver::ChanHandle _sndChannel;
431 MacLowLevelPCMDriver::ChanHandle _musChannels[4];
434 MacSndLoader *_loader;
452 extern const uint8 _fourToneSynthWaveForm[256];
453 extern const uint32 _fourToneSynthWaveFormSize;
Definition: player_mac_intern.h:76
Definition: player_mac_intern.h:217
Definition: player_mac_intern.h:32
int getRate() const override
Definition: player_mac_intern.h:179
bool isStereo() const override
Definition: player_mac_intern.h:178
Definition: player_mac_intern.h:116
Definition: player_mac_intern.h:46
Definition: player_mac_intern.h:155
Definition: serializer.h:79
SoundType
Definition: mixer.h:62
bool endOfData() const override
Definition: player_mac_intern.h:180
Definition: audiostream.h:50
Definition: player_mac_intern.h:163
Definition: player_mac_intern.h:74
Definition: player_mac_intern.h:374