ScummVM API documentation
player_mac_intern.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef SCUMM_PLAYERS_PLAYER_MAC_INTERN_H
23#define SCUMM_PLAYERS_PLAYER_MAC_INTERN_H
24
25#include "engines/scumm/players/mac_sound_lowlevel.h"
26#include "common/serializer.h"
27
28namespace Scumm {
29
30class LegacyMusicDriver;
31class ScummEngine;
32class Indy3MacSnd final : public VblTaskClientDriver {
33private:
35public:
38 bool startDevices(uint32 outputRate, uint32 pcmDeviceRate, uint32 feedBufferSize, bool enableInterpolation, bool stereo, bool internal16Bit);
39
40 void setMusicVolume(int vol);
41 void setSfxVolume(int vol);
42 void startSound(int id);
43 void stopSound(int id);
44 void stopAllSounds();
45 int getMusicTimer();
46 int getSoundStatus(int id) const;
47 void setQuality(int qual);
48 void saveLoadWithSerializer(Common::Serializer &ser);
49 void restoreAfterLoad();
50 void toggleMusic(bool enable);
51 void toggleSoundEffects(bool enable);
52
53 void vblCallback() override;
54 void generateData(int8 *dst, uint32 byteSize, Audio::Mixer::SoundType type, bool expectStereo) const override;
55 const MacSoundDriver::Status &getDriverStatus(Audio::Mixer::SoundType sndType) const override;
56
57private:
58 void startSong(int id);
59 void startSoundEffect(int id);
60 void stopSong();
61 void stopSoundEffect();
62 void stopActiveSound();
63 void finishSong();
64 void updateSong();
65 void updateSoundEffect();
66
67 void checkRestartSoundEffects();
68 void endOfTrack();
69
70 bool isSong(int id) const;
71 bool isHiQuality() const;
72
73 int _curSound;
74 int _curSong;
75 int _lastSoundEffectPrio;
76 int _soundEffectNumLoops;
77 int _songTimer;
78 bool _songUnfinished;
79 uint _activeChanCount;
80 byte _songTimerInternal;
81 byte *_soundUsage;
82 byte _disableFlags;
83
84 bool _soundEffectPlaying;
85 bool _soundEffectReschedule;
86 int _qmode;
87 bool _16bit;
88 bool _qualHi;
89 bool _mixerThread;
90
92 MacLowLevelPCMDriver::ChanHandle _sfxChan;
93
94 MacPlayerAudioStream *_macstr;
95 Audio::SoundHandle _soundHandle;
97
98 ScummEngine *_vm;
99 Audio::Mixer *_mixer;
100 static Common::WeakPtr<Indy3MacSnd> *_inst;
101
102 const byte *_musicIDTable;
103 int _musicIDTableLen;
104 const int _idRangeMax;
105
106 LegacyMusicDriver *_mdrv;
109
110private:
111 class MusicChannel {
112 public:
113 MusicChannel(Indy3MacSnd *pl);
114 ~MusicChannel();
115 void clear();
116
117 void start(Common::SharedPtr<const byte> &songRes, uint16 offset, bool hq);
118 void nextTick();
119 void parseNextEvents();
120 void noteOn(uint16 duration, uint8 note);
121 uint16 checkPeriod() const;
122
123 uint16 _frameLen;
124 uint16 _curPos;
125 uint16 _freqCur;
126 uint16 _freqIncr;
127 uint16 _freqEff;
128 uint16 _envPhase;
129 uint16 _envRate;
130 uint16 _tempo;
131 uint16 _envSust;
132 int16 _transpose;
133 uint16 _envAtt;
134 uint16 _envShape;
135 uint16 _envStep;
136 uint16 _envStepLen;
137 uint16 _modType;
138 uint16 _modState;
139 uint16 _modStep;
140 uint16 _modSensitivity;
141 uint16 _modRange;
142 uint16 _localVars[5];
144 bool _hq;
145
146 private:
147 typedef bool (Indy3MacSnd::MusicChannel::*CtrlProc)(const byte *&);
148
149 bool ctrl_setShape(const byte *&pos);
150 bool ctrl_modPara(const byte *&pos);
151 bool ctrl_init(const byte *&pos);
152 bool ctrl_returnFromSubroutine(const byte *&pos);
153 bool ctrl_jumpToSubroutine(const byte *&pos);
154 bool ctrl_initOther(const byte *&pos);
155 bool ctrl_decrJumpIf(const byte *&pos);
156 bool ctrl_writeVar(const byte *&pos);
157
158 const CtrlProc *_ctrlProc;
159
160 void limitedClear();
161 uint16 &getMemberRef(int pos);
162
163 uint16 **_vars;
164 int _numVars;
165 uint16 &_savedOffset;
166
167 uint16 _resSize;
168
169 Indy3MacSnd *_player;
170 static MusicChannel *_ctrlChan;
171
172 static const uint32 _envShapes[98];
173 const uint8 *const &_modShapes;
174 const uint32 &_modShapesTableSize;
175
176 bool ctrlProc(int procId, const byte *&arg);
177 void setFrameLen(uint8 len);
178 };
179
180 MusicChannel **_musicChannels;
181 const int _numMusicChannels;
182 const int _numMusicTracks;
183
184public:
185 MusicChannel *getMusicChannel(uint8 id) const;
186};
187
188class MacSndLoader;
190private:
192public:
195 bool startDevice(uint32 outputRate, uint32 pcmDeviceRate, uint32 feedBufferSize, bool enableInterpolation, bool stereo, bool internal16Bit);
196
197 void setMusicVolume(int vol);
198 void setSfxVolume(int vol);
199 void startSound(int id, int jumpToTick = 0);
200 void stopSound(int id);
201 void stopAllSounds();
202 int getMusicTimer();
203 int getSoundStatus(int id) const;
204 void setQuality(int qual);
205 void saveLoadWithSerializer(Common::Serializer &ser);
206 void restoreAfterLoad();
207 void toggleMusic(bool enable);
208 void toggleSoundEffects(bool enable);
209
210 void vblCallback() override;
211 void generateData(int8 *dst, uint32 byteSize, Audio::Mixer::SoundType type, bool expectStereo) const override;
212 const MacSoundDriver::Status &getDriverStatus(Audio::Mixer::SoundType sndType) const override;
213
214 void sndChannelCallback(uint16 arg1, const void *arg2) override;
215
216private:
217 void sendSoundCommands(int timeStamp);
218 void stopActiveSound();
219 void setupChannels();
220 void disposeAllChannels();
221 void updateDisabledState();
222
223 void detectQuality();
224 bool isSoundCardType10() const;
225
226 int _curSound;
227 int _restartSound;
228 int _curSoundSaveVar;
229 int &_checkSound;
230 int _songTimer;
231 byte _songTimerInternal;
232 byte *_chanConfigTable;
233 const int _idRangeMax;
234 const byte _saveVersionChange;
235 const byte _legacySaveUnits;
236 bool _mixerThread;
237
238 int _machineRating;
239 int _selectedQuality;
240 int _effectiveChanConfig;
241 int _defaultChanConfig;
242 bool _16bit;
243 byte _disableFlags;
244
245 MacLowLevelPCMDriver::ChanHandle _sndChannel;
246 MacLowLevelPCMDriver::ChanHandle _musChannels[4];
247
248 MacPlayerAudioStream *_macstr;
249 MacSndLoader *_loader;
251 Audio::SoundHandle _soundHandle;
254
255 ScummEngine *_vm;
256 Audio::Mixer *_mixer;
258
259 byte _curChanConfig;
260 byte _chanUse;
261 byte _curSynthType;
262 Audio::Mixer::SoundType _curSndType;
263 Audio::Mixer::SoundType _lastSndType;
264 byte _chanPlaying;
265};
266
267} // End of namespace Scumm
268
269#endif
Definition: mixer.h:70
SoundType
Definition: mixer.h:73
Definition: mixer.h:49
Definition: array.h:52
Definition: serializer.h:80
Definition: ptr.h:159
Definition: ptr.h:381
Definition: player_mac_intern.h:32
Definition: player_mac_intern.h:189
Definition: mac_sound_lowlevel.h:130
Definition: mac_sound_lowlevel.h:75
Definition: mac_sound_lowlevel.h:183
Definition: scumm.h:536
Definition: mac_sound_lowlevel.h:175
Definition: actor.h:30
Definition: mac_sound_lowlevel.h:77
Definition: mac_sound_lowlevel.h:46