Wwise SoundBank (*.bnk)

From XentaxWiki
Revision as of 00:22, 29 November 2012 by SWTOR fan (talk | contribs) (.bnk SoundBank specification added (still under construction))

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

On this page you can find a file format specification of the .bnk SoundBank files used by Wwise.

SoundBanks by Wwise can be used to have a great deal of control over the soundtrack of a game, including the sound effects and the score. SoundBanks contain the individual audio files as well as containers to group the files, e.g. a gun shot container that plays a random gun shot sound. Also, SoundBanks contain events which can play or pause containers or audio files. Events are the only type of object that is visible outside the SoundBanks, and developers can access these events from the game code. For example, during a very emotional scene they could call a Play_EmotionalTheme event, which will play an emotional piece, as defined by the sound designer.

Each Wwise project contains an initialization SoundBank, Init.bnk. This SoundBank contains the project settings and is loaded first. The other SoundBanks contain sounds for different parts of the game (e.g. one SoundBank for each area or level). They are loaded into memory whenever the player has reached that part of the game.

The sound files are stored via a custom Wwise encoding and have the file extension .wem (before 2011, the Wwise extension was called .wav). For converting these files to .ogg files, I recommend the command-line utility ww2ogg by Halley's Comet Software (hcs) -- see hcs64.com/vgm_ripping.html. Depending on the game, some files are not embedded in the SoundBanks but are streamed. In this case, look in the game archive for .wem files.

General format

  • FOR EACH (section) {
    • byte[4]: four-letter identifier of the section, e.g. BKHD or DIDX
    • uint32: length of this section in bytes
    • byte[]: section data (see below)
  • } END FOR

-- END OF FILE --

To avoid errors when reading a .bnk file, it is recommended to always seek to the end of a section by using the byte length field. That way, even the program has reached the end of the section, it will automatically skip to the end in case it has left out something.

BKHD section

The BKHD section (Bank Header) contains the version number and the SoundBank id.

  • 42 4B 48 44 -- BKHD
  • uint32: length of section
  • uint32: version number of this SoundBank
  • uint32: id of this SoundBank
  • uint32: always zero
  • uint32: always zero

DIDX section

The DIDX (Data Index) section contains the references to the .wem files embedded in the SoundBank. Each sound file is described with 12 bytes, so you can get the number of embedded files by dividing the section length by 12.

  • 44 49 44 58 -- DIDX
  • uint32: length of section
  • FOR EACH (embedded .wem file) {
    • uint32: .wem file id
    • uint32: offset from start of DATA section
    • uint32: length in bytes of .wem file
  • } END FOR

DATA section

The DATA section contains the .wem files, not encoded, and immediately following each other. It is not recommended to read this section by itself but instead to immediately jump to the correct position based on the offset given in the DIDX or HIRC section.

  • 44 41 54 41 -- DATA
  • uint32: length of section
  • FOR EACH (embedded .wem file) {
    • byte[]: the .wem file with the length as given in the DIDX section, and starting with 52 49 46 46 -- RIFF.
  • } END FOR

ENVS section

The ENVS section (Environments?) section is yet to be analysed.

FXPR section

The FXPR section (Effects production?) section is yet to be analysed.

HIRC section

The HIRC section contains all the Wwise objects, including the events, the containers to group sounds, and the references to the sound files.

Format:

  • 48 49 52 43 -- HIRC
  • uint32: length of section
  • uint32: number of objects
  • FOR EACH (object) {
    • byte: single byte identifying type of object
    • uint32: length of object section (= 4-byte id field and additional bytes)
    • uint32: id of this object
    • byte[]: additional bytes, depending on type of object and section length
  • } END FOR

type #2: Sound SFX

Format:

-- BEGINNING OF SECTION --

  • 02 -- identifier for Sound SFX section
  • uint32: length of this section
  • uint32: id of this Sound SFX object
  • byte[4]: four unknown bytes
  • byte: whether the sound is included in the SoundBank or streamed:
    • 00: embedded in the SoundBank, not streamed
    • 01: is streamed
    • 02: is streamed, with Zero Latency (that is, the sound data is prefetched)
  • byte[3]: three unknown bytes
  • uint32: id of the audio file
  • uint32: id of the source:
    • If this file is embedded, this will contain the SoundBank id as given in the STID section.
    • If the file is being streamed, this number will be identical to the audio file id and can be used to find the .wem file to stream.

