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-24 15:31:37 +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-24 15:31:37 +00:00
|
|
|
*
|
2006-02-11 09:55:41 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2002-08-24 15:31:37 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-02-19 17:48:19 +00:00
|
|
|
#ifndef SCUMM_SMUSH_CHANNEL_H
|
|
|
|
#define SCUMM_SMUSH_CHANNEL_H
|
2002-08-24 15:31:37 +00:00
|
|
|
|
2003-09-10 12:31:20 +00:00
|
|
|
#include "common/util.h"
|
2002-08-24 15:31:37 +00:00
|
|
|
|
2003-10-03 18:33:57 +00:00
|
|
|
namespace Scumm {
|
|
|
|
|
2002-08-24 17:18:55 +00:00
|
|
|
class Chunk;
|
|
|
|
class ContChunk;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-03-17 12:28:50 +00:00
|
|
|
class SmushChannel {
|
2006-10-27 22:26:33 +00:00
|
|
|
protected:
|
|
|
|
int32 _track; //!< the track number
|
|
|
|
byte *_tbuffer; //!< data temporary buffer
|
|
|
|
int32 _tbufferSize; //!< temporary buffer size
|
|
|
|
byte *_sbuffer; //!< sound buffer
|
|
|
|
int32 _sbufferSize; //!< sound buffer size
|
|
|
|
|
|
|
|
int32 _dataSize; //!< remaining size of sound data in the iMUS buffer
|
|
|
|
|
|
|
|
bool _inData;
|
|
|
|
|
|
|
|
int32 _volume;
|
|
|
|
int32 _pan;
|
2003-03-17 12:28:50 +00:00
|
|
|
|
2006-10-27 22:49:31 +00:00
|
|
|
void processBuffer();
|
|
|
|
|
|
|
|
virtual bool handleSubTags(int32 &offset) = 0;
|
|
|
|
|
2006-10-27 22:26:33 +00:00
|
|
|
public:
|
2006-10-27 22:49:31 +00:00
|
|
|
SmushChannel(int32 track);
|
|
|
|
virtual ~SmushChannel();
|
2003-03-06 08:36:56 +00:00
|
|
|
virtual bool appendData(Chunk &b, int32 size) = 0;
|
2003-12-25 08:25:04 +00:00
|
|
|
virtual bool setParameters(int32, int32, int32, int32, int32) = 0;
|
2002-08-30 07:24:45 +00:00
|
|
|
virtual bool checkParameters(int32, int32, int32, int32, int32) = 0;
|
2002-08-24 15:31:37 +00:00
|
|
|
virtual bool isTerminated() const = 0;
|
2006-10-28 00:18:13 +00:00
|
|
|
virtual byte *getSoundData() = 0;
|
2002-09-18 08:06:15 +00:00
|
|
|
virtual int32 getRate() = 0;
|
2006-10-27 22:26:33 +00:00
|
|
|
virtual bool getParameters(bool &stereo, bool &is_16bit, int32 &vol, int32 &pan) = 0;
|
2006-10-27 22:49:31 +00:00
|
|
|
|
2006-10-28 00:18:13 +00:00
|
|
|
int32 getAvailableSoundDataSize() const { return _sbufferSize; }
|
|
|
|
int32 getTrackIdentifier() const { return _track; }
|
2002-08-24 15:31:37 +00:00
|
|
|
};
|
|
|
|
|
2003-03-17 12:28:50 +00:00
|
|
|
class SaudChannel : public SmushChannel {
|
2002-08-24 15:31:37 +00:00
|
|
|
private:
|
2003-03-17 12:28:50 +00:00
|
|
|
int32 _nbframes;
|
|
|
|
bool _markReached;
|
|
|
|
int32 _flags;
|
|
|
|
int32 _index;
|
2003-12-25 08:25:04 +00:00
|
|
|
bool _keepSize;
|
2002-08-24 15:31:37 +00:00
|
|
|
|
|
|
|
protected:
|
2003-03-06 08:36:56 +00:00
|
|
|
bool handleSubTags(int32 &offset);
|
2002-08-24 15:31:37 +00:00
|
|
|
|
|
|
|
public:
|
2006-10-27 22:26:33 +00:00
|
|
|
SaudChannel(int32 track);
|
2002-08-24 15:31:37 +00:00
|
|
|
bool isTerminated() const;
|
2003-12-25 08:25:04 +00:00
|
|
|
bool setParameters(int32 duration, int32 flags, int32 vol1, int32 vol2, int32 index);
|
2002-08-30 07:24:45 +00:00
|
|
|
bool checkParameters(int32 index, int32 duration, int32 flags, int32 vol1, int32 vol2);
|
2003-03-06 08:36:56 +00:00
|
|
|
bool appendData(Chunk &b, int32 size);
|
2006-10-28 00:18:13 +00:00
|
|
|
byte *getSoundData();
|
2006-10-27 22:26:33 +00:00
|
|
|
int32 getRate() { return 22050; }
|
|
|
|
bool getParameters(bool &stereo, bool &is_16bit, int32 &vol, int32 &pan) {
|
2006-10-28 00:04:50 +00:00
|
|
|
stereo = false;
|
|
|
|
is_16bit = false;
|
2004-01-09 23:33:46 +00:00
|
|
|
vol = _volume;
|
|
|
|
pan = _pan;
|
2002-08-24 15:31:37 +00:00
|
|
|
return true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2003-03-17 12:28:50 +00:00
|
|
|
class ImuseChannel : public SmushChannel {
|
2002-08-24 15:31:37 +00:00
|
|
|
private:
|
2002-08-30 07:24:45 +00:00
|
|
|
int32 _srbufferSize;
|
2002-08-24 15:31:37 +00:00
|
|
|
|
2002-08-30 07:24:45 +00:00
|
|
|
int32 _bitsize; //!< the bitsize of the original data
|
|
|
|
int32 _rate; //!< the sampling rate of the original data
|
|
|
|
int32 _channels; //!< the number of channels of the original data
|
2002-08-24 15:31:37 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void decode();
|
2006-10-27 22:49:31 +00:00
|
|
|
bool handleMap(Chunk &c);
|
|
|
|
bool handleSubTags(int32 &offset);
|
2002-08-24 15:31:37 +00:00
|
|
|
|
|
|
|
public:
|
2006-10-27 22:26:33 +00:00
|
|
|
ImuseChannel(int32 track);
|
2002-08-24 15:31:37 +00:00
|
|
|
bool isTerminated() const;
|
2003-12-25 08:25:04 +00:00
|
|
|
bool setParameters(int32 nbframes, int32 size, int32 track_flags, int32 unk1, int32);
|
2002-09-21 09:21:50 +00:00
|
|
|
bool checkParameters(int32 index, int32 nbframes, int32 size, int32 track_flags, int32 unk1);
|
2003-03-06 08:36:56 +00:00
|
|
|
bool appendData(Chunk &b, int32 size);
|
2006-10-28 00:18:13 +00:00
|
|
|
byte *getSoundData();
|
2002-09-18 08:06:15 +00:00
|
|
|
int32 getRate() { return _rate; }
|
2006-10-27 22:26:33 +00:00
|
|
|
bool getParameters(bool &stereo, bool &is_16bit, int32 &vol, int32 &pan) {
|
2002-08-24 15:31:37 +00:00
|
|
|
stereo = (_channels == 2);
|
|
|
|
is_16bit = (_bitsize > 8);
|
2004-01-09 23:33:46 +00:00
|
|
|
vol = _volume;
|
|
|
|
pan = _pan;
|
2002-08-24 15:31:37 +00:00
|
|
|
return true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2003-10-03 18:33:57 +00:00
|
|
|
} // End of namespace Scumm
|
|
|
|
|
2002-08-24 15:31:37 +00:00
|
|
|
#endif
|