2009-12-29 23:18:24 +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 MOHAWK_SOUND_H
|
|
|
|
#define MOHAWK_SOUND_H
|
|
|
|
|
|
|
|
#include "common/scummsys.h"
|
|
|
|
#include "common/str.h"
|
|
|
|
|
2011-02-09 01:09:01 +00:00
|
|
|
#include "audio/audiostream.h"
|
|
|
|
#include "audio/mixer.h"
|
2011-08-05 12:33:42 +00:00
|
|
|
#include "audio/decoders/adpcm.h"
|
2009-12-29 23:18:24 +00:00
|
|
|
|
|
|
|
#include "mohawk/mohawk.h"
|
2010-01-22 03:43:57 +00:00
|
|
|
#include "mohawk/resource.h"
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2011-08-05 12:33:42 +00:00
|
|
|
class MidiDriver;
|
|
|
|
class MidiParser;
|
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
namespace Mohawk {
|
|
|
|
|
|
|
|
#define MAX_CHANNELS 2 // Can there be more than 2?
|
|
|
|
|
|
|
|
struct SLSTRecord {
|
|
|
|
uint16 index;
|
|
|
|
uint16 sound_count;
|
2010-02-26 08:11:45 +00:00
|
|
|
uint16 *sound_ids;
|
2009-12-29 23:18:24 +00:00
|
|
|
uint16 fade_flags;
|
|
|
|
uint16 loop;
|
|
|
|
uint16 global_volume;
|
|
|
|
uint16 u0;
|
|
|
|
uint16 u1;
|
2010-02-26 08:11:45 +00:00
|
|
|
uint16 *volumes;
|
|
|
|
int16 *balances;
|
|
|
|
uint16 *u2;
|
2009-12-29 23:18:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum SndHandleType {
|
|
|
|
kFreeHandle,
|
2011-01-19 16:52:47 +00:00
|
|
|
kUsedHandle
|
2009-12-29 23:18:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SndHandle {
|
|
|
|
Audio::SoundHandle handle;
|
|
|
|
SndHandleType type;
|
2011-01-19 16:36:34 +00:00
|
|
|
uint samplesPerSecond;
|
2010-11-27 21:36:04 +00:00
|
|
|
uint16 id;
|
2009-12-29 23:18:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SLSTSndHandle {
|
|
|
|
Audio::SoundHandle *handle;
|
|
|
|
uint16 id;
|
|
|
|
};
|
|
|
|
|
2011-01-11 21:48:49 +00:00
|
|
|
struct ADPCMStatus { // Holds ADPCM status data, but is irrelevant for us.
|
2009-12-29 23:18:24 +00:00
|
|
|
uint32 size;
|
2010-01-24 23:39:27 +00:00
|
|
|
uint16 itemCount;
|
2009-12-29 23:18:24 +00:00
|
|
|
uint16 channels;
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2010-01-24 23:39:27 +00:00
|
|
|
struct StatusItem {
|
|
|
|
uint32 sampleFrame;
|
2011-01-22 16:16:30 +00:00
|
|
|
struct {
|
|
|
|
int16 last;
|
|
|
|
uint16 stepIndex;
|
|
|
|
} channelStatus[MAX_CHANNELS];
|
2010-01-24 23:39:27 +00:00
|
|
|
} *statusItems;
|
2009-12-29 23:18:24 +00:00
|
|
|
};
|
|
|
|
|
2011-01-19 22:41:12 +00:00
|
|
|
struct CueListPoint {
|
|
|
|
uint32 sampleFrame;
|
|
|
|
Common::String name;
|
|
|
|
};
|
|
|
|
|
2011-01-11 21:48:49 +00:00
|
|
|
struct CueList {
|
2009-12-29 23:18:24 +00:00
|
|
|
uint32 size;
|
2011-01-11 21:48:49 +00:00
|
|
|
uint16 pointCount;
|
2011-01-19 22:41:12 +00:00
|
|
|
Common::Array<CueListPoint> points;
|
2009-12-29 23:18:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
kCodecRaw = 0,
|
|
|
|
kCodecADPCM = 1,
|
|
|
|
kCodecMPEG2 = 2
|
|
|
|
};
|
|
|
|
|
2011-01-11 21:48:49 +00:00
|
|
|
struct DataChunk {
|
|
|
|
uint16 sampleRate;
|
|
|
|
uint32 sampleCount;
|
2009-12-29 23:18:24 +00:00
|
|
|
byte bitsPerSample;
|
|
|
|
byte channels;
|
|
|
|
uint16 encoding;
|
2011-01-22 16:35:25 +00:00
|
|
|
uint16 loopCount; // 0 == no looping, 0xFFFF == infinite loop
|
2009-12-29 23:18:24 +00:00
|
|
|
uint32 loopStart;
|
|
|
|
uint32 loopEnd;
|
2011-01-11 21:48:49 +00:00
|
|
|
Common::SeekableReadStream *audioData;
|
2009-12-29 23:18:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class MohawkEngine;
|
|
|
|
|
|
|
|
class Sound {
|
|
|
|
public:
|
2010-09-08 20:50:56 +00:00
|
|
|
Sound(MohawkEngine *vm);
|
2009-12-29 23:18:24 +00:00
|
|
|
~Sound();
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2011-01-18 21:10:58 +00:00
|
|
|
// Generic sound functions
|
2011-01-19 16:36:34 +00:00
|
|
|
Audio::SoundHandle *playSound(uint16 id, byte volume = Audio::Mixer::kMaxChannelVolume, bool loop = false, CueList *cueList = NULL);
|
2010-09-08 20:50:56 +00:00
|
|
|
void playSoundBlocking(uint16 id, byte volume = Audio::Mixer::kMaxChannelVolume);
|
2009-12-29 23:18:24 +00:00
|
|
|
void playMidi(uint16 id);
|
2011-01-03 22:53:34 +00:00
|
|
|
void stopMidi();
|
2009-12-29 23:18:24 +00:00
|
|
|
void stopSound();
|
2010-11-27 21:36:04 +00:00
|
|
|
void stopSound(uint16 id);
|
2009-12-29 23:18:24 +00:00
|
|
|
void pauseSound();
|
|
|
|
void resumeSound();
|
2010-11-27 21:36:04 +00:00
|
|
|
bool isPlaying(uint16 id);
|
2011-03-29 19:18:55 +00:00
|
|
|
bool isPlaying();
|
2011-01-19 16:36:34 +00:00
|
|
|
uint getNumSamplesPlayed(uint16 id);
|
2010-09-08 20:50:56 +00:00
|
|
|
|
2011-01-18 21:10:58 +00:00
|
|
|
// Myst-specific sound functions
|
|
|
|
Audio::SoundHandle *replaceSoundMyst(uint16 id, byte volume = Audio::Mixer::kMaxChannelVolume, bool loop = false);
|
|
|
|
Audio::SoundHandle *replaceBackgroundMyst(uint16 id, uint16 volume = 0xFFFF);
|
|
|
|
void pauseBackgroundMyst();
|
|
|
|
void resumeBackgroundMyst();
|
|
|
|
void stopBackgroundMyst();
|
|
|
|
void changeBackgroundVolumeMyst(uint16 vol);
|
2010-11-29 20:53:56 +00:00
|
|
|
|
2011-01-18 21:10:58 +00:00
|
|
|
// Riven-specific sound functions
|
2009-12-29 23:18:24 +00:00
|
|
|
void playSLST(uint16 index, uint16 card);
|
|
|
|
void playSLST(SLSTRecord slstRecord);
|
|
|
|
void pauseSLST();
|
|
|
|
void resumeSLST();
|
2011-01-23 07:02:49 +00:00
|
|
|
void stopAllSLST(bool fade = false);
|
2010-09-08 20:50:56 +00:00
|
|
|
static byte convertRivenVolume(uint16 volume);
|
2009-12-30 07:30:04 +00:00
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
private:
|
|
|
|
MohawkEngine *_vm;
|
|
|
|
MidiDriver *_midiDriver;
|
|
|
|
MidiParser *_midiParser;
|
2011-01-02 14:57:20 +00:00
|
|
|
byte *_midiData;
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2011-01-19 16:36:34 +00:00
|
|
|
static Audio::AudioStream *makeMohawkWaveStream(Common::SeekableReadStream *stream, CueList *cueList = NULL);
|
2011-03-23 01:16:27 +00:00
|
|
|
static Audio::AudioStream *makeLivingBooksWaveStream_v1(Common::SeekableReadStream *stream);
|
2009-12-29 23:18:24 +00:00
|
|
|
void initMidi();
|
|
|
|
|
|
|
|
Common::Array<SndHandle> _handles;
|
|
|
|
SndHandle *getHandle();
|
2011-01-19 16:36:34 +00:00
|
|
|
Audio::AudioStream *makeAudioStream(uint16 id, CueList *cueList = NULL);
|
2011-01-18 21:10:58 +00:00
|
|
|
uint16 convertMystID(uint16 id);
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2011-01-19 16:52:47 +00:00
|
|
|
// Myst-specific
|
|
|
|
SndHandle _mystBackgroundSound;
|
|
|
|
|
2010-09-08 20:50:56 +00:00
|
|
|
// Riven-specific
|
2009-12-29 23:18:24 +00:00
|
|
|
void playSLSTSound(uint16 index, bool fade, bool loop, uint16 volume, int16 balance);
|
|
|
|
void stopSLSTSound(uint16 id, bool fade);
|
|
|
|
Common::Array<SLSTSndHandle> _currentSLSTSounds;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace Mohawk
|
|
|
|
|
|
|
|
#endif
|