xoreos  0.0.5
wwisesoundbank.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos 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 xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef SOUND_WWISESOUNDBANK_H
26 #define SOUND_WWISESOUNDBANK_H
27 
28 #include <vector>
29 #include <map>
30 
31 #include "src/common/ustring.h"
32 #include "src/common/scopedptr.h"
33 #include "src/common/readstream.h"
34 
35 namespace Sound {
36 
37 class RewindableAudioStream;
38 
47 public:
49  WwiseSoundBank(const Common::UString &name);
50  WwiseSoundBank(uint64 hash);
52 
54  size_t getFileCount() const;
56  size_t getSoundCount() const;
57 
59  uint32 getFileID(size_t index) const;
61  uint32 getSoundID(size_t index) const;
62 
64  uint32 getSoundFileID(size_t index) const;
65 
67  size_t findFileByID(uint32 id) const;
69  size_t findSoundByID(uint32 id) const;
70 
71  RewindableAudioStream *getFile(size_t index) const;
72  RewindableAudioStream *getSound(size_t index) const;
73 
74 private:
76  struct File {
78 
79  size_t offset;
80  size_t size;
81  };
82 
83  enum SoundType {
87  };
88 
89  struct Sound {
91 
93 
94  bool isEmbedded;
96 
99 
100  size_t fileOffset;
101  size_t fileSize;
102  };
103 
105 
107  size_t _dataOffset;
108 
109  std::vector<File> _files;
110  std::vector<Sound> _sounds;
111 
112  std::map<uint32, Common::UString> _banks;
113 
114  std::map<uint32, size_t> _fileIDs;
115  std::map<uint32, size_t> _soundIDs;
116 
117 
118  void load(Common::SeekableReadStream &bnk);
119 
120  const File &getFileStruct(size_t index) const;
121  const Sound &getSoundStruct(size_t index) const;
122 
123  bool isEmptyFile(size_t index) const;
124  bool isEmptySound(size_t index) const;
125 
126  Common::SeekableReadStream *getFileData(size_t index) const;
127  Common::SeekableReadStream *getSoundData(size_t index) const;
128 };
129 
130 } // End of namespace Sound
131 
132 #endif // SOUND_WWISESOUNDBANK_H
A class holding an UTF-8 string.
Definition: ustring.h:48
std::map< uint32, Common::UString > _banks
const File & getFileStruct(size_t index) const
uint64_t uint64
Definition: types.h:206
size_t offset
Offset of the file from the beginning of the data section.
Common::ScopedPtr< Common::SeekableReadStream > _bnk
size_t findFileByID(uint32 id) const
Return the index of a file from its ID, or SIZE_MAX if not found.
Class to hold audio resources and information of a Wwise soundbank file.
Common::SeekableReadStream * getFileData(size_t index) const
RewindableAudioStream * getFile(size_t index) const
A simple scoped smart pointer template.
std::map< uint32, size_t > _fileIDs
std::vector< Sound > _sounds
uint32 getSoundID(size_t index) const
Return the ID of a referenced sound.
Definition: game.h:37
size_t findSoundByID(uint32 id) const
Return the index of a sound from its ID, or SIZE_MAX if not found.
A rewindable audio stream.
Definition: audiostream.h:125
Common::SeekableReadStream * getSoundData(size_t index) const
void load(Common::SeekableReadStream &bnk)
uint32 getSoundFileID(size_t index) const
Return the ID of a file used by a referenced sound.
uint32 getFileID(size_t index) const
Return the ID of an embedded file.
WwiseSoundBank(Common::SeekableReadStream *bnk)
Basic reading stream interfaces.
std::map< uint32, size_t > _soundIDs
Unicode string handling.
size_t size
Size of the file in bytes.
bool isEmptyFile(size_t index) const
bool isEmptySound(size_t index) const
uint32_t uint32
Definition: types.h:204
std::vector< File > _files
const Sound & getSoundStruct(size_t index) const
size_t getFileCount() const
Return the number of embedded files.
size_t getSoundCount() const
Return the number of sounds this bank references.
RewindableAudioStream * getSound(size_t index) const
Interface for a seekable & readable data stream.
Definition: readstream.h:265
An embedded sound file within the SoundBank.