Fetching contributors…
Cannot retrieve contributors at this time
133 lines (100 sloc) 3.48 KB
/* xoreos - A reimplementation of BioWare's Aurora engine
* xoreos is the legal property of its developers, whose names
* can be found in the AUTHORS file distributed with this source
* distribution.
* xoreos 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.
* xoreos is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with xoreos. If not, see <>.
/** @file
* A Wwise SoundBank, found in Dragon Age II as BNK files.
#include <vector>
#include <map>
#include "src/common/ustring.h"
#include "src/common/scopedptr.h"
#include "src/common/readstream.h"
namespace Sound {
class RewindableAudioStream;
/** Class to hold audio resources and information of a Wwise soundbank file.
* An BNK file is a Wwise soundbank, i.e. an archive containing one or more
* audio files, together with event, effect, track and similar information.
* It is part of the Wwise middleware.
class WwiseSoundBank {
WwiseSoundBank(Common::SeekableReadStream *bnk);
WwiseSoundBank(const Common::UString &name);
WwiseSoundBank(uint64 hash);
~WwiseSoundBank() { }
/** Return the number of embedded files. */
size_t getFileCount() const;
/** Return the number of sounds this bank references. */
size_t getSoundCount() const;
/** Return the ID of an embedded file. */
uint32 getFileID(size_t index) const;
/** Return the ID of a referenced sound. */
uint32 getSoundID(size_t index) const;
/** Return the ID of a file used by a referenced sound. */
uint32 getSoundFileID(size_t index) const;
/** Return the index of a file from its ID, or SIZE_MAX if not found. */
size_t findFileByID(uint32 id) const;
/** Return the index of a sound from its ID, or SIZE_MAX if not found. */
size_t findSoundByID(uint32 id) const;
RewindableAudioStream *getFile(size_t index) const;
RewindableAudioStream *getSound(size_t index) const;
/** An embedded sound file within the SoundBank. */
struct File {
uint32 id;
size_t offset; ///< Offset of the file from the beginning of the data section.
size_t size; ///< Size of the file in bytes.
enum SoundType {
struct Sound {
uint32 id;
SoundType type;
bool isEmbedded;
bool zeroLatency;
uint32 fileID;
uint32 fileSource;
size_t fileOffset;
size_t fileSize;
Common::ScopedPtr<Common::SeekableReadStream> _bnk;
uint32 _bankID;
size_t _dataOffset;
std::vector<File> _files;
std::vector<Sound> _sounds;
std::map<uint32, Common::UString> _banks;
std::map<uint32, size_t> _fileIDs;
std::map<uint32, size_t> _soundIDs;
void load(Common::SeekableReadStream &bnk);
const File &getFileStruct(size_t index) const;
const Sound &getSoundStruct(size_t index) const;
bool isEmptyFile(size_t index) const;
bool isEmptySound(size_t index) const;
Common::SeekableReadStream *getFileData(size_t index) const;
Common::SeekableReadStream *getSoundData(size_t index) const;
} // End of namespace Sound