2007-05-30 21:56:52 +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.
|
2004-01-06 17:28:29 +00:00
|
|
|
*
|
|
|
|
* 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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2004-01-06 17:28:29 +00:00
|
|
|
*
|
2006-02-11 09:55:41 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2004-01-06 17:28:29 +00:00
|
|
|
*/
|
|
|
|
|
2007-02-19 17:48:19 +00:00
|
|
|
#if !defined(SCUMM_IMUSE_DIGI_H) && !defined(DISABLE_SCUMM_7_8)
|
|
|
|
#define SCUMM_IMUSE_DIGI_H
|
2004-01-06 17:28:29 +00:00
|
|
|
|
|
|
|
#include "common/scummsys.h"
|
2005-01-10 22:51:42 +00:00
|
|
|
#include "common/util.h"
|
2004-01-06 17:28:29 +00:00
|
|
|
|
|
|
|
#include "scumm/imuse_digi/dimuse.h"
|
|
|
|
#include "scumm/imuse_digi/dimuse_bndmgr.h"
|
|
|
|
#include "scumm/imuse_digi/dimuse_sndmgr.h"
|
|
|
|
#include "scumm/music.h"
|
2005-01-09 03:15:59 +00:00
|
|
|
#include "scumm/sound.h"
|
2004-01-06 17:28:29 +00:00
|
|
|
|
|
|
|
#include "sound/mixer.h"
|
|
|
|
#include "sound/audiostream.h"
|
|
|
|
|
|
|
|
namespace Scumm {
|
|
|
|
|
2004-03-27 20:26:25 +00:00
|
|
|
#define MAX_DIGITAL_TRACKS 8
|
2004-04-11 14:48:50 +00:00
|
|
|
#define MAX_DIGITAL_FADETRACKS 8
|
2004-01-06 17:28:29 +00:00
|
|
|
|
2004-01-17 08:34:54 +00:00
|
|
|
struct imuseDigTable;
|
2004-01-14 22:07:24 +00:00
|
|
|
struct imuseComiTable;
|
2005-04-26 13:17:11 +00:00
|
|
|
class Serializer;
|
2006-10-07 13:57:06 +00:00
|
|
|
class ScummEngine_v7;
|
2004-01-14 22:07:24 +00:00
|
|
|
|
2007-03-02 17:30:29 +00:00
|
|
|
// These flag bits correspond exactly to the sound mixer flags of March 2007.
|
|
|
|
// We don't want to use the mixer flags directly, because then our saved games
|
|
|
|
// will break in interesting ways if the mixer flags are ever assigned new
|
|
|
|
// values. Now they should keep working, as long as these flags don't change.
|
|
|
|
|
|
|
|
enum {
|
|
|
|
kFlagUnsigned = 1 << 0,
|
|
|
|
kFlag16Bits = 1 << 1,
|
|
|
|
kFlagLittleEndian = 1 << 2,
|
|
|
|
kFlagStereo = 1 << 3,
|
|
|
|
kFlagReverseStereo = 1 << 4
|
|
|
|
|
|
|
|
// Not used by Digital iMUSE
|
|
|
|
// kFlagAutoFree = 1 << 5,
|
|
|
|
// kFlagLoop = 1 << 6
|
|
|
|
};
|
|
|
|
|
2004-01-06 17:28:29 +00:00
|
|
|
class IMuseDigital : public MusicEngine {
|
|
|
|
private:
|
|
|
|
|
2007-06-01 08:59:21 +00:00
|
|
|
int _callbackFps; // value how many times callback needs to be called per second
|
2006-02-05 13:48:27 +00:00
|
|
|
|
2004-01-06 17:28:29 +00:00
|
|
|
struct Track {
|
2007-06-01 08:59:21 +00:00
|
|
|
int trackId; // used to identify track by value (0-15)
|
|
|
|
|
|
|
|
int8 pan; // panning value of sound
|
|
|
|
int32 vol; // volume level (values 0-127 * 1000)
|
|
|
|
int32 volFadeDest; // volume level which fading target (values 0-127 * 1000)
|
|
|
|
int32 volFadeStep; // delta of step while changing volume at each imuse callback
|
|
|
|
int32 volFadeDelay; // time in ms how long fading volume must be
|
|
|
|
bool volFadeUsed; // flag if fading is in progress
|
|
|
|
|
|
|
|
int32 soundId; // sound id used by scumm script
|
|
|
|
char soundName[15]; // sound name but also filename of sound in bundle data
|
2007-06-01 09:02:16 +00:00
|
|
|
bool used; // flag mean that track is used
|
2007-06-01 08:59:21 +00:00
|
|
|
bool toBeRemoved; // flag mean that track need to be free
|
2008-01-05 22:57:36 +00:00
|
|
|
bool mixerStreamRunning; // flag mean sound mixer's stream is running OBSOLETE
|
2007-06-01 11:22:49 +00:00
|
|
|
bool souStreamUsed; // flag mean that track use stream from sou file
|
|
|
|
bool sndDataExtComp;// flag mean that sound data is compressed by scummvm tools
|
|
|
|
int32 soundPriority;// priority level of played sound (0-127)
|
2007-06-01 08:59:21 +00:00
|
|
|
int32 regionOffset; // offset to sound data relative to begining of current region
|
|
|
|
int32 dataOffset; // offset to sound data relative to begining of 'DATA' chunk
|
|
|
|
int32 curRegion; // id of current used region
|
|
|
|
int32 curHookId; // id of current used hook id
|
|
|
|
int32 volGroupId; // id of volume group (IMUSE_VOLGRP_VOICE, IMUSE_VOLGRP_SFX, IMUSE_VOLGRP_MUSIC)
|
|
|
|
int32 soundType; // type of sound data (kSpeechSoundType, kSFXSoundType, kMusicSoundType)
|
2007-06-01 11:22:49 +00:00
|
|
|
int32 feedSize; // size of sound data needed to be filled at each callback iteration
|
|
|
|
int32 dataMod12Bit; // value used between all callback to align 12 bit source of data
|
|
|
|
int32 mixerFlags; // flags for sound mixer's channel (kFlagStereo, kFlag16Bits, kFlagReverseStereo, kFlagUnsigned, kFlagLittleEndian)
|
2007-06-01 08:59:21 +00:00
|
|
|
|
2007-07-22 09:17:23 +00:00
|
|
|
ImuseDigiSndMgr::SoundDesc *soundDesc; // sound handle used by iMuse sound manager
|
2007-06-01 11:22:49 +00:00
|
|
|
Audio::SoundHandle mixChanHandle; // sound mixer's channel handle
|
2007-06-01 08:59:21 +00:00
|
|
|
Audio::AppendableAudioStream *stream; // sound mixer's audio stream handle for *.la1 and *.bun
|
2004-01-06 17:28:29 +00:00
|
|
|
|
|
|
|
Track();
|
2008-01-05 22:44:39 +00:00
|
|
|
|
|
|
|
int getPan() const { return (pan != 64) ? 2 * pan - 127 : 0; }
|
|
|
|
int getVol() const { return vol / 1000; }
|
|
|
|
Audio::Mixer::SoundType getType() const {
|
|
|
|
Audio::Mixer::SoundType type = Audio::Mixer::kPlainSoundType;
|
|
|
|
if (volGroupId == 1)
|
|
|
|
type = Audio::Mixer::kSpeechSoundType;
|
|
|
|
else if (volGroupId == 2)
|
|
|
|
type = Audio::Mixer::kSFXSoundType;
|
|
|
|
else if (volGroupId == 3)
|
|
|
|
type = Audio::Mixer::kMusicSoundType;
|
|
|
|
return type;
|
|
|
|
}
|
2004-01-06 17:28:29 +00:00
|
|
|
};
|
|
|
|
|
2004-04-11 14:48:50 +00:00
|
|
|
Track *_track[MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS];
|
2004-01-06 17:28:29 +00:00
|
|
|
|
2006-02-05 13:48:27 +00:00
|
|
|
Common::Mutex _mutex;
|
2006-10-07 13:57:06 +00:00
|
|
|
ScummEngine_v7 *_vm;
|
2006-10-21 12:44:10 +00:00
|
|
|
Audio::Mixer *_mixer;
|
2004-01-06 17:28:29 +00:00
|
|
|
ImuseDigiSndMgr *_sound;
|
2004-04-05 18:24:36 +00:00
|
|
|
|
2007-06-01 08:59:21 +00:00
|
|
|
char *_audioNames; // filenames of sound SFX used in FT
|
|
|
|
int32 _numAudioNames; // number of above filenames
|
2005-04-20 23:33:35 +00:00
|
|
|
|
2007-06-01 08:59:21 +00:00
|
|
|
bool _pause; // flag mean that iMuse callback should be idle
|
2004-01-14 22:07:24 +00:00
|
|
|
|
2007-12-30 21:59:50 +00:00
|
|
|
int32 _attributes[188]; // internal attributes for each music file to store and check later
|
2007-06-01 08:59:21 +00:00
|
|
|
int32 _nextSeqToPlay; // id of sequence type of music needed played
|
|
|
|
int32 _curMusicState; // current or previous id of music
|
|
|
|
int32 _curMusicSeq; // current or previous id of sequence music
|
|
|
|
int32 _curMusicCue; // current cue for current music. used in FT
|
2008-01-13 00:10:30 +00:00
|
|
|
bool _stopingSequence;
|
2004-01-14 22:07:24 +00:00
|
|
|
|
2007-03-02 17:30:29 +00:00
|
|
|
int32 makeMixerFlags(int32 flags);
|
2006-02-05 13:48:27 +00:00
|
|
|
static void timer_handler(void *refConf);
|
|
|
|
void callback();
|
2004-11-24 09:47:32 +00:00
|
|
|
void switchToNextRegion(Track *track);
|
2004-05-26 17:03:31 +00:00
|
|
|
int allocSlot(int priority);
|
2006-04-29 22:33:31 +00:00
|
|
|
void startSound(int soundId, const char *soundName, int soundType, int volGroupId, Audio::AudioStream *input, int hookId, int volume, int priority);
|
2004-04-11 14:48:50 +00:00
|
|
|
void selectVolumeGroup(int soundId, int volGroupId);
|
2004-01-06 17:28:29 +00:00
|
|
|
|
2004-01-12 19:15:07 +00:00
|
|
|
int32 getPosInMs(int soundId);
|
|
|
|
void getLipSync(int soundId, int syncId, int32 msPos, int32 &width, int32 &height);
|
|
|
|
|
|
|
|
int getSoundIdByName(const char *soundName);
|
2004-01-14 22:07:24 +00:00
|
|
|
void fadeOutMusic(int fadeDelay);
|
2007-12-30 16:32:30 +00:00
|
|
|
Track *cloneToFadeOutTrack(Track *track, int fadeDelay);
|
2004-01-17 08:34:54 +00:00
|
|
|
|
2004-01-12 19:15:07 +00:00
|
|
|
void setFtMusicState(int stateId);
|
|
|
|
void setFtMusicSequence(int seqId);
|
|
|
|
void setFtMusicCuePoint(int cueId);
|
2004-03-02 20:35:48 +00:00
|
|
|
void playFtMusic(const char *songName, int opcode, int volume);
|
2004-01-14 22:07:24 +00:00
|
|
|
|
|
|
|
void setComiMusicState(int stateId);
|
|
|
|
void setComiMusicSequence(int seqId);
|
2007-12-30 22:10:24 +00:00
|
|
|
void playComiMusic(const char *songName, const imuseComiTable *table, int attribPos, bool sequence);
|
2004-01-12 19:15:07 +00:00
|
|
|
|
2004-01-17 08:34:54 +00:00
|
|
|
void setDigMusicState(int stateId);
|
|
|
|
void setDigMusicSequence(int seqId);
|
2007-12-30 21:59:50 +00:00
|
|
|
void playDigMusic(const char *songName, const imuseDigTable *table, int attribPos, bool sequence);
|
2004-01-17 08:34:54 +00:00
|
|
|
|
2008-01-01 11:27:29 +00:00
|
|
|
void flushTrack(Track *track);
|
|
|
|
|
2004-01-06 17:28:29 +00:00
|
|
|
public:
|
2006-10-21 12:44:10 +00:00
|
|
|
IMuseDigital(ScummEngine_v7 *scumm, Audio::Mixer *mixer, int fps);
|
2004-01-14 16:00:24 +00:00
|
|
|
virtual ~IMuseDigital();
|
2004-01-06 17:28:29 +00:00
|
|
|
|
2005-04-20 23:33:35 +00:00
|
|
|
void setAudioNames(int32 num, char *names);
|
|
|
|
|
2006-04-29 22:33:31 +00:00
|
|
|
void startVoice(int soundId, Audio::AudioStream *input);
|
2004-04-06 19:46:43 +00:00
|
|
|
void startVoice(int soundId, const char *soundName);
|
|
|
|
void startMusic(int soundId, int volume);
|
|
|
|
void startMusic(const char *soundName, int soundId, int hookId, int volume);
|
|
|
|
void startSfx(int soundId, int priority);
|
2004-09-25 23:26:46 +00:00
|
|
|
void startSound(int sound)
|
2007-03-20 19:04:51 +00:00
|
|
|
{ error("IMuseDigital::startSound(int) should be never called"); }
|
2004-04-05 18:24:36 +00:00
|
|
|
|
2004-05-02 10:07:59 +00:00
|
|
|
void saveOrLoad(Serializer *ser);
|
2004-04-05 18:24:36 +00:00
|
|
|
void resetState();
|
|
|
|
|
2004-03-27 20:26:25 +00:00
|
|
|
void setPriority(int soundId, int priority);
|
2004-01-18 11:18:46 +00:00
|
|
|
void setVolume(int soundId, int volume);
|
|
|
|
void setPan(int soundId, int pan);
|
|
|
|
void setFade(int soundId, int destVolume, int delay60HzTicks);
|
2005-03-12 18:54:06 +00:00
|
|
|
int getCurMusicSoundId();
|
|
|
|
char *getCurMusicSoundName();
|
|
|
|
void setHookId(int soundId, int hookId);
|
2004-11-28 21:24:02 +00:00
|
|
|
void setMusicVolume(int vol) {}
|
2004-10-07 21:18:54 +00:00
|
|
|
void stopSound(int sound);
|
2004-04-26 07:47:12 +00:00
|
|
|
void stopAllSounds();
|
2004-01-06 17:28:29 +00:00
|
|
|
void pause(bool pause);
|
2004-11-24 09:47:32 +00:00
|
|
|
void parseScriptCmds(int cmd, int soundId, int sub_cmd, int d, int e, int f, int g, int h);
|
2004-04-09 05:43:24 +00:00
|
|
|
void refreshScripts();
|
2004-05-26 17:03:31 +00:00
|
|
|
void flushTracks();
|
2004-01-06 17:28:29 +00:00
|
|
|
int getSoundStatus(int sound) const;
|
|
|
|
int32 getCurMusicPosInMs();
|
|
|
|
int32 getCurVoiceLipSyncWidth();
|
|
|
|
int32 getCurVoiceLipSyncHeight();
|
2004-01-09 22:10:32 +00:00
|
|
|
int32 getCurMusicLipSyncWidth(int syncId);
|
|
|
|
int32 getCurMusicLipSyncHeight(int syncId);
|
2004-01-06 17:28:29 +00:00
|
|
|
};
|
|
|
|
|
2004-01-17 08:34:54 +00:00
|
|
|
struct imuseRoomMap {
|
2004-01-18 19:00:44 +00:00
|
|
|
int8 roomId;
|
2004-05-01 18:36:13 +00:00
|
|
|
byte stateIndex1;
|
|
|
|
byte offset;
|
|
|
|
byte stateIndex2;
|
2007-12-30 21:59:50 +00:00
|
|
|
byte attribPos;
|
2004-05-01 18:36:13 +00:00
|
|
|
byte stateIndex3;
|
2004-01-06 17:28:29 +00:00
|
|
|
};
|
|
|
|
|
2004-01-17 08:34:54 +00:00
|
|
|
struct imuseDigTable {
|
2007-06-02 09:07:29 +00:00
|
|
|
byte transitionType;
|
2004-01-18 16:43:16 +00:00
|
|
|
int16 soundId;
|
2004-01-18 16:32:30 +00:00
|
|
|
char name[20];
|
2007-12-30 21:59:50 +00:00
|
|
|
byte attribPos;
|
2004-03-02 20:35:48 +00:00
|
|
|
byte hookId;
|
2004-01-14 22:07:24 +00:00
|
|
|
char filename[13];
|
2004-01-06 17:28:29 +00:00
|
|
|
};
|
|
|
|
|
2004-01-14 22:07:24 +00:00
|
|
|
struct imuseComiTable {
|
2007-06-02 09:07:29 +00:00
|
|
|
byte transitionType;
|
2004-01-18 16:43:16 +00:00
|
|
|
int16 soundId;
|
2004-01-18 16:32:30 +00:00
|
|
|
char name[20];
|
2007-12-30 21:59:50 +00:00
|
|
|
byte attribPos;
|
2004-01-18 16:43:16 +00:00
|
|
|
byte hookId;
|
2007-03-20 18:45:54 +00:00
|
|
|
int16 fadeOutDelay;
|
2004-01-14 22:07:24 +00:00
|
|
|
char filename[13];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-01-12 19:15:07 +00:00
|
|
|
struct imuseFtNames {
|
|
|
|
char name[20];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct imuseFtStateTable {
|
|
|
|
char audioName[9];
|
2007-06-02 09:07:29 +00:00
|
|
|
byte transitionType;
|
2004-01-18 16:44:58 +00:00
|
|
|
byte volume;
|
2004-01-12 19:15:07 +00:00
|
|
|
char name[21];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct imuseFtSeqTable {
|
|
|
|
char audioName[9];
|
2007-06-02 09:07:29 +00:00
|
|
|
byte transitionType;
|
2004-01-18 16:44:58 +00:00
|
|
|
byte volume;
|
2004-01-06 17:28:29 +00:00
|
|
|
};
|
|
|
|
|
2004-01-17 08:34:54 +00:00
|
|
|
extern const imuseRoomMap _digStateMusicMap[];
|
|
|
|
extern const imuseDigTable _digStateMusicTable[];
|
|
|
|
extern const imuseDigTable _digSeqMusicTable[];
|
2004-01-14 22:07:24 +00:00
|
|
|
extern const imuseComiTable _comiStateMusicTable[];
|
|
|
|
extern const imuseComiTable _comiSeqMusicTable[];
|
2004-01-12 19:15:07 +00:00
|
|
|
extern const imuseFtStateTable _ftStateMusicTable[];
|
|
|
|
extern const imuseFtSeqTable _ftSeqMusicTable[];
|
|
|
|
extern const imuseFtNames _ftSeqNames[];
|
2004-01-06 17:28:29 +00:00
|
|
|
|
|
|
|
} // End of namespace Scumm
|
|
|
|
|
2004-01-20 00:21:24 +00:00
|
|
|
#endif
|