2011-02-14 09:37:27 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TSAGE_SOUND_H
|
|
|
|
#define TSAGE_SOUND_H
|
|
|
|
|
|
|
|
#include "common/scummsys.h"
|
2011-06-20 13:02:59 +00:00
|
|
|
#include "common/mutex.h"
|
2011-06-27 12:54:28 +00:00
|
|
|
#include "common/queue.h"
|
2011-06-01 11:02:00 +00:00
|
|
|
#include "audio/audiostream.h"
|
|
|
|
#include "audio/fmopl.h"
|
|
|
|
#include "audio/mixer.h"
|
2011-05-01 05:23:30 +00:00
|
|
|
#include "common/list.h"
|
2011-02-14 09:37:27 +00:00
|
|
|
#include "tsage/saveload.h"
|
2011-04-27 11:23:47 +00:00
|
|
|
#include "tsage/core.h"
|
2011-02-14 09:37:27 +00:00
|
|
|
|
2011-08-15 10:47:59 +00:00
|
|
|
namespace TsAGE {
|
2011-02-14 09:37:27 +00:00
|
|
|
|
2011-05-01 05:23:30 +00:00
|
|
|
class Sound;
|
|
|
|
|
2011-05-01 09:28:30 +00:00
|
|
|
#define SOUND_ARR_SIZE 16
|
2011-05-04 13:13:15 +00:00
|
|
|
#define ROLAND_DRIVER_NUM 2
|
|
|
|
#define ADLIB_DRIVER_NUM 3
|
2011-07-02 00:39:57 +00:00
|
|
|
#define SBLASTER_DRIVER_NUM 4
|
2011-07-24 11:25:00 +00:00
|
|
|
#define CALLBACKS_PER_SECOND 60
|
2011-05-01 09:28:30 +00:00
|
|
|
|
2011-05-01 05:23:30 +00:00
|
|
|
struct trackInfoStruct {
|
2011-06-04 23:16:56 +00:00
|
|
|
int _numTracks;
|
|
|
|
int _chunks[SOUND_ARR_SIZE];
|
|
|
|
int _voiceTypes[SOUND_ARR_SIZE];
|
2011-05-01 09:28:30 +00:00
|
|
|
};
|
|
|
|
|
2011-05-04 13:13:15 +00:00
|
|
|
enum SoundDriverStatus {SNDSTATUS_FAILED = 0, SNDSTATUS_DETECTED = 1, SNDSTATUS_SKIPPED = 2};
|
2011-06-05 12:39:05 +00:00
|
|
|
enum VoiceType {VOICETYPE_0 = 0, VOICETYPE_1 = 1};
|
2011-05-04 13:13:15 +00:00
|
|
|
|
2011-05-01 09:28:30 +00:00
|
|
|
class SoundDriverEntry {
|
|
|
|
public:
|
2012-09-03 05:58:35 +00:00
|
|
|
int _driverNum;
|
|
|
|
SoundDriverStatus _status;
|
|
|
|
int _field2, _field6;
|
|
|
|
Common::String _shortDescription;
|
|
|
|
Common::String _longDescription;
|
2011-05-01 09:28:30 +00:00
|
|
|
};
|
|
|
|
|
2011-05-18 10:32:40 +00:00
|
|
|
struct GroupData {
|
2012-09-03 05:58:35 +00:00
|
|
|
uint32 _groupMask;
|
|
|
|
const byte *_pData;
|
2011-05-18 10:32:40 +00:00
|
|
|
};
|
|
|
|
|
2011-06-27 12:54:28 +00:00
|
|
|
struct RegisterValue {
|
|
|
|
uint8 _regNum;
|
|
|
|
uint8 _value;
|
|
|
|
|
2011-09-26 22:40:10 +00:00
|
|
|
RegisterValue(int regNum, int value) {
|
2011-06-27 12:54:28 +00:00
|
|
|
_regNum = regNum; _value = value;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-05-01 09:28:30 +00:00
|
|
|
class SoundDriver {
|
2011-05-04 13:13:15 +00:00
|
|
|
public:
|
2011-05-01 09:28:30 +00:00
|
|
|
Common::String _shortDescription, _longDescription;
|
2011-05-04 13:13:15 +00:00
|
|
|
int _minVersion, _maxVersion;
|
2011-05-12 13:09:48 +00:00
|
|
|
// The following fields were originally held in separate arrays in the SoundManager class
|
|
|
|
uint32 _groupMask;
|
2011-05-18 10:32:40 +00:00
|
|
|
const GroupData *_groupOffset;
|
2011-06-04 23:44:48 +00:00
|
|
|
int _driverResID;
|
2011-05-01 09:28:30 +00:00
|
|
|
public:
|
2011-05-12 13:09:48 +00:00
|
|
|
SoundDriver();
|
2011-11-26 12:33:42 +00:00
|
|
|
virtual ~SoundDriver() {}
|
2011-05-12 13:09:48 +00:00
|
|
|
|
2011-05-01 09:28:30 +00:00
|
|
|
const Common::String &getShortDriverDescription() { return _shortDescription; }
|
|
|
|
const Common::String &getLongDriverDescription() { return _longDescription; }
|
|
|
|
|
2011-06-13 06:31:35 +00:00
|
|
|
virtual bool open() { return true; } // Method #0
|
|
|
|
virtual void close() {} // Method #1
|
|
|
|
virtual bool reset() { return true; } // Method #2
|
|
|
|
virtual const GroupData *getGroupData() { return NULL; } // Method #3
|
2011-06-14 14:08:40 +00:00
|
|
|
virtual void installPatch(const byte *data, int size) {} // Method #4
|
2011-06-13 06:31:35 +00:00
|
|
|
virtual void poll() {} // Method #5
|
2013-10-26 22:12:48 +00:00
|
|
|
virtual void method6() {} // Method #6
|
2011-06-13 06:31:35 +00:00
|
|
|
virtual int setMasterVolume(int volume) { return 0; } // Method #7
|
|
|
|
virtual void proc16() {} // Method #8
|
|
|
|
virtual void proc18(int al, VoiceType voiceType) {} // Method #9
|
|
|
|
virtual void proc20(int al, VoiceType voiceType) {} // Method #10
|
|
|
|
virtual void proc22(int al, VoiceType voiceType, int v3) {} // Method #11
|
2011-06-08 11:23:25 +00:00
|
|
|
virtual void proc24(int channel, int voiceIndex, Sound *sound, int v1, int v2) {}
|
2011-06-13 06:31:35 +00:00
|
|
|
virtual void setProgram(int channel, int program) {} // Method #13
|
2011-05-24 10:07:41 +00:00
|
|
|
virtual void setVolume1(int channel, int v2, int v3, int volume) {}
|
2011-06-13 06:31:35 +00:00
|
|
|
virtual void setPitchBlend(int channel, int pitchBlend) {} // Method #15
|
2011-07-28 10:42:29 +00:00
|
|
|
virtual void playSound(const byte *channelData, int dataOffset, int program, int channel, int v0, int v1) {}// Method #16
|
2011-06-13 06:31:35 +00:00
|
|
|
virtual void updateVoice(int channel) {} // Method #17
|
|
|
|
virtual void proc36() {} // Method #18
|
|
|
|
virtual void proc38(int channel, int cmd, int value) {} // Method #19
|
2011-06-14 11:27:54 +00:00
|
|
|
virtual void setPitch(int channel, int pitchBlend) {} // Method #20
|
2011-07-02 00:39:57 +00:00
|
|
|
virtual void proc42(int channel, int cmd, int value, int *v1, int *v2) {} // Method #21
|
2011-05-18 10:32:40 +00:00
|
|
|
};
|
|
|
|
|
2011-06-05 12:39:05 +00:00
|
|
|
struct VoiceStructEntryType0 {
|
|
|
|
Sound *_sound;
|
|
|
|
int _channelNum;
|
2011-06-10 13:17:12 +00:00
|
|
|
int _priority;
|
2011-06-05 12:39:05 +00:00
|
|
|
int _fieldA;
|
|
|
|
Sound *_sound2;
|
|
|
|
int _channelNum2;
|
2011-06-10 13:17:12 +00:00
|
|
|
int _priority2;
|
2011-06-05 12:39:05 +00:00
|
|
|
int _field12;
|
|
|
|
Sound *_sound3;
|
|
|
|
int _channelNum3;
|
2011-06-10 13:17:12 +00:00
|
|
|
int _priority3;
|
2011-06-05 12:39:05 +00:00
|
|
|
int _field1A;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct VoiceStructEntryType1 {
|
2011-05-18 10:32:40 +00:00
|
|
|
int _field4;
|
2011-06-05 12:39:05 +00:00
|
|
|
int _field5;
|
2011-05-18 10:32:40 +00:00
|
|
|
int _field6;
|
2011-06-06 12:15:03 +00:00
|
|
|
Sound *_sound;
|
|
|
|
int _channelNum;
|
2011-06-09 12:50:00 +00:00
|
|
|
int _priority;
|
2011-06-06 12:15:03 +00:00
|
|
|
Sound *_sound2;
|
|
|
|
int _channelNum2;
|
2011-06-09 12:50:00 +00:00
|
|
|
int _priority2;
|
2011-06-06 12:15:03 +00:00
|
|
|
Sound *_sound3;
|
|
|
|
int _channelNum3;
|
2011-06-09 12:50:00 +00:00
|
|
|
int _priority3;
|
2011-05-18 10:32:40 +00:00
|
|
|
};
|
|
|
|
|
2011-06-05 12:39:05 +00:00
|
|
|
struct VoiceStructEntry {
|
2011-06-06 12:15:03 +00:00
|
|
|
int _voiceNum;
|
2011-06-05 12:39:05 +00:00
|
|
|
int _field1;
|
|
|
|
SoundDriver *_driver;
|
|
|
|
|
|
|
|
VoiceStructEntryType0 _type0;
|
|
|
|
VoiceStructEntryType1 _type1;
|
|
|
|
};
|
2011-05-24 10:07:41 +00:00
|
|
|
|
2011-06-05 12:39:05 +00:00
|
|
|
class VoiceTypeStruct {
|
2011-05-18 10:32:40 +00:00
|
|
|
public:
|
2011-05-24 10:07:41 +00:00
|
|
|
VoiceType _voiceType;
|
2011-06-13 06:31:35 +00:00
|
|
|
int _total;
|
2011-06-09 12:50:00 +00:00
|
|
|
int _numVoices;
|
2011-06-05 12:39:05 +00:00
|
|
|
int _field3;
|
2011-05-18 10:32:40 +00:00
|
|
|
|
|
|
|
Common::Array<VoiceStructEntry> _entries;
|
2011-05-01 05:23:30 +00:00
|
|
|
};
|
|
|
|
|
2011-04-13 19:27:46 +00:00
|
|
|
class SoundManager : public SaveListener {
|
2011-05-01 09:28:30 +00:00
|
|
|
private:
|
2011-05-04 13:13:15 +00:00
|
|
|
SoundDriver *instantiateDriver(int driverNum);
|
2011-05-01 05:23:30 +00:00
|
|
|
public:
|
2011-11-14 17:19:32 +00:00
|
|
|
bool _sndmgrReady;
|
2011-06-04 23:44:48 +00:00
|
|
|
int _ourSndResVersion, _ourDrvResVersion;
|
2011-06-22 13:40:25 +00:00
|
|
|
SynchronizedList<Sound *> _playList;
|
2011-06-04 23:44:48 +00:00
|
|
|
Common::List<SoundDriver *> _installedDrivers;
|
2011-06-05 12:39:05 +00:00
|
|
|
VoiceTypeStruct *_voiceTypeStructPtrs[SOUND_ARR_SIZE];
|
2011-06-04 23:44:48 +00:00
|
|
|
uint32 _groupsAvail;
|
|
|
|
int _masterVol;
|
2011-06-21 11:42:42 +00:00
|
|
|
int _newVolume;
|
2011-06-20 13:02:59 +00:00
|
|
|
Common::Mutex _serverDisabledMutex;
|
|
|
|
Common::Mutex _serverSuspendedMutex;
|
2011-05-04 13:13:15 +00:00
|
|
|
bool _driversDetected;
|
2011-06-22 13:40:25 +00:00
|
|
|
SynchronizedList<Sound *> _soundList;
|
2011-05-04 13:13:15 +00:00
|
|
|
Common::List<SoundDriverEntry> _availableDrivers;
|
2011-05-18 10:32:40 +00:00
|
|
|
bool _needToRethink;
|
2011-06-05 12:39:05 +00:00
|
|
|
// Misc flags
|
|
|
|
bool _soTimeIndexFlag;
|
2011-02-14 09:37:27 +00:00
|
|
|
public:
|
2011-05-01 09:28:30 +00:00
|
|
|
SoundManager();
|
|
|
|
~SoundManager();
|
|
|
|
|
2011-05-18 10:32:40 +00:00
|
|
|
void dispatch();
|
2011-05-04 08:47:12 +00:00
|
|
|
virtual void listenerSynchronize(Serializer &s);
|
2011-02-14 09:37:27 +00:00
|
|
|
virtual void postInit();
|
2011-05-18 10:32:40 +00:00
|
|
|
void syncSounds();
|
2011-06-20 09:42:13 +00:00
|
|
|
void update();
|
2011-02-14 09:37:27 +00:00
|
|
|
|
|
|
|
static void saveNotifier(bool postFlag);
|
|
|
|
void saveNotifierProc(bool postFlag);
|
|
|
|
static void loadNotifier(bool postFlag);
|
|
|
|
void loadNotifierProc(bool postFlag);
|
|
|
|
|
2011-05-04 13:13:15 +00:00
|
|
|
void installConfigDrivers();
|
|
|
|
Common::List<SoundDriverEntry> &buildDriverList(bool detectFlag);
|
|
|
|
Common::List<SoundDriverEntry> &getDriverList(bool detectFlag);
|
2011-05-01 09:28:30 +00:00
|
|
|
void dumpDriverList();
|
2011-05-04 13:13:15 +00:00
|
|
|
void installDriver(int driverNum);
|
|
|
|
bool isInstalled(int driverNum) const;
|
|
|
|
void unInstallDriver(int driverNum);
|
2011-05-01 05:23:30 +00:00
|
|
|
void checkResVersion(const byte *soundData);
|
|
|
|
int determineGroup(const byte *soundData);
|
|
|
|
int extractPriority(const byte *soundData);
|
|
|
|
int extractLoop(const byte *soundData);
|
2011-05-01 09:28:30 +00:00
|
|
|
bool isOnPlayList(Sound *sound);
|
|
|
|
void extractTrackInfo(trackInfoStruct *trackInfo, const byte *soundData, int groupNum);
|
2011-05-01 05:23:30 +00:00
|
|
|
void addToSoundList(Sound *sound);
|
|
|
|
void removeFromSoundList(Sound *sound);
|
|
|
|
void addToPlayList(Sound *sound);
|
|
|
|
void removeFromPlayList(Sound *sound);
|
|
|
|
void rethinkVoiceTypes();
|
|
|
|
void updateSoundVol(Sound *sound);
|
|
|
|
void updateSoundPri(Sound *sound);
|
|
|
|
void updateSoundLoop(Sound *sound);
|
2011-05-01 09:28:30 +00:00
|
|
|
void setMasterVol(int volume);
|
|
|
|
int getMasterVol() const;
|
|
|
|
void loadSound(int soundNum, bool showErrors);
|
|
|
|
void unloadSound(int soundNum);
|
2011-08-01 12:36:21 +00:00
|
|
|
bool isFading();
|
2011-05-01 05:23:30 +00:00
|
|
|
|
2011-06-05 12:39:05 +00:00
|
|
|
// _sf methods
|
2011-05-07 04:13:52 +00:00
|
|
|
static SoundManager &sfManager();
|
2012-09-03 05:58:35 +00:00
|
|
|
static void sfTerminate();
|
|
|
|
static int sfDetermineGroup(const byte *soundData);
|
|
|
|
static void sfAddToPlayList(Sound *sound);
|
|
|
|
static void sfRemoveFromPlayList(Sound *sound);
|
|
|
|
static bool sfIsOnPlayList(Sound *sound);
|
|
|
|
static void sfRethinkSoundDrivers();
|
|
|
|
static void sfRethinkVoiceTypes();
|
|
|
|
static void sfUpdateVolume(Sound *sound);
|
|
|
|
static void sfDereferenceAll();
|
|
|
|
static void sfUpdatePriority(Sound *sound);
|
|
|
|
static void sfUpdateLoop(Sound *sound);
|
|
|
|
static void sfSetMasterVol(int volume);
|
|
|
|
static void sfExtractTrackInfo(trackInfoStruct *trackInfo, const byte *soundData, int groupNum);
|
|
|
|
static void sfExtractGroupMask();
|
|
|
|
static bool sfInstallDriver(SoundDriver *driver);
|
|
|
|
static void sfUnInstallDriver(SoundDriver *driver);
|
|
|
|
static void sfInstallPatchBank(SoundDriver *driver, const byte *bankData);
|
|
|
|
static void sfDoAddToPlayList(Sound *sound);
|
|
|
|
static bool sfDoRemoveFromPlayList(Sound *sound);
|
|
|
|
static void sfDoUpdateVolume(Sound *sound);
|
|
|
|
static void sfSoundServer();
|
|
|
|
static void sfProcessFading();
|
|
|
|
static void sfUpdateVoiceStructs();
|
|
|
|
static void sfUpdateVoiceStructs2();
|
|
|
|
static void sfUpdateCallback(void *ref);
|
2011-04-29 10:19:37 +00:00
|
|
|
};
|
|
|
|
|
2011-04-27 11:23:47 +00:00
|
|
|
class Sound: public EventHandler {
|
2011-04-29 10:19:37 +00:00
|
|
|
private:
|
2011-06-19 13:21:02 +00:00
|
|
|
void _prime(int soundResID, bool dontQueue);
|
2013-10-15 02:58:29 +00:00
|
|
|
void _primeBuffer(const byte *soundData);
|
2011-04-29 10:19:37 +00:00
|
|
|
void _unPrime();
|
|
|
|
public:
|
2011-06-04 23:16:56 +00:00
|
|
|
bool _stoppedAsynchronously;
|
|
|
|
int _soundResID;
|
|
|
|
int _group;
|
|
|
|
int _sndResPriority;
|
|
|
|
int _fixedPriority;
|
2011-06-20 12:33:55 +00:00
|
|
|
int _sndResLoop;
|
|
|
|
int _fixedLoop;
|
2011-04-29 10:19:37 +00:00
|
|
|
int _priority;
|
|
|
|
int _volume;
|
2011-06-05 12:39:05 +00:00
|
|
|
int _loop;
|
2011-06-04 23:16:56 +00:00
|
|
|
int _pausedCount;
|
|
|
|
int _mutedCount;
|
|
|
|
int _hold;
|
2011-05-01 05:23:30 +00:00
|
|
|
int _cueValue;
|
2011-06-04 23:16:56 +00:00
|
|
|
int _fadeDest;
|
|
|
|
int _fadeSteps;
|
|
|
|
int _fadeTicks;
|
|
|
|
int _fadeCounter;
|
|
|
|
bool _stopAfterFadeFlag;
|
2011-06-22 13:40:25 +00:00
|
|
|
uint32 _timer;
|
|
|
|
uint32 _newTimeIndex;
|
2011-06-04 23:16:56 +00:00
|
|
|
int _loopTimer;
|
|
|
|
int _chProgram[SOUND_ARR_SIZE];
|
|
|
|
int _chModulation[SOUND_ARR_SIZE];
|
|
|
|
int _chVolume[SOUND_ARR_SIZE];
|
|
|
|
int _chPan[SOUND_ARR_SIZE];
|
|
|
|
int _chDamper[SOUND_ARR_SIZE];
|
|
|
|
int _chPitchBlend[SOUND_ARR_SIZE];
|
|
|
|
int _chVoiceType[SOUND_ARR_SIZE];
|
|
|
|
int _chNumVoices[SOUND_ARR_SIZE];
|
|
|
|
int _chSubPriority[SOUND_ARR_SIZE];
|
|
|
|
int _chFlags[SOUND_ARR_SIZE];
|
2011-06-14 11:27:54 +00:00
|
|
|
bool _chWork[SOUND_ARR_SIZE];
|
2011-04-29 10:19:37 +00:00
|
|
|
trackInfoStruct _trackInfo;
|
2011-06-04 23:16:56 +00:00
|
|
|
byte *_channelData[SOUND_ARR_SIZE];
|
|
|
|
int _trkChannel[SOUND_ARR_SIZE];
|
|
|
|
int _trkState[SOUND_ARR_SIZE];
|
|
|
|
int _trkLoopState[SOUND_ARR_SIZE];
|
|
|
|
int _trkIndex[SOUND_ARR_SIZE];
|
|
|
|
int _trkLoopIndex[SOUND_ARR_SIZE];
|
|
|
|
int _trkRest[SOUND_ARR_SIZE];
|
|
|
|
int _trkLoopRest[SOUND_ARR_SIZE];
|
|
|
|
|
2011-04-29 10:19:37 +00:00
|
|
|
bool _primed;
|
2011-05-26 10:30:30 +00:00
|
|
|
bool _isEmpty;
|
2011-06-04 23:16:56 +00:00
|
|
|
byte *_remoteReceiver;
|
2011-04-27 11:23:47 +00:00
|
|
|
public:
|
2011-05-01 05:23:30 +00:00
|
|
|
Sound();
|
2011-05-27 10:55:09 +00:00
|
|
|
~Sound();
|
2011-05-01 05:23:30 +00:00
|
|
|
|
2011-06-22 13:40:25 +00:00
|
|
|
void synchronize(Serializer &s);
|
|
|
|
void orientAfterRestore();
|
|
|
|
|
2011-06-04 23:16:56 +00:00
|
|
|
void play(int soundResID);
|
2011-04-27 11:23:47 +00:00
|
|
|
void stop();
|
2011-06-04 23:16:56 +00:00
|
|
|
void prime(int soundResID);
|
2011-04-27 11:23:47 +00:00
|
|
|
void unPrime();
|
|
|
|
void go();
|
2011-04-27 12:22:20 +00:00
|
|
|
void halt(void);
|
2011-05-01 05:23:30 +00:00
|
|
|
bool isPlaying();
|
2011-04-27 11:23:47 +00:00
|
|
|
int getSoundNum() const;
|
2011-04-27 12:22:20 +00:00
|
|
|
bool isPrimed() const;
|
2011-04-27 11:23:47 +00:00
|
|
|
bool isPaused() const;
|
|
|
|
bool isMuted() const;
|
2011-05-01 05:23:30 +00:00
|
|
|
void pause(bool flag);
|
|
|
|
void mute(bool flag);
|
2011-06-20 11:09:39 +00:00
|
|
|
void fade(int fadeDest, int fadeSteps, int fadeTicks, bool stopAfterFadeFlag);
|
2011-04-27 11:23:47 +00:00
|
|
|
void setTimeIndex(uint32 timeIndex);
|
|
|
|
uint32 getTimeIndex() const;
|
2011-05-01 05:23:30 +00:00
|
|
|
int getCueValue() const;
|
|
|
|
void setCueValue(int cueValue);
|
2011-04-27 12:22:20 +00:00
|
|
|
void setVol(int volume);
|
|
|
|
int getVol() const;
|
2011-05-01 05:23:30 +00:00
|
|
|
void setPri(int priority);
|
2011-06-20 12:33:55 +00:00
|
|
|
void setLoop(int flag);
|
2011-04-27 11:23:47 +00:00
|
|
|
int getPri() const;
|
2011-06-20 12:33:55 +00:00
|
|
|
int getLoop();
|
2011-05-01 05:23:30 +00:00
|
|
|
void holdAt(int amount);
|
2011-04-27 11:23:47 +00:00
|
|
|
void release();
|
2011-05-04 13:13:15 +00:00
|
|
|
void orientAfterDriverChange();
|
2011-06-05 12:39:05 +00:00
|
|
|
|
|
|
|
// _so methods
|
2012-09-03 05:58:35 +00:00
|
|
|
void soPrimeSound(bool dontQueue);
|
|
|
|
void soSetTimeIndex(uint timeIndex);
|
|
|
|
bool soServiceTracks();
|
|
|
|
void soPrimeChannelData();
|
|
|
|
void soRemoteReceive();
|
|
|
|
void soServiceTrackType0(int trackIndex, const byte *channelData);
|
|
|
|
void soUpdateDamper(VoiceTypeStruct *voiceType, int channelNum, VoiceType mode, int v0);
|
|
|
|
void soPlaySound(VoiceTypeStruct *vtStruct, const byte *channelData, int channelNum, VoiceType voiceType, int v0, int v1);
|
|
|
|
void soPlaySound2(VoiceTypeStruct *vtStruct, const byte *channelData, int channelNum, VoiceType voiceType, int v0);
|
|
|
|
void soProc38(VoiceTypeStruct *vtStruct, int channelNum, VoiceType voiceType, int cmd, int value);
|
|
|
|
void soProc40(VoiceTypeStruct *vtStruct, int channelNum, int pitchBlend);
|
|
|
|
void soDoTrackCommand(int channelNum, int command, int value);
|
|
|
|
bool soDoUpdateTracks(int command, int value);
|
|
|
|
void soSetTrackPos(int trackIndex, int trackPos, int cueValue);
|
|
|
|
|
|
|
|
void soServiceTrackType1(int trackIndex, const byte *channelData);
|
|
|
|
int soFindSound(VoiceTypeStruct *vtStruct, int channelNum);
|
2011-04-27 11:23:47 +00:00
|
|
|
};
|
|
|
|
|
2011-04-27 12:22:20 +00:00
|
|
|
class ASound: public EventHandler {
|
|
|
|
public:
|
|
|
|
Sound _sound;
|
2013-11-10 20:30:24 +00:00
|
|
|
EventHandler *_endAction;
|
2011-05-18 10:32:40 +00:00
|
|
|
int _cueValue;
|
2011-04-27 12:22:20 +00:00
|
|
|
|
|
|
|
ASound();
|
2011-06-22 08:58:59 +00:00
|
|
|
~ASound();
|
2011-04-27 12:22:20 +00:00
|
|
|
virtual void synchronize(Serializer &s);
|
|
|
|
virtual void dispatch();
|
|
|
|
|
2013-11-10 20:30:24 +00:00
|
|
|
void play(int soundNum, EventHandler *endAction = NULL, int volume = 127);
|
2011-04-27 12:22:20 +00:00
|
|
|
void stop();
|
|
|
|
void prime(int soundNum, Action *action = NULL);
|
|
|
|
void unPrime();
|
|
|
|
void go() { _sound.go(); }
|
|
|
|
void hault(void) { _sound.halt(); }
|
2011-05-01 05:23:30 +00:00
|
|
|
bool isPlaying() { return _sound.isPlaying(); }
|
2011-04-27 12:22:20 +00:00
|
|
|
int getSoundNum() const { return _sound.getSoundNum(); }
|
|
|
|
bool isPaused() const { return _sound.isPaused(); }
|
|
|
|
bool isMuted() const { return _sound.isMuted(); }
|
2011-05-01 05:23:30 +00:00
|
|
|
void pause(bool flag) { _sound.pause(flag); }
|
|
|
|
void mute(bool flag) { _sound.mute(flag); }
|
2013-11-10 20:30:24 +00:00
|
|
|
void fade(int fadeDest, int fadeSteps, int fadeTicks, bool stopAfterFadeFlag, EventHandler *endAction);
|
2011-06-20 11:09:39 +00:00
|
|
|
void fadeIn() { fade(127, 5, 10, false, NULL); }
|
|
|
|
void fadeOut(Action *action) { fade(0, 5, 10, true, action); }
|
2011-04-27 12:22:20 +00:00
|
|
|
void setTimeIndex(uint32 timeIndex) { _sound.setTimeIndex(timeIndex); }
|
|
|
|
uint32 getTimeIndex() const { return _sound.getTimeIndex(); }
|
|
|
|
void setPri(int v) { _sound.setPri(v); }
|
2011-06-20 12:33:55 +00:00
|
|
|
void setLoop(int total) { _sound.setLoop(total); }
|
2011-04-27 12:22:20 +00:00
|
|
|
int getPri() const { return _sound.getPri(); }
|
2011-06-20 12:33:55 +00:00
|
|
|
int getLoop() { return _sound.getLoop(); }
|
2011-04-27 12:22:20 +00:00
|
|
|
void setVol(int volume) { _sound.setVol(volume); }
|
|
|
|
int getVol() const { return _sound.getVol(); }
|
|
|
|
void holdAt(int v) { _sound.holdAt(v); }
|
|
|
|
void release() { _sound.release(); }
|
2011-08-07 13:14:09 +00:00
|
|
|
void fadeSound(int soundNum);
|
2011-04-27 12:22:20 +00:00
|
|
|
};
|
|
|
|
|
2011-08-07 13:14:09 +00:00
|
|
|
class ASoundExt: public ASound {
|
|
|
|
public:
|
|
|
|
int _soundNum;
|
|
|
|
|
|
|
|
ASoundExt();
|
2013-11-10 20:30:24 +00:00
|
|
|
void fadeOut2(EventHandler *endAction);
|
2011-08-26 09:07:43 +00:00
|
|
|
void changeSound(int soundNum);
|
2011-08-20 09:14:23 +00:00
|
|
|
|
2011-08-07 13:14:09 +00:00
|
|
|
virtual Common::String getClassName() { return "ASoundExt"; }
|
|
|
|
virtual void synchronize(Serializer &s);
|
|
|
|
virtual void signal();
|
|
|
|
};
|
|
|
|
|
2013-10-15 02:58:29 +00:00
|
|
|
class PlayStream: public EventHandler {
|
|
|
|
class ResFileData {
|
|
|
|
public:
|
|
|
|
int _fileChunkSize;
|
|
|
|
uint _indexSize;
|
|
|
|
uint _chunkSize;
|
|
|
|
|
|
|
|
void load(Common::SeekableReadStream &stream);
|
|
|
|
};
|
|
|
|
private:
|
|
|
|
Common::File _file;
|
|
|
|
ResFileData _resData;
|
2013-10-20 17:47:06 +00:00
|
|
|
Audio::QueuingAudioStream *_audioStream;
|
2013-10-16 02:35:26 +00:00
|
|
|
Audio::SoundHandle _soundHandle;
|
2013-10-15 02:58:29 +00:00
|
|
|
uint16 *_index;
|
|
|
|
EventHandler *_endAction;
|
2013-10-16 02:35:26 +00:00
|
|
|
int _voiceNum;
|
2013-10-15 02:58:29 +00:00
|
|
|
|
|
|
|
static uint32 getFileOffset(const uint16 *data, int count, int voiceNum);
|
|
|
|
public:
|
|
|
|
PlayStream();
|
|
|
|
virtual ~PlayStream();
|
2011-10-30 08:47:51 +00:00
|
|
|
|
2013-11-10 22:00:15 +00:00
|
|
|
bool setFile(const Common::String &filename);
|
2013-10-15 02:58:29 +00:00
|
|
|
bool play(int voiceNum, EventHandler *endAction);
|
|
|
|
void stop();
|
|
|
|
bool isPlaying() const;
|
|
|
|
|
|
|
|
virtual void remove();
|
|
|
|
virtual void dispatch();
|
2011-10-30 08:47:51 +00:00
|
|
|
};
|
2011-08-07 13:14:09 +00:00
|
|
|
|
2011-06-13 06:31:35 +00:00
|
|
|
#define ADLIB_CHANNEL_COUNT 9
|
|
|
|
|
2011-06-20 09:42:13 +00:00
|
|
|
class AdlibSoundDriver: public SoundDriver, Audio::AudioStream {
|
2011-05-18 10:32:40 +00:00
|
|
|
private:
|
|
|
|
GroupData _groupData;
|
2011-06-01 11:02:00 +00:00
|
|
|
Audio::Mixer *_mixer;
|
2011-06-13 06:31:35 +00:00
|
|
|
FM_OPL *_opl;
|
2011-06-20 09:42:13 +00:00
|
|
|
Audio::SoundHandle _soundHandle;
|
2011-06-13 06:31:35 +00:00
|
|
|
int _sampleRate;
|
|
|
|
byte _portContents[256];
|
|
|
|
const byte *_patchData;
|
|
|
|
int _masterVolume;
|
2011-06-27 12:54:28 +00:00
|
|
|
Common::Queue<RegisterValue> _queue;
|
2011-07-24 11:25:00 +00:00
|
|
|
int _samplesTillCallback;
|
|
|
|
int _samplesTillCallbackRemainder;
|
|
|
|
int _samplesPerCallback;
|
|
|
|
int _samplesPerCallbackRemainder;
|
2011-06-13 06:31:35 +00:00
|
|
|
|
|
|
|
bool _channelVoiced[ADLIB_CHANNEL_COUNT];
|
|
|
|
int _channelVolume[ADLIB_CHANNEL_COUNT];
|
|
|
|
int _v4405E[ADLIB_CHANNEL_COUNT];
|
|
|
|
int _v44067[ADLIB_CHANNEL_COUNT];
|
|
|
|
int _v44070[ADLIB_CHANNEL_COUNT];
|
|
|
|
int _v44079[ADLIB_CHANNEL_COUNT];
|
|
|
|
int _v44082[ADLIB_CHANNEL_COUNT + 1];
|
2011-06-14 11:27:54 +00:00
|
|
|
int _pitchBlend[ADLIB_CHANNEL_COUNT];
|
2011-06-13 06:31:35 +00:00
|
|
|
int _v4409E[ADLIB_CHANNEL_COUNT];
|
|
|
|
|
|
|
|
|
|
|
|
void write(byte reg, byte value);
|
2011-06-27 12:54:28 +00:00
|
|
|
void flush();
|
2011-06-13 06:31:35 +00:00
|
|
|
void updateChannelVolume(int channel);
|
|
|
|
void setVoice(int channel);
|
|
|
|
void clearVoice(int channel);
|
|
|
|
void updateChannel(int channel);
|
|
|
|
void setFrequency(int channel);
|
2011-05-04 13:13:15 +00:00
|
|
|
public:
|
2011-05-18 10:32:40 +00:00
|
|
|
AdlibSoundDriver();
|
2011-06-19 13:13:49 +00:00
|
|
|
virtual ~AdlibSoundDriver();
|
2011-06-13 06:31:35 +00:00
|
|
|
|
|
|
|
virtual bool open();
|
|
|
|
virtual void close();
|
|
|
|
virtual bool reset();
|
|
|
|
virtual const GroupData *getGroupData();
|
2011-06-14 14:08:40 +00:00
|
|
|
virtual void installPatch(const byte *data, int size);
|
2011-06-13 06:31:35 +00:00
|
|
|
virtual int setMasterVolume(int volume);
|
2011-07-28 10:42:29 +00:00
|
|
|
virtual void playSound(const byte *channelData, int dataOffset, int program, int channel, int v0, int v1);
|
2011-06-13 06:31:35 +00:00
|
|
|
virtual void updateVoice(int channel);
|
|
|
|
virtual void proc38(int channel, int cmd, int value);
|
2011-06-14 11:27:54 +00:00
|
|
|
virtual void setPitch(int channel, int pitchBlend);
|
2011-06-20 09:42:13 +00:00
|
|
|
|
|
|
|
// AudioStream interface
|
|
|
|
virtual int readBuffer(int16 *buffer, const int numSamples);
|
|
|
|
virtual bool isStereo() const { return false; }
|
|
|
|
virtual bool endOfData() const { return false; }
|
|
|
|
virtual int getRate() const { return _sampleRate; }
|
|
|
|
|
|
|
|
void update(int16 *buf, int len);
|
2011-05-04 13:13:15 +00:00
|
|
|
};
|
|
|
|
|
2011-07-29 10:05:02 +00:00
|
|
|
class SoundBlasterDriver: public SoundDriver {
|
2011-06-27 12:54:28 +00:00
|
|
|
private:
|
|
|
|
GroupData _groupData;
|
|
|
|
Audio::Mixer *_mixer;
|
|
|
|
Audio::SoundHandle _soundHandle;
|
2011-07-27 12:20:29 +00:00
|
|
|
Audio::QueuingAudioStream *_audioStream;
|
2011-06-27 12:54:28 +00:00
|
|
|
int _sampleRate;
|
|
|
|
|
2011-07-02 00:39:57 +00:00
|
|
|
byte _masterVolume;
|
|
|
|
byte _channelVolume;
|
2011-07-27 09:38:10 +00:00
|
|
|
const byte *_channelData;
|
2011-06-27 12:54:28 +00:00
|
|
|
public:
|
2011-07-29 10:05:02 +00:00
|
|
|
SoundBlasterDriver();
|
|
|
|
virtual ~SoundBlasterDriver();
|
2011-06-27 12:54:28 +00:00
|
|
|
|
|
|
|
virtual bool open();
|
|
|
|
virtual void close();
|
|
|
|
virtual bool reset();
|
|
|
|
virtual const GroupData *getGroupData();
|
|
|
|
virtual int setMasterVolume(int volume);
|
2011-07-28 10:42:29 +00:00
|
|
|
virtual void playSound(const byte *channelData, int dataOffset, int program, int channel, int v0, int v1);
|
2011-06-27 12:54:28 +00:00
|
|
|
virtual void updateVoice(int channel);
|
|
|
|
virtual void proc38(int channel, int cmd, int value);
|
2011-07-02 00:39:57 +00:00
|
|
|
virtual void proc42(int channel, int cmd, int value, int *v1, int *v2);
|
2011-06-27 12:54:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-08-15 10:47:59 +00:00
|
|
|
} // End of namespace TsAGE
|
2011-02-14 09:37:27 +00:00
|
|
|
|
|
|
|
#endif
|