Difference between revisions of "XBOX XWB3"

From XentaxWiki
Jump to: navigation, search
m
m (Reverted edits by Xz3J1f (Talk); changed back to last version by Mr.Mouse)
Line 8: Line 8:
  
 
<tt><b>
 
<tt><b>
char {4}
+
char {4}&nbsp;&nbsp;&nbsp;&nbsp; - Header <font color="purple">(WBND)</font> <br>
 +
uint32 {4}&nbsp;&nbsp; - Version <font color="purple">(3)</font> <br>
 +
uint32 {4}&nbsp;&nbsp; - Size Of Header 1 <font color="purple">(40)</font> <br>
 +
uint32 {4}&nbsp;&nbsp; - Size Of Header 2 <font color="purple">(40)</font> <br>
 +
uint32 {4}&nbsp;&nbsp; - Offset To Details Directory <font color="purple">(80)</font> <br>
 +
uint32 {4}&nbsp;&nbsp; - Length Of Details Directory <br>
 +
uint32 {4}&nbsp;&nbsp; - Offset To Filename Directory <br>
 +
uint32 {4}&nbsp;&nbsp; - Length Of Filename Directory <br>
 +
uint32 {4}&nbsp;&nbsp; - First File Offset <font color="purple">(8192)</font> <br>
 +
uint32 {4}&nbsp;&nbsp; - <font color="red"> '' Unknown '' </font> <br>
 +
uint16 {2}&nbsp;&nbsp; - <font color="red"> '' Unknown <font color="purple">(1)</font> '' </font> <br>
 +
uint16 {2}&nbsp;&nbsp; - <font color="red"> '' Unknown <font color="purple">(1)</font> '' </font> <br>
 +
uint32 {4}&nbsp;&nbsp; - Number Of Files <br>
 +
char {16}&nbsp;&nbsp;&nbsp; - Archive Filename <font color="purple">(null)</font> <font color="purple">(without extension)</font> <br>
 +
uint32 {4}&nbsp;&nbsp; - Length Of Each Details Entry <font color="purple">(24)</font> <br>
 +
uint32 {4}&nbsp;&nbsp; - Length Of Each Filename Entry <font color="purple">(64)</font> <br>
 +
uint32 {4}&nbsp;&nbsp; - Max padding size between each file <font color="purple">(2048)</font> <br>
 +
uint32 {4}&nbsp;&nbsp; - null <br>
 +
<br>
 +
<font color="blue"> ''' // for each file ''' </font> <br>
 +
: uint16 {2}&nbsp;&nbsp; - <font color="red"> '' Unknown <font color="purple">(0/2)</font> '' </font> <br>
 +
: uint16 {2}&nbsp;&nbsp; - <font color="red"> '' Unknown <font color="purple">(1)</font> '' </font> <br>
 +
: uint32 {4}&nbsp;&nbsp; - <font color="red"> '' Unknown '' </font> <br>
 +
: uint32 {4}&nbsp;&nbsp; - File Offset <font color="darkgreen">[+firstFileOffset]</font> <br>
 +
: uint32 {4}&nbsp;&nbsp; - File Length <br>
 +
: uint64 {8}&nbsp;&nbsp; - null <br>
 +
<br>
 +
<font color="blue"> ''' // for each file ''' </font> <br>
 +
: char {64}&nbsp;&nbsp;&nbsp; - Filename <font color="purple">(null)</font> <font color="purple">(without extension)</font> <br>
 +
<br>
 +
<font color="blue"> ''' // for each file ''' </font> <br>
 +
: byte {X}&nbsp;&nbsp;&nbsp;&nbsp; - File Data <br>
 +
: byte {0-2047}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - null Padding so the file length is a multiple of 2048 bytes) <br>
 +
<br>
 +
</b></tt>
 +
 
 +
=== Format Specifications #2 ===
 +
<tt><b>
 +
<font color="blue"> ''' // ARCHIVE HEADER ''' </font> <br>
 +
: char {4}&nbsp;&nbsp;&nbsp;&nbsp;  - Header <font color="purple">(WBND)</font> <br>
 +
: uint32 {4}&nbsp;&nbsp; - Version <br>
 +
<br>
 +
<font color="blue"> ''' // DIRECTORIES ''' </font> <br>
 +
<font color="blue"> ''' // Strictly speaking you can seek past this section, it (always?) refers to 4 directories ''' </font> <br> 
 +
: <font color="blue"> ''' // DIR 1 - WAVE BANK INFO ''' </font> <br>
 +
: uint32 {4}&nbsp;&nbsp; - Offset <br>
 +
: uint32 {4}&nbsp;&nbsp; - Length <br>
 +
: <font color="blue"> ''' // DIR 2 - FILE RECORDS ''' </font> <br>
 +
