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,
78 PCMSound() : len(0), rate(0), loopst(0), loopend(0), baseFreq(0), stereo(
false), enc(0) {}
79 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) {}
90 enum SynthType : byte {
97 enum ChanAttrib : byte {
100 kWaveInitChannel0 = 4,
101 kWaveInitChannel1 = 5,
102 kWaveInitChannel2 = 6,
103 kWaveInitChannel3 = 7,
110 enum ExecMode : byte {
115 typedef int ChanHandle;
120 virtual void sndChannelCallback(uint16 arg1,
const void *arg2) = 0;
130 ChanHandle createChannel(
Audio::Mixer::SoundType sndType, SynthType synthType, byte attributes, ChanCallback *callback);
131 void disposeChannel(ChanHandle handle);
133 void playSamples(ChanHandle handle, ExecMode mode,
const PCMSound *snd);
134 void playNote(ChanHandle handle, ExecMode mode, uint8 note, uint16 duration);
135 void quiet(ChanHandle handle, ExecMode mode);
136 void flush(ChanHandle handle, ExecMode mode);
137 void wait(ChanHandle handle, ExecMode mode, uint16 duration);
138 void loadWaveTable(ChanHandle handle, ExecMode mode,
const byte *data, uint16 dataSize);
139 void loadInstrument(ChanHandle handle, ExecMode mode,
const PCMSound *snd);
140 void setTimbre(ChanHandle handle, ExecMode mode, uint16 timbre);
141 void callback(ChanHandle handle, ExecMode mode, uint16 arg1,
const void *arg2);
143 uint8 getChannelStatus(ChanHandle handle)
const;
144 void clearChannelFlags(ChanHandle handle, uint8 flags);
148 MacSndChannel *findAndCheckChannel(ChanHandle h,
const char *caller, byte reqSynthType)
const;
149 MacSndChannel *findChannel(ChanHandle h)
const;
151 int _numInternalMixChannels;
152 int32 *_mixBuffer = 0;
153 uint32 _mixBufferSize;
159 virtual void vblCallback() = 0;
169 void initBuffers(uint32 feedBufferSize);
172 void setVblCallback(
const CallbackProc *proc);
178 int readBuffer(int16 *buffer,
const int numSamples)
override;
179 bool isStereo()
const override {
return _isStereo; }
180 int getRate()
const override {
return _outputRate; }
190 uint32 _vblSmpQtyRem;
191 uint32 _vblCountDown;
192 uint32 _vblCountDownRem;
193 const CallbackProc *_vblCbProc;
196 SmpBuffer() : start(0), pos(0), end(0), volume(0x10000), lastL(0), lastR(0), size(0), rateConvInt(0), rateConvFrac(0), rateConvAcc(-1) {}
209 const uint32 _outputRate;
210 const uint8 _frameSize;
212 const int _smpInternalSize;
214 const bool _isStereo;
217 class LegacyMusicDriver;
224 bool startDevices(uint32 outputRate, uint32 pcmDeviceRate, uint32 feedBufferSize,
bool enableInterpolation,
bool stereo,
bool internal16Bit);
226 void setMusicVolume(
int vol);
227 void setSfxVolume(
int vol);
228 void startSound(
int id);
229 void stopSound(
int id);
230 void stopAllSounds();
232 int getSoundStatus(
int id)
const;
233 void setQuality(
int qual);
235 void restoreAfterLoad();
237 void vblCallback()
override;
242 void startSong(
int id);
243 void startSoundEffect(
int id);
245 void stopSoundEffect();
246 void stopActiveSound();
249 void updateSoundEffect();
251 void checkRestartSoundEffects();
254 bool isSong(
int id)
const;
255 bool isHiQuality()
const;
259 int _lastSoundEffectPrio;
260 int _soundEffectNumLoops;
262 bool _songUnfinished;
263 uint _activeChanCount;
264 byte _songTimerInternal;
267 bool _soundEffectPlaying;
274 MacLowLevelPCMDriver::ChanHandle _sfxChan;
284 const byte *_musicIDTable;
285 int _musicIDTableLen;
286 const int _idRangeMax;
288 LegacyMusicDriver *_mdrv;
301 void parseNextEvents();
302 void noteOn(uint16 duration, uint8 note);
303 uint16 checkPeriod()
const;
322 uint16 _modSensitivity;
324 uint16 _localVars[5];
329 typedef bool (Indy3MacSnd::MusicChannel::*CtrlProc)(
const byte *&);
331 bool ctrl_setShape(
const byte *&pos);
332 bool ctrl_modPara(
const byte *&pos);
333 bool ctrl_init(
const byte *&pos);
334 bool ctrl_returnFromSubroutine(
const byte *&pos);
335 bool ctrl_jumpToSubroutine(
const byte *&pos);
336 bool ctrl_initOther(
const byte *&pos);
337 bool ctrl_decrJumpIf(
const byte *&pos);
338 bool ctrl_writeVar(
const byte *&pos);
340 const CtrlProc *_ctrlProc;
343 uint16 &getMemberRef(
int pos);
347 uint16 &_savedOffset;
352 static MusicChannel *_ctrlChan;
354 static const uint32 _envShapes[98];
355 const uint8 *&_modShapes;
356 const uint32 &_modShapesTableSize;
358 bool ctrlProc(
int procId,
const byte *&arg);
359 void setFrameLen(uint8 len);
362 MusicChannel **_musicChannels;
363 const int _numMusicChannels;
364 const int _numMusicTracks;
367 MusicChannel *getMusicChannel(uint8
id)
const;
377 bool startDevice(uint32 outputRate, uint32 pcmDeviceRate, uint32 feedBufferSize,
bool enableInterpolation,
bool stereo,
bool internal16Bit);
379 void setMusicVolume(
int vol);
380 void setSfxVolume(
int vol);
381 void startSound(
int id,
int jumpToTick = 0);
382 void stopSound(
int id);
383 void stopAllSounds();
385 int getSoundStatus(
int id)
const;
386 void setQuality(
int qual);
388 void restoreAfterLoad();
390 void vblCallback()
override;
394 void sndChannelCallback(uint16 arg1,
const void *arg2)
override;
397 void sendSoundCommands(
int timeStamp);
398 void stopActiveSound();
399 void setupChannels();
400 void disposeAllChannels();
402 void detectQuality();
403 bool isSoundCardType10()
const;
407 int _curSoundSaveVar;
409 byte _songTimerInternal;
410 byte *_chanConfigTable;
411 const int _idRangeMax;
412 const byte _saveVersionChange;
413 const byte _legacySaveUnits;
417 int _selectedQuality;
418 int _effectiveChanConfig;
419 int _defaultChanConfig;
422 MacLowLevelPCMDriver::ChanHandle _sndChannel;
423 MacLowLevelPCMDriver::ChanHandle _musChannels[4];
426 MacSndLoader *_loader;
444 extern const uint8 _fourToneSynthWaveForm[256];
445 extern const uint32 _fourToneSynthWaveFormSize;
Definition: player_mac_intern.h:77
Definition: player_mac_intern.h:218
Definition: player_mac_intern.h:32
int getRate() const override
Definition: player_mac_intern.h:180
bool isStereo() const override
Definition: player_mac_intern.h:179
Definition: player_mac_intern.h:117
Definition: player_mac_intern.h:46
Definition: player_mac_intern.h:156
Definition: serializer.h:79
SoundType
Definition: mixer.h:62
bool endOfData() const override
Definition: player_mac_intern.h:181
Definition: audiostream.h:50
Definition: player_mac_intern.h:164
Definition: player_mac_intern.h:75
Definition: player_mac_intern.h:371