ScummVM API documentation
sound.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef MOHAWK_SOUND_H
23#define MOHAWK_SOUND_H
24
25#include "common/array.h"
26#include "common/scummsys.h"
27#include "common/str.h"
28#include "common/stream.h"
29
30#include "audio/mixer.h"
31
32class MidiDriver;
33class MidiParser;
34
35namespace Audio {
36class SeekableAudioStream;
37}
38
39namespace Mohawk {
40
41#define MAX_CHANNELS 2 // Can there be more than 2?
42
43enum SndHandleType {
44 kFreeHandle,
45 kUsedHandle
46};
47
55struct SndHandle {
59 SndHandleType type;
63 uint16 id;
64};
65
75 uint32 size;
77 uint16 itemCount;
79 uint16 channels;
80
82 struct StatusItem {
86 struct {
88 int16 last;
90 uint16 stepIndex;
96 } channelStatus[MAX_CHANNELS];
97 } *statusItems;
103};
104
111};
112
119struct CueList {
121 uint32 size;
126};
127
128enum {
129 kCodecRaw = 0,
130 kCodecADPCM = 1,
131 kCodecMPEG2 = 2
132};
133
150struct DataChunk {
163 uint16 encoding;
169 uint16 loopCount;
171 uint32 loopStart;
173 uint32 loopEnd;
180};
181
191 uint32 start = 0;
192 uint32 end = 0;
193
194 bool isValid() const { return start < end; }
195};
196
211
212class MohawkEngine;
213
214class Sound {
215public:
219 explicit Sound(MohawkEngine *vm);
220 ~Sound();
221
222 // Generic sound functions
223 Audio::SoundHandle *playSound(uint16 id, byte volume = Audio::Mixer::kMaxChannelVolume, bool loop = false, CueList *cueList = NULL);
224 void stopSound();
225 void stopSound(uint16 id);
226 bool isPlaying(uint16 id);
227 bool isPlaying();
228 uint getNumSamplesPlayed(uint16 id);
229
230private:
231 MohawkEngine *_vm;
232
233 static Audio::SeekableAudioStream *makeLivingBooksWaveStream_v1(Common::SeekableReadStream *stream);
234
236 SndHandle *getHandle();
237 Audio::SeekableAudioStream *makeAudioStream(uint16 id, CueList *cueList = nullptr,
238 MohawkWaveLoopInfo *loopInfo = nullptr);
239};
240
241} // End of namespace Mohawk
242
243#endif
@ kMaxChannelVolume
Definition: mixer.h:82
Definition: audiostream.h:212
Definition: mixer.h:49
Definition: array.h:52
Definition: stream.h:745
Definition: str.h:59
Definition: mididrv.h:313
Definition: midiparser.h:354
Definition: mohawk.h:54
Definition: sound.h:214
Sound(MohawkEngine *vm)
Definition: system.h:39
Definition: bitmap.h:32
Audio::SeekableAudioStream * makeMohawkWaveStream(Common::SeekableReadStream *stream, CueList *cueList=nullptr, MohawkWaveLoopInfo *loopInfo=nullptr)
Definition: sound.h:82
int16 last
Definition: sound.h:88
uint16 stepIndex
Definition: sound.h:90
uint32 sampleFrame
Definition: sound.h:84
struct Mohawk::ADPCMStatus::StatusItem::@744 channelStatus[2]
Definition: sound.h:73
uint32 size
Definition: sound.h:75
uint16 itemCount
Definition: sound.h:77
uint16 channels
Definition: sound.h:79
struct Mohawk::ADPCMStatus::StatusItem * statusItems
Definition: sound.h:119
uint32 size
Definition: sound.h:121
Common::Array< CueListPoint > points
Definition: sound.h:125
uint16 pointCount
Definition: sound.h:123
Definition: sound.h:106
Common::String name
Definition: sound.h:110
uint32 sampleFrame
Definition: sound.h:108
Definition: sound.h:150
uint32 sampleCount
Definition: sound.h:154
uint32 loopStart
Definition: sound.h:171
uint16 loopCount
Definition: sound.h:169
uint32 loopEnd
Definition: sound.h:173
byte channels
Definition: sound.h:158
uint16 sampleRate
Definition: sound.h:152
byte bitsPerSample
Definition: sound.h:156
uint16 encoding
Definition: sound.h:163
Common::SeekableReadStream * audioData
Definition: sound.h:179
Definition: sound.h:190
Definition: sound.h:55
SndHandleType type
Definition: sound.h:59
uint16 id
Definition: sound.h:63
uint samplesPerSecond
Definition: sound.h:61
Audio::SoundHandle handle
Definition: sound.h:57