: uint32 {4}&nbsp;&nbsp; - Offset <br>
 +
: uint32 {4}&nbsp;&nbsp; - Length <br>
 +
: <font color="blue"> ''' // DIR 3 - ALWAYS EMPTY? ''' </font> <br>
 +
: uint32 {4}&nbsp;&nbsp; - Offset <br>
 +
: uint32 {4}&nbsp;&nbsp; - Length <br>
 +
: <font color="blue"> ''' // DIR 4 - FILE DATA ''' </font> <br>
 +
: uint32 {4}&nbsp;&nbsp; - Offset <br>
 +
: uint32 {4}&nbsp;&nbsp; - Length <br>
 +
<br>
 +
 
 +
<font color="blue"> ''' // DIR 1 - WAVE BANK INFO ''' </font> <br>
 +
: uint32 {4}&nbsp;&nbsp; - Flags <br>
 +
: uint32 {4}&nbsp;&nbsp; - Number of files <br>
 +
: byte {16}&nbsp;&nbsp;&nbsp;  -  Wavebank name <font color="purple">(Padded with 0's)</font><br>
 +
: uint32 {4}&nbsp;&nbsp; - Size of each file record (in dir 2) <br>
 +
: uint32 {4}&nbsp;&nbsp; - Size of each entry name block <br>
 +
: uint32 {4}&nbsp;&nbsp; - Offset of file data <br>
 +
: uint32 {4}&nbsp;&nbsp; - Always null? <br>
 +
<br>
 +
 
 +
<font color="blue"> ''' // DIR 2 - FILE RECORDS ''' </font> <br>
 +
:<font color="blue"> ''' // FOR EACH FILE ''' </font> <br>
 +
: uint16 {2}&nbsp;&nbsp; - Number of channels <br>
 +
: uint16 {2}&nbsp;&nbsp; - Format tag <font color="purple">(0=normal pcm) (1=xbox adpcm)</font> <br>
 +
: uint32 {4}&nbsp;&nbsp; - Magic value <br>
 +
: uint32 {4}&nbsp;&nbsp; - File offset <font color="purple">(Relative to start of DIR 4)</font><br>
 +
: uint32 {4}&nbsp;&nbsp; - File size <br>
 +
: uint32 {4}&nbsp;&nbsp; - Loop region offset (not sure what this does)  <br>
 +
: uint32 {4}&nbsp;&nbsp; - Loop region length (not sure what this does)  <br>
 +
<br>
 +
 
 +
 
 +
 
 +
<font color="blue"> ''' // DUMPING FILES''' </font> <br>
 +
Read the file records then seek to 'Offset of file data'(section 3) + File Offset.<br>
 +
The files are wav's so you need to write a .wav header first and then copy the data<br>
 +
<br>
 +
 
 +
Extra Checks:<br>
 +
The number of channels can be wrong, sometimes its given as 0 or even 15 and sometimes it indicates a stereo file when its actually mono. The bottom line is - dont trust the 'number of channels' value. The correct number of channels can be worked out from the 'magic value', below is the code I use to do this:
 +
function TPsychoAudioDumper.RepairXboxChannels(Format, MagicValue,
 +
  Channels: cardinal): integer;
 +
var
 +
  Temp: integer;
 +
begin
 +
  if format=0 then //Pcm
 +
  begin
 +
    Temp:=(MagicValue - 4) mod 32;
 +
    if Temp=0 then
 +
      Result:=1
 +
    else
 +
      Result:=2;
 +
  end
 +
  else
 +
  if format=1 then //Adpcm
 +
  begin
 +
    Temp:=(MagicValue - 5) mod 32;
 +
    if Temp=0 then
 +
      Result:=1
 +
    else
 +
      Result:=2;
 +
  end
 +
  else
 +
    Result:=1;
 +
end;
 +
<br>
 +
Similarly, the samplerate is sometimes wrong, so to correct this:<br>
 +
 
 +
function TPsychoAudioDumper.GetXboxSamplerate(Format, MagicValue,
 +
  Channels: cardinal): integer;
 +
begin
 +
  if format=0 then //Pcm
 +
  begin
 +
    if Channels=1 then
 +
    begin
 +
      if MagicValue=2148894852 then //1 channel
 +
        result:=44100
 +
      else
 +
      if MagicValue=2148507652 then //1 channel
 +
        result:=32000
 +
      else
 +
      if MagicValue=2148189252 then //1 channel
 +
        result:=22050
 +
      else
 +
      if MagicValue=705604 then //1 channel
 +
        result:=22050
 +
      else
 +
      if MagicValue=352804 then //1 channel
 +
        result:=11025
 +
      else
 +
      if MagicValue=256004 then //1 channel
 +
        result:=8000
 +
      else
 +
        begin
 +
          result:=0;
 +
          if Assigned(FOnDebug) then
 +
            FOnDebug('Unknown magic value! = ' + inttostr(magicvalue));
 +
        end
 +
    end
 +
    else //2 channels
 +
    begin
 +
      if MagicValue=2148894856 then //2 channel
 +
        result:=44100
 +
      else
 +
      if MagicValue=2148507656 then //2 channel
 +
        result:=32000
 +
      else
 +
      if MagicValue=2148189256 then //2 channel
 +
        result:=22050
 +
      else
 +
        begin
 +
          result:=0;
 +
          if Assigned(FOnDebug) then
 +
            FOnDebug('Unknown magic value! = ' + inttostr(magicvalue));
 +
        end
 +
    end;
 +
  end
 +
  else
 +
  if format=1 then //Adpcm
 +
  begin
 +
    Result:=(MagicValue - (1 + (Channels * 4))) div 32;
 +
  end
 +
  else
 +
    Result:=0;
 +
end;
 +
<br>
 +
Very rarely, the format tag is given as 2, this should be treated as format tag 0 - a normal pcm wave.<br>
 +
<br>
 +
</b></tt>
 +
 
 +
=== Notes and Comments ===
 +
 
 +
XWB files (Xbox Wavebanks) contain the audio data and are only used in the XBox version. XWB files are also used in many other XBox games, the specs here are only tested with Psychonauts though.<br>
 +
<br>
 +
XWB files contain 2 types of audio:<br>
 +
: PCM - Standard Wave PCM<br>
 +
: Xbox ADPCM - As used by many Xbox games<br><br>
 +
 
 +
The PCM audio can be played easily, to play the Xbox ADPCM however you either need to pass it through a decoder (there's one in [http://quick.mixnmojo.com/software.php#psychonautsexplorer Psychonauts Explorer]) or install the Xbox ADPCM codec.<br>
 +
<br>
 +
The Wavebank doesnt contain any file names. This is because these are stored in a seperate file - the SoundBank file (.xsb). See below for info on this.<br>
 +
<br>
 +
 
 +
=== MultiEx BMS Script ===
 +
 
 +
Not written yet<br><br>
 +
 
 +
=== Compatible Programs ===
 +
 
 +
* [[Game Extractor|Game Extractor]]<br>
 +
* [http://quick.mixnmojo.com/software.php#psychonautsexplorer Psychonauts Explorer]<br>
 +
 
 +
=== Other Games ===
 +
 
 +
These games use this file format<br>
 +
* Full Spectrum Warrior *.xwb
 +
* Ghost Recon 2 (XBox) *.xwb
 +
* Powerdrome *.xwb
 +
* Psychonauts *.xwb
 +
* Return To Castle Wolfenstein: Tide Of War (XBox) *.xwb
 +
* Star Trek Shattered Universe (XBox) *.xwb
 +
* Sudeki *.xwb
 +
* Unreal Championship 2: The Liandri Conflict (XBox) *.xwb

Revision as of 17:09, 18 June 2007

XWB


Format Specifications

char {4}     - Header (WBND)
uint32 {4}   - Version (3)
uint32 {4}   - Size Of Header 1 (40)
uint32 {4}   - Size Of Header 2 (40)
uint32 {4}   - Offset To Details Directory (80)
uint32 {4}   - Length Of Details Directory
uint32 {4}   - Offset To Filename Directory
uint32 {4}   - Length Of Filename Directory
uint32 {4}   - First File Offset (8192)
uint32 {4}   - Unknown
uint16 {2}   - Unknown (1)
uint16 {2}   - Unknown (1)
uint32 {4}   - Number Of Files
char {16}    - Archive Filename (null) (without extension)
uint32 {4}   - Length Of Each Details Entry (24)
uint32 {4}   - Length Of Each Filename Entry (64)
uint32 {4}   - Max padding size between each file (2048)
uint32 {4}   - null

// for each file

uint16 {2}   - Unknown (0/2)
uint16 {2}   - Unknown (1)
uint32 {4}   - Unknown
uint32 {4}   - File Offset [+firstFileOffset]
uint32 {4}   - File Length
uint64 {8}   - null


// for each file

char {64}    - Filename (null) (without extension)


// for each file

byte {X}     - File Data
byte {0-2047}      - null Padding so the file length is a multiple of 2048 bytes)


Format Specifications #2

// ARCHIVE HEADER

char {4}     - Header (WBND)
uint32 {4}   - Version


// DIRECTORIES
// Strictly speaking you can seek past this section, it (always?) refers to 4 directories

// DIR 1 - WAVE BANK INFO
uint32 {4}   - Offset
uint32 {4}   - Length
// DIR 2 - FILE RECORDS
uint32 {4}   - Offset
uint32 {4}   - Length
// DIR 3 - ALWAYS EMPTY?
uint32 {4}   - Offset
uint32 {4}   - Length
// DIR 4 - FILE DATA
uint32 {4}   - Offset
uint32 {4}   - Length


// DIR 1 - WAVE BANK INFO

uint32 {4}   - Flags
uint32 {4}   - Number of files
byte {16}    - Wavebank name (Padded with 0's)
uint32 {4}   - Size of each file record (in dir 2)
uint32 {4}   - Size of each entry name block
uint32 {4}   - Offset of file data
uint32 {4}   - Always null?


// DIR 2 - FILE RECORDS

// FOR EACH FILE
uint16 {2}   - Number of channels
uint16 {2}   - Format tag (0=normal pcm) (1=xbox adpcm)
uint32 {4}   - Magic value
uint32 {4}   - File offset (Relative to start of DIR 4)
uint32 {4}   - File size
uint32 {4}   - Loop region offset (not sure what this does)
uint32 {4}   - Loop region length (not sure what this does)



// DUMPING FILES
Read the file records then seek to 'Offset of file data'(section 3) + File Offset.
The files are wav's so you need to write a .wav header first and then copy the data

Extra Checks:
The number of channels can be wrong, sometimes its given as 0 or even 15 and sometimes it indicates a stereo file when its actually mono. The bottom line is - dont trust the 'number of channels' value. The correct number of channels can be worked out from the 'magic value', below is the code I use to do this:

function TPsychoAudioDumper.RepairXboxChannels(Format, MagicValue,
 Channels: cardinal): integer;
var
  Temp: integer;
begin
  if format=0 then //Pcm
  begin
    Temp:=(MagicValue - 4) mod 32;
    if Temp=0 then
      Result:=1
    else
      Result:=2;
  end
  else
  if format=1 then //Adpcm
  begin
    Temp:=(MagicValue - 5) mod 32;
    if Temp=0 then
      Result:=1
    else
      Result:=2;
  end
  else
    Result:=1;
end;


Similarly, the samplerate is sometimes wrong, so to correct this:

function TPsychoAudioDumper.GetXboxSamplerate(Format, MagicValue,
  Channels: cardinal): integer;
begin
  if format=0 then //Pcm
  begin
    if Channels=1 then
    begin
      if MagicValue=2148894852 then //1 channel
        result:=44100
      else
      if MagicValue=2148507652 then //1 channel
        result:=32000
      else
      if MagicValue=2148189252 then //1 channel
        result:=22050
      else
      if MagicValue=705604 then //1 channel
        result:=22050
      else
      if MagicValue=352804 then //1 channel
        result:=11025
      else
      if MagicValue=256004 then //1 channel
        result:=8000
      else
        begin
          result:=0;
          if Assigned(FOnDebug) then
            FOnDebug('Unknown magic value! = ' + inttostr(magicvalue));
        end
    end
    else //2 channels
    begin
      if MagicValue=2148894856 then //2 channel
        result:=44100
      else
      if MagicValue=2148507656 then //2 channel
        result:=32000
      else
      if MagicValue=2148189256 then //2 channel
        result:=22050
      else
        begin
          result:=0;
          if Assigned(FOnDebug) then
            FOnDebug('Unknown magic value! = ' + inttostr(magicvalue));
        end
    end;
  end
  else
  if format=1 then //Adpcm
  begin
    Result:=(MagicValue - (1 + (Channels * 4))) div 32;
  end
  else
    Result:=0;
end;


Very rarely, the format tag is given as 2, this should be treated as format tag 0 - a normal pcm wave.

Notes and Comments

XWB files (Xbox Wavebanks) contain the audio data and are only used in the XBox version. XWB files are also used in many other XBox games, the specs here are only tested with Psychonauts though.

XWB files contain 2 types of audio:

PCM - Standard Wave PCM
Xbox ADPCM - As used by many Xbox games

The PCM audio can be played easily, to play the Xbox ADPCM however you either need to pass it through a decoder (there's one in Psychonauts Explorer) or install the Xbox ADPCM codec.

The Wavebank doesnt contain any file names. This is because these are stored in a seperate file - the SoundBank file (.xsb). See below for info on this.

MultiEx BMS Script

Not written yet

Compatible Programs

Other Games

These games use this file format

  • Full Spectrum Warrior *.xwb
  • Ghost Recon 2 (XBox) *.xwb
  • Powerdrome *.xwb
  • Psychonauts *.xwb
  • Return To Castle Wolfenstein: Tide Of War (XBox) *.xwb
  • Star Trek Shattered Universe (XBox) *.xwb
  • Sudeki *.xwb
  • Unreal Championship 2: The Liandri Conflict (XBox) *.xwb