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.
|
2002-08-14 20:43:56 +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.
|
2002-08-14 20:43:56 +00:00
|
|
|
*
|
2006-02-11 09:55:41 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2002-08-14 20:43:56 +00:00
|
|
|
*/
|
|
|
|
|
2006-04-23 18:52:39 +00:00
|
|
|
#ifndef SCUMM_SOUND_H
|
|
|
|
#define SCUMM_SOUND_H
|
2002-08-14 20:43:56 +00:00
|
|
|
|
2003-08-01 12:21:04 +00:00
|
|
|
#include "common/scummsys.h"
|
2005-01-09 03:15:59 +00:00
|
|
|
#include "sound/audiostream.h"
|
2003-07-14 21:37:45 +00:00
|
|
|
#include "sound/mixer.h"
|
2005-10-21 23:04:58 +00:00
|
|
|
#include "scumm/saveload.h"
|
2002-08-14 20:43:56 +00:00
|
|
|
|
2006-10-21 12:44:10 +00:00
|
|
|
namespace Audio {
|
|
|
|
class Mixer;
|
|
|
|
}
|
|
|
|
|
2003-10-03 18:33:57 +00:00
|
|
|
namespace Scumm {
|
|
|
|
|
2003-10-02 22:42:03 +00:00
|
|
|
class ScummEngine;
|
2006-04-23 17:47:40 +00:00
|
|
|
class BaseScummFile;
|
2003-06-15 01:56:47 +00:00
|
|
|
|
2003-09-15 19:48:54 +00:00
|
|
|
struct MP3OffsetTable;
|
2004-08-09 01:07:48 +00:00
|
|
|
struct SaveLoadEntry;
|
2002-08-14 20:43:56 +00:00
|
|
|
|
2003-12-26 13:13:56 +00:00
|
|
|
enum {
|
|
|
|
kTalkSoundID = 10000
|
|
|
|
};
|
|
|
|
|
2006-04-23 18:52:39 +00:00
|
|
|
// TODO: Consider splitting Sound into even more subclasses.
|
|
|
|
// E.g. for v1-v4, v5, v6+, ...
|
2005-10-21 23:04:58 +00:00
|
|
|
class Sound : public Serializable {
|
2004-04-16 12:47:55 +00:00
|
|
|
public:
|
2004-04-10 00:07:58 +00:00
|
|
|
enum SoundMode {
|
|
|
|
kVOCMode,
|
|
|
|
kMP3Mode,
|
|
|
|
kVorbisMode,
|
|
|
|
kFlacMode
|
|
|
|
};
|
|
|
|
|
2004-04-16 12:47:55 +00:00
|
|
|
protected:
|
2004-04-10 00:07:58 +00:00
|
|
|
ScummEngine *_vm;
|
2006-10-21 12:44:10 +00:00
|
|
|
Audio::Mixer *_mixer;
|
2004-04-10 00:07:58 +00:00
|
|
|
|
2002-08-14 20:43:56 +00:00
|
|
|
int16 _soundQuePos, _soundQue[0x100];
|
2004-10-13 07:52:42 +00:00
|
|
|
int16 _soundQue2Pos;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
int16 sound;
|
2005-01-24 10:07:17 +00:00
|
|
|
int32 offset;
|
2004-10-13 07:52:42 +00:00
|
|
|
int16 channel;
|
|
|
|
int16 flags;
|
|
|
|
} _soundQue2[10];
|
2002-08-14 20:43:56 +00:00
|
|
|
|
2006-04-23 17:47:40 +00:00
|
|
|
BaseScummFile *_sfxFile;
|
2005-07-30 21:11:48 +00:00
|
|
|
SoundMode _soundMode;
|
2004-04-10 00:07:58 +00:00
|
|
|
MP3OffsetTable *_offsetTable; // For compressed audio
|
|
|
|
int _numSoundEffects; // For compressed audio
|
|
|
|
|
2002-09-13 11:59:43 +00:00
|
|
|
uint32 _talk_sound_a1, _talk_sound_a2, _talk_sound_b1, _talk_sound_b2;
|
2004-08-09 00:58:21 +00:00
|
|
|
byte _talk_sound_mode, _talk_sound_channel;
|
2002-08-14 20:43:56 +00:00
|
|
|
bool _mouthSyncMode;
|
|
|
|
bool _endOfMouthSync;
|
2002-11-05 13:56:31 +00:00
|
|
|
uint16 _mouthSyncTimes[64];
|
2002-08-14 20:43:56 +00:00
|
|
|
uint _curSoundPos;
|
|
|
|
|
2004-08-09 01:07:48 +00:00
|
|
|
int16 _currentCDSound;
|
|
|
|
int16 _currentMusic;
|
2005-04-25 05:44:12 +00:00
|
|
|
|
2002-08-14 20:43:56 +00:00
|
|
|
public:
|
2005-05-11 00:01:44 +00:00
|
|
|
Audio::SoundHandle _talkChannelHandle; // Handle of mixer channel actor is talking on
|
2004-07-12 09:02:18 +00:00
|
|
|
|
2002-08-14 20:43:56 +00:00
|
|
|
bool _soundsPaused;
|
|
|
|
byte _sfxMode;
|
2003-06-25 23:25:52 +00:00
|
|
|
|
2003-06-15 00:54:14 +00:00
|
|
|
public:
|
2006-10-21 12:44:10 +00:00
|
|
|
Sound(ScummEngine *parent, Audio::Mixer *mixer);
|
2006-04-23 18:52:39 +00:00
|
|
|
virtual ~Sound();
|
|
|
|
virtual void addSoundToQueue(int sound, int heOffset = 0, int heChannel = 0, int heFlags = 0);
|
|
|
|
virtual void addSoundToQueue2(int sound, int heOffset = 0, int heChannel = 0, int heFlags = 0);
|
2005-06-04 06:30:35 +00:00
|
|
|
void processSound();
|
2006-01-05 07:06:47 +00:00
|
|
|
|
|
|
|
void playSound(int soundID);
|
2005-05-11 00:01:44 +00:00
|
|
|
void startTalkSound(uint32 offset, uint32 b, int mode, Audio::SoundHandle *handle = NULL);
|
2002-08-14 20:43:56 +00:00
|
|
|
void stopTalkSound();
|
|
|
|
bool isMouthSyncOff(uint pos);
|
2006-04-23 18:52:39 +00:00
|
|
|
virtual int isSoundRunning(int sound) const;
|
2003-09-07 17:14:56 +00:00
|
|
|
bool isSoundInUse(int sound) const;
|
2006-04-23 18:52:39 +00:00
|
|
|
virtual void stopSound(int sound);
|
2006-04-23 23:00:32 +00:00
|
|
|
virtual void stopAllSounds();
|
2002-12-25 14:46:39 +00:00
|
|
|
void soundKludge(int *list, int num);
|
2004-08-09 00:58:21 +00:00
|
|
|
void talkSound(uint32 a, uint32 b, int mode, int channel = 0);
|
2006-04-23 18:52:39 +00:00
|
|
|
virtual void setupSound();
|
2002-08-14 20:43:56 +00:00
|
|
|
void pauseSounds(bool pause);
|
2003-06-15 00:54:14 +00:00
|
|
|
|
2002-09-21 13:48:03 +00:00
|
|
|
void startCDTimer();
|
|
|
|
void stopCDTimer();
|
|
|
|
|
2003-07-22 20:27:54 +00:00
|
|
|
void playCDTrack(int track, int numLoops, int startFrame, int duration);
|
2002-08-29 23:45:15 +00:00
|
|
|
void stopCD();
|
2003-06-25 23:49:54 +00:00
|
|
|
int pollCD() const;
|
2002-08-29 23:45:15 +00:00
|
|
|
void updateCD();
|
2003-06-30 23:18:20 +00:00
|
|
|
int getCurrentCDSound() const { return _currentCDSound; }
|
2002-08-29 23:45:15 +00:00
|
|
|
|
2004-08-09 01:07:48 +00:00
|
|
|
// Used by the save/load system:
|
2005-10-21 23:04:58 +00:00
|
|
|
void saveLoadWithSerializer(Serializer *ser);
|
2004-08-09 01:07:48 +00:00
|
|
|
|
2002-08-29 23:45:15 +00:00
|
|
|
protected:
|
2006-04-23 17:47:40 +00:00
|
|
|
BaseScummFile *openSfxFile();
|
2003-06-25 23:49:54 +00:00
|
|
|
bool isSfxFinished() const;
|
2003-12-25 15:09:23 +00:00
|
|
|
void processSfxQueues();
|
|
|
|
|
|
|
|
bool isSoundInQueue(int sound) const;
|
2006-04-23 18:52:39 +00:00
|
|
|
|
|
|
|
virtual void processSoundQueues();
|
2002-08-14 20:43:56 +00:00
|
|
|
};
|
|
|
|
|
2005-01-09 03:15:59 +00:00
|
|
|
|
2003-10-03 18:33:57 +00:00
|
|
|
} // End of namespace Scumm
|
|
|
|
|
2002-08-14 20:43:56 +00:00
|
|
|
#endif
|