ScummVM API documentation
soundse.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 SCUMM_SOUNDSE_H
23 #define SCUMM_SOUNDSE_H
24 
25 #include "common/scummsys.h"
26 #include "audio/mixer.h"
27 #include "scumm/file.h"
28 
29 namespace Common {
30 class SeekableSubReadStream;
31 }
32 
33 namespace Audio {
34 class SeekableAudioStream;
35 }
36 
37 namespace Scumm {
38 
39 class ScummEngine;
40 
41 enum SoundSEType {
42  kSoundSETypeMusic,
43  kSoundSETypeSpeech,
44  kSoundSETypeSFX
45 };
46 
47 class SoundSE {
48 
49 protected:
50  ScummEngine *_vm;
51  Audio::Mixer *_mixer;
52 
53 public:
54  SoundSE(ScummEngine *parent, Audio::Mixer *mixer);
55  ~SoundSE() = default;
56 
57  Audio::SeekableAudioStream *getXWBTrack(int track);
58  Audio::AudioStream *getAudioStream(uint32 offset, SoundSEType type);
59 
60 private:
61  enum AudioCodec {
62  kXWBCodecPCM = 0,
63  kXWBCodecXMA = 1,
64  kXWBCodecADPCM = 2,
65  kXWBCodecWMA = 3,
66  kFSBCodecMP3 = 4
67  };
68 
69  enum XWBSegmentType {
70  kXWBSegmentBankData = 0,
71  kXWBSegmentEntryMetaData = 1,
72  kXWBSegmentSeekTables = 2,
73  kXWBSegmentEntryNames = 3,
74  kXWBSegmentEntryWaveData = 4
75  };
76 
77  struct AudioEntry {
78  uint64 offset;
79  uint32 length;
80  AudioCodec codec;
81  byte channels;
82  uint16 rate;
83  uint16 align;
84  byte bits;
85  Common::String name;
86  };
87 
88  Common::HashMap<Common::String, uint32> _audioNameToOriginalOffsetMap;
89 
92 
93  OffsetToIndexMap _offsetToIndex;
94 
95  AudioIndex _musicEntries;
96  Common::String _musicFilename;
97  AudioIndex _speechEntries;
98  Common::String _speechFilename;
99  AudioIndex _sfxEntries;
100  Common::String _sfxFilename;
101 
102  int32 getSoundIndexFromOffset(uint32 offset);
103 
104  void initAudioMapping();
105  void initSoundFiles();
106  void indexXWBFile(const Common::String &filename, AudioIndex *audioIndex);
107  Audio::SeekableAudioStream *createSoundStream(Common::SeekableSubReadStream *stream, AudioEntry entry);
108  void indexFSBFile(const Common::String &filename, AudioIndex *audioIndex);
109 };
110 
111 
112 } // End of namespace Scumm
113 
114 #endif
Definition: str.h:59
Definition: soundse.h:47
Definition: audiostream.h:212
Definition: scumm.h:519
Definition: mixer.h:59
Definition: substream.h:78
Definition: algorithm.h:29
Definition: audiostream.h:50
Definition: actor.h:30
Definition: system.h:38