IF (file is embedded in a SoundBank) {

  • uint32: offset to the position where the .wem sound file can be found in the SoundBank
  • uint32: length in bytes of the .wem sound file in the SoundBank

} END IF

  • byte[7]: seven unknown bytes
  • uint32: id of the parent container, e.g. a Random Container
  • byte[2]: two unknown bytes
  • uint16: number of additional properties given in this file; they are only included if they are different from their default values
  • FOR EACH (property) {
    • byte: the type of the property:
      • 00: Volume, given as float
      • 02: Pitch, given as float
      • 03: Low Pass Filter (LPF), given as float
      • 07: whether to Loop, given as uint32 = number of loops, or infinite if the value is 0
  • } END FOR
  • FOR EACH (property) {
    • byte[]: the value of the property, decoded based on the property type, see above
  • } END FOR
  • byte[21]: 21 additional bytes, yet to be decoded

-- END OF SECTION --

type #3: Event Action

Format:

  • 03 -- identifier for Event Action section
  • uint32: length of this section
  • uint32: id of this Event Action object
  • byte: The Scope of this Event Action:
    • 02: Global
    • 03: Game object (see referenced object id)
    • 05: All
    • 09: All Except (see referenced object id)
  • byte: Action Type:
    • 01: Stop
    • 02: Pause
    • 03: Resume
    • 04: Play
    • 06: Mute
    • 07: UnMute
    • 08: Set Voice Pitch
    • 09: Reset Voice Pitch
    • 0A: Set Voice Volume
    • 0B: Reset Voice Volume
    • 0C: Set Bus Volume
    • 0D: Reset Bus Volume
    • 0E: Set Voice Low-pass Filter
    • 0F: Reset Voice Low-pass Filter
    • 10: Enable State
    • 11: Disable State
    • 1A: Enable Bypass or Disable Bypass
    • 1B: Reset Bypass Effect
    • 1C: Break
    • 1E: Seek
  • uint32: id of the object that is referenced by this Event Action
  • byte[]: Some more unknown bytes with settings for this Event Action

Possible settings:

  • 0E: Delay, given as uint32 in milliseconds
  • 0F: Play: Fade in time, given as uint32 in milliseconds
  • 10: Probability, given as float

More information will follow.

type #4: Event

Format:

-- BEGINNING OF SECTION --

  • 04 -- identifier for Event section
  • uint32: length of this section
  • uint32: id of this Event object
  • uint32: the number of Event Actions this Event has
  • FOR EACH (event action) {
    • uint32: id of the Event Action
  • } END FOR

-- END OF SECTION --

type #5: Random Container or Sequence Container

More information will follow.

type #6: Switch Container

More information will follow.

type #7: Actor-Mixer

More information will follow.

type #8: Audio Bus?

More information will follow.

type #10: Music Segment

More information will follow.

type #11: Music Track

More information will follow.

type #13: Music Playlist Container

More information will follow.

STID section

The STID section (Sound Type ID?) section contains a list of all the SoundBanks referenced in the HIRC section (including the current SoundBank). In the HIRC section, only the SoundBank ids are given, so this section can be used to match an id with a SoundBank file name.

  • 53 54 49 44 -- STID
  • uint32: length of section
  • uint32: unknown integer, always 01 00 00 00
  • uint32: number of SoundBanks
  • FOR EACH (SoundBank) {
    • uint32: SoundBank id
    • byte: length of SoundBank name
    • char[]: String with given length, e.g. "music". Can be used to find the SoundBank file name: "music.bnk".
  • } END FOR

STMG section

The STMG section section can only be found in the Init.bnk SoundBank. It contains the project settings and global variables.

  • 53 54 4D 47 -- STMG
  • uint32: length of section
  • uint32: project id
  • byte[10]: ten unknown bytes
  • uint32: number of parameters
  • FOR EACH (parameter) {
    • uint32: parameter id
    • float: parameter value
  • } END FOR

More information will follow.

Further information

You can get Wwise, free for personal use, at Audiokinetic.com, to generate custom SoundBank files and train your converter/reader. Also, I recommend watching the video tutorials at www.audiokinetic.com/en/resources/videos, specifically:

  • Using the interface
  • Importing Audio Files
  • Building Sound Hierarchies
  • Creating Events
  • Building SoundBanks
  • Relation between Sound, Source and Audio File