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.
|
|
|
|
*
|
2021-12-26 18:47:58 +01: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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2014-02-18 02:34:22 +01:00
|
|
|
*
|
2009-12-29 23:18:24 +00:00
|
|
|
* 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.
|
2014-02-18 02:34:22 +01:00
|
|
|
*
|
2009-12-29 23:18:24 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
2021-12-26 18:47:58 +01:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-12-29 23:18:24 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MOHAWK_SOUND_H
|
|
|
|
#define MOHAWK_SOUND_H
|
|
|
|
|
2017-07-21 12:25:09 +02:00
|
|
|
#include "common/array.h"
|
2009-12-29 23:18:24 +00:00
|
|
|
#include "common/scummsys.h"
|
|
|
|
#include "common/str.h"
|
2017-07-21 12:25:09 +02:00
|
|
|
#include "common/stream.h"
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2011-02-09 01:09:01 +00:00
|
|
|
#include "audio/mixer.h"
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2011-08-05 13:33:42 +01:00
|
|
|
class MidiDriver;
|
|
|
|
class MidiParser;
|
|
|
|
|
2016-04-14 16:10:21 +03:00
|
|
|
namespace Audio {
|
|
|
|
class RewindableAudioStream;
|
|
|
|
}
|
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
namespace Mohawk {
|
|
|
|
|
|
|
|
#define MAX_CHANNELS 2 // Can there be more than 2?
|
|
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2016-08-08 06:59:24 +02:00
|
|
|
Audio::RewindableAudioStream *makeMohawkWaveStream(Common::SeekableReadStream *stream, CueList *cueList = nullptr);
|
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
class MohawkEngine;
|
|
|
|
|
|
|
|
class Sound {
|
|
|
|
public:
|
2018-03-31 12:52:08 +02:00
|
|
|
explicit 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);
|
2009-12-29 23:18:24 +00:00
|
|
|
void stopSound();
|
2010-11-27 21:36:04 +00:00
|
|
|
void stopSound(uint16 id);
|
|
|
|
bool isPlaying(uint16 id);
|
2011-03-29 21:18:55 +02:00
|
|
|
bool isPlaying();
|
2011-01-19 16:36:34 +00:00
|
|
|
uint getNumSamplesPlayed(uint16 id);
|
2010-09-08 20:50:56 +00:00
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
private:
|
|
|
|
MohawkEngine *_vm;
|
|
|
|
|
2014-06-09 20:35:40 -04:00
|
|
|
static Audio::RewindableAudioStream *makeLivingBooksWaveStream_v1(Common::SeekableReadStream *stream);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
|
|
|
Common::Array<SndHandle> _handles;
|
|
|
|
SndHandle *getHandle();
|
2018-03-31 12:52:08 +02:00
|
|
|
Audio::RewindableAudioStream *makeAudioStream(uint16 id, CueList *cueList = nullptr);
|
2009-12-29 23:18:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace Mohawk
|
|
|
|
|
|
|
|
#endif
|