25 #include "common/scummsys.h" 26 #include "common/mutex.h" 27 #include "common/queue.h" 28 #include "audio/mixer.h" 29 #include "common/list.h" 30 #include "tsage/saveload.h" 31 #include "tsage/core.h" 34 class QueuingAudioStream;
45 #define SOUND_ARR_SIZE 16 46 #define ROLAND_DRIVER_NUM 2 47 #define ADLIB_DRIVER_NUM 3 48 #define SBLASTER_DRIVER_NUM 4 49 #define CALLBACKS_PER_SECOND 60 53 int _chunks[SOUND_ARR_SIZE];
54 int _voiceTypes[SOUND_ARR_SIZE];
57 enum SoundDriverStatus {SNDSTATUS_FAILED = 0, SNDSTATUS_DETECTED = 1, SNDSTATUS_SKIPPED = 2};
58 enum VoiceType {VOICETYPE_0 = 0, VOICETYPE_1 = 1};
63 SoundDriverStatus _status;
79 _regNum = regNum; _value = value;
86 int _minVersion, _maxVersion;
95 const Common::String &getShortDriverDescription() {
return _shortDescription; }
96 const Common::String &getLongDriverDescription() {
return _longDescription; }
98 virtual bool open() {
return true; }
99 virtual void close() {}
100 virtual bool reset() {
return true; }
101 virtual const GroupData *getGroupData() {
return NULL; }
102 virtual void installPatch(
const byte *data,
int size) {}
103 virtual void poll() {}
104 virtual void method6() {}
105 virtual int setMasterVolume(
int volume) {
return 0; }
106 virtual void proc16() {}
107 virtual void proc18(
int al, VoiceType voiceType) {}
108 virtual void proc20(
int al, VoiceType voiceType) {}
109 virtual void proc22(
int al, VoiceType voiceType,
int v3) {}
110 virtual void proc24(
int channel,
int voiceIndex,
Sound *sound,
int v1,
int v2) {}
111 virtual void setProgram(
int channel,
int program) {}
112 virtual void setVolume1(
int channel,
int v2,
int v3,
int volume) {}
113 virtual void setPitchBlend(
int channel,
int pitchBlend) {}
114 virtual void playSound(
const byte *channelData,
int dataOffset,
int program,
int channel,
int v0,
int v1) {}
115 virtual void updateVoice(
int channel) {}
116 virtual void proc36() {}
117 virtual void proc38(
int channel,
int cmd,
int value) {}
118 virtual void setPitch(
int channel,
int pitchBlend) {}
119 virtual void proc42(
int channel,
int cmd,
int value,
int *v1,
int *v2) {}
162 VoiceType _voiceType;
175 int _ourSndResVersion, _ourDrvResVersion;
184 bool _driversDetected;
189 bool _soTimeIndexFlag;
195 void listenerSynchronize(
Serializer &s)
override;
196 virtual void postInit();
199 static void saveNotifier(
bool postFlag);
200 void saveNotifierProc(
bool postFlag);
201 static void loadNotifier(
bool postFlag);
202 void loadNotifierProc(
bool postFlag);
204 void installConfigDrivers();
207 void dumpDriverList();
208 void installDriver(
int driverNum);
209 bool isInstalled(
int driverNum)
const;
210 void unInstallDriver(
int driverNum);
211 void checkResVersion(
const byte *soundData);
212 int determineGroup(
const byte *soundData);
213 int extractPriority(
const byte *soundData);
214 int extractLoop(
const byte *soundData);
215 bool isOnPlayList(
Sound *sound);
216 void extractTrackInfo(
trackInfoStruct *trackInfo,
const byte *soundData,
int groupNum);
217 void addToSoundList(
Sound *sound);
218 void removeFromSoundList(
Sound *sound);
219 void addToPlayList(
Sound *sound);
220 void removeFromPlayList(
Sound *sound);
221 void rethinkVoiceTypes();
222 void updateSoundVol(
Sound *sound);
223 void updateSoundPri(
Sound *sound);
224 void updateSoundLoop(
Sound *sound);
225 void setMasterVol(
int volume);
226 int getMasterVol()
const;
227 void loadSound(
int soundNum,
bool showErrors);
228 void unloadSound(
int soundNum);
233 static void sfTerminate();
234 static int sfDetermineGroup(
const byte *soundData);
235 static void sfAddToPlayList(
Sound *sound);
236 static void sfRemoveFromPlayList(
Sound *sound);
237 static bool sfIsOnPlayList(
Sound *sound);
238 static void sfRethinkSoundDrivers();
239 static void sfRethinkVoiceTypes();
240 static void sfUpdateVolume(
Sound *sound);
241 static void sfDereferenceAll();
242 static void sfUpdatePriority(
Sound *sound);
243 static void sfUpdateLoop(
Sound *sound);
244 static void sfSetMasterVol(
int volume);
245 static void sfExtractTrackInfo(
trackInfoStruct *trackInfo,
const byte *soundData,
int groupNum);
246 static void sfExtractGroupMask();
248 static void sfUnInstallDriver(
SoundDriver *driver);
249 static void sfInstallPatchBank(
SoundDriver *driver,
const byte *bankData);
250 static void sfDoAddToPlayList(
Sound *sound);
251 static bool sfDoRemoveFromPlayList(
Sound *sound);
252 static void sfDoUpdateVolume(
Sound *sound);
253 static void sfSoundServer(
void *);
254 static void sfProcessFading();
255 static void sfUpdateVoiceStructs();
256 static void sfUpdateVoiceStructs2();
261 void _prime(
int soundResID,
bool dontQueue);
262 void _primeBuffer(
const byte *soundData);
265 bool _stoppedAsynchronously;
283 bool _stopAfterFadeFlag;
285 uint32 _newTimeIndex;
287 int _chProgram[SOUND_ARR_SIZE];
288 int _chModulation[SOUND_ARR_SIZE];
289 int _chVolume[SOUND_ARR_SIZE];
290 int _chPan[SOUND_ARR_SIZE];
291 int _chDamper[SOUND_ARR_SIZE];
292 int _chPitchBlend[SOUND_ARR_SIZE];
293 int _chVoiceType[SOUND_ARR_SIZE];
294 int _chNumVoices[SOUND_ARR_SIZE];
295 int _chSubPriority[SOUND_ARR_SIZE];
296 int _chFlags[SOUND_ARR_SIZE];
297 bool _chWork[SOUND_ARR_SIZE];
299 byte *_channelData[SOUND_ARR_SIZE];
300 int _trkChannel[SOUND_ARR_SIZE];
301 int _trkState[SOUND_ARR_SIZE];
302 int _trkLoopState[SOUND_ARR_SIZE];
303 int _trkIndex[SOUND_ARR_SIZE];
304 int _trkLoopIndex[SOUND_ARR_SIZE];
305 int _trkRest[SOUND_ARR_SIZE];
306 int _trkLoopRest[SOUND_ARR_SIZE];
310 byte *_remoteReceiver;
316 void orientAfterRestore();
318 void play(
int soundResID);
320 void prime(
int soundResID);
325 int getSoundNum()
const;
326 bool isPrimed()
const;
327 bool isPaused()
const;
328 bool isMuted()
const;
329 void pause(
bool flag);
330 void mute(
bool flag);
331 void fade(
int fadeDest,
int fadeSteps,
int fadeTicks,
bool stopAfterFadeFlag);
332 void setTimeIndex(uint32 timeIndex);
333 uint32 getTimeIndex()
const;
334 int getCueValue()
const;
335 void setCueValue(
int cueValue);
336 void setVol(
int volume);
338 void setPri(
int priority);
339 void setLoop(
int flag);
342 void holdAt(
int amount);
344 void orientAfterDriverChange();
347 void soPrimeSound(
bool dontQueue);
348 void soSetTimeIndex(uint timeIndex);
349 bool soServiceTracks();
350 void soPrimeChannelData();
351 void soRemoteReceive();
352 void soServiceTrackType0(
int trackIndex,
const byte *channelData);
353 void soUpdateDamper(
VoiceTypeStruct *voiceType,
int channelNum, VoiceType mode,
int v0);
354 void soPlaySound(
VoiceTypeStruct *vtStruct,
const byte *channelData,
int channelNum, VoiceType voiceType,
int v0,
int v1);
355 void soPlaySound2(
VoiceTypeStruct *vtStruct,
const byte *channelData,
int channelNum, VoiceType voiceType,
int v0);
356 void soProc38(
VoiceTypeStruct *vtStruct,
int channelNum, VoiceType voiceType,
int cmd,
int value);
357 void soProc40(
VoiceTypeStruct *vtStruct,
int channelNum,
int pitchBlend);
358 void soDoTrackCommand(
int channelNum,
int command,
int value);
359 bool soDoUpdateTracks(
int command,
int value);
360 void soSetTrackPos(
int trackIndex,
int trackPos,
int cueValue);
362 void soServiceTrackType1(
int trackIndex,
const byte *channelData);
375 void dispatch()
override;
377 void play(
int soundNum,
EventHandler *endAction = NULL,
int volume = 127);
379 void prime(
int soundNum,
Action *action = NULL);
381 void go() { _sound.go(); }
382 void hault(
void) { _sound.halt(); }
383 bool isPlaying() {
return _sound.isPlaying(); }
384 int getSoundNum()
const {
return _sound.getSoundNum(); }
385 bool isPaused()
const {
return _sound.isPaused(); }
386 bool isMuted()
const {
return _sound.isMuted(); }
387 void pause(
bool flag) { _sound.pause(flag); }
388 void mute(
bool flag) { _sound.mute(flag); }
389 void fade(
int fadeDest,
int fadeSteps,
int fadeTicks,
bool stopAfterFadeFlag,
EventHandler *endAction);
390 void fadeIn() { fade(127, 5, 10,
false, NULL); }
391 void fadeOut(
Action *action) { fade(0, 5, 10,
true, action); }
392 void setTimeIndex(uint32 timeIndex) { _sound.setTimeIndex(timeIndex); }
393 uint32 getTimeIndex()
const {
return _sound.getTimeIndex(); }
394 void setPri(
int v) { _sound.setPri(v); }
395 void setLoop(
int total) { _sound.setLoop(total); }
396 int getPri()
const {
return _sound.getPri(); }
397 int getLoop() {
return _sound.getLoop(); }
398 void setVol(
int volume) { _sound.setVol(volume); }
399 int getVol()
const {
return _sound.getVol(); }
400 void holdAt(
int v) { _sound.holdAt(v); }
401 void release() { _sound.release(); }
402 void fadeSound(
int soundNum);
411 void changeSound(
int soundNum);
415 void signal()
override;
429 ResFileData _resData;
436 static uint32 getFileOffset(
const uint16 *data,
int count,
int voiceNum);
444 bool isPlaying()
const;
446 void remove()
override;
447 void dispatch()
override;
450 #define ADLIB_CHANNEL_COUNT 9 457 byte _portContents[256];
458 const byte *_patchData;
463 bool _channelVoiced[ADLIB_CHANNEL_COUNT];
464 int _channelVolume[ADLIB_CHANNEL_COUNT];
465 int _v4405E[ADLIB_CHANNEL_COUNT];
466 int _v44067[ADLIB_CHANNEL_COUNT];
467 int _v44070[ADLIB_CHANNEL_COUNT];
468 int _v44079[ADLIB_CHANNEL_COUNT];
469 int _v44082[ADLIB_CHANNEL_COUNT + 1];
470 int _pitchBlend[ADLIB_CHANNEL_COUNT];
471 int _v4409E[ADLIB_CHANNEL_COUNT];
474 void write(byte reg, byte value);
476 void updateChannelVolume(
int channel);
477 void setVoice(
int channel);
478 void clearVoice(
int channel);
479 void updateChannel(
int channel);
480 void setFrequency(
int channel);
485 bool open()
override;
486 void close()
override;
487 bool reset()
override;
488 const GroupData *getGroupData()
override;
489 void installPatch(
const byte *data,
int size)
override;
490 int setMasterVolume(
int volume)
override;
491 void playSound(
const byte *channelData,
int dataOffset,
int program,
int channel,
int v0,
int v1)
override;
492 void updateVoice(
int channel)
override;
493 void proc38(
int channel,
int cmd,
int value)
override;
494 void setPitch(
int channel,
int pitchBlend)
override;
510 const byte *_channelData;
515 bool open()
override;
516 void close()
override;
517 bool reset()
override;
518 const GroupData *getGroupData()
override;
519 int setMasterVolume(
int volume)
override;
520 void playSound(
const byte *channelData,
int dataOffset,
int program,
int channel,
int v0,
int v1)
override;
521 void updateVoice(
int channel)
override;
522 void proc38(
int channel,
int cmd,
int value)
override;
523 void proc42(
int channel,
int cmd,
int value,
int *v1,
int *v2)
override;
Definition: saveload.h:115
Definition: blueforce_dialogs.h:30
Definition: saveload.h:63
Definition: audiostream.h:370
Definition: saveload.h:90