XWV: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
(Complete rewrite using the information from the SDK)
Line 1: Line 1:
{{cleanup}}
{{stub}}


The sound format used by Valve's Xbox 360 games. Still being researched...
'''XWV''' is the sound format used by Valve's Xbox 360 games. It is similar to the WAV format and uses the big-endian byte order. The format is defined in the [[SDK]] in ''public\xwvfile.h'';


No Known values listed = one value is consistent across all tested files.
== Header ==
Except for the id field it appears to be Big Endian.


Header
<source lang="cpp">
#define XWV_ID (('X'<<24)|('W'<<16)|('V'<<8)|(' '<<0))
#define XWV_VERSION 4


<code>
enum xwvSampleRate_t
DWORD id = 1482118688 "XWV " (Xbox Wave (Little Endian) or Valve Wave Xbox (Big Endian))
{
XWV_RATE_11025 = 0,
XWV_RATE_22050 = 1,
XWV_RATE_44100 = 2,
};


DWORD magic1 = 4
enum xwvFormat_t
{
XWV_FORMAT_PCM = 0,
XWV_FORMAT_XMA = 1,
XWV_FORMAT_ADPCM = 2,
};


DWORD magic2 = 48
// generated in big-endian
 
struct xwvHeader_t
DWORD magic3 = (known values 156, 172, 192, 324) increases with file size
{
 
unsigned int id;
DWORD magic4 = 2048 (header size?)
unsigned int version;
 
unsigned int headerSize; // header only
DWORD magic5 = (filesize - magic4)
unsigned int staticDataSize; // follows header
 
unsigned int dataOffset; // start of samples, possibly sector aligned
DWORD magic6 = (kv 268288, 204288, 243200, 471040) proportionally increases with file size (double file size doubles this)
unsigned int dataSize; // length of samples in bytes
 
unsigned int numDecodedSamples; // for duration calcs
DWORD magic7 = -1
int loopStart; // -1 = no loop, offset of loop in samples
 
unsigned short loopBlock; // the xma block where the loop starts
DWORD magic8 = 0
unsigned short numLeadingSamples; // number of leading samples in the loop block to discard
 
unsigned short numTrailingSamples; // number of trailing samples at the final block to discard
DWORD magic9 = 16
unsigned short vdatSize; // follows seek table
 
byte format;
DWORD magic10 = 17826305
byte bitsPerSample;
 
byte sampleRate;
DWORD magic11 = 1258356736
byte channels;
 
byte quality;
DWORD magic12 = (known values 6144, 7680, 5632, 2 files of vastly different sizes both had 7680)
byte bHasSeekTable; // indicates presence, follows header
 
byte padding[2]; // created as 0
DWORD magic13 = (kv 14848, 13312, 13824) (2 files of different sizes both had 13312, bigger files have had smaller numbers)
};
 
</source>
DWORD magic14 = (kv 20992, 19968)
 
<more magics, always seem to be similar between files and slightly bigger in bigger files>
 
 
At offset of magic4:
Always "<"
</code>


[[Category:File formats]]
[[Category:File formats]]

Revision as of 01:41, 16 April 2011

Stub

This article or section is a stub. You can help by expanding it.

XWV is the sound format used by Valve's Xbox 360 games. It is similar to the WAV format and uses the big-endian byte order. The format is defined in the SDK in public\xwvfile.h;

Header

#define XWV_ID		(('X'<<24)|('W'<<16)|('V'<<8)|(' '<<0))
#define XWV_VERSION 4

enum xwvSampleRate_t
{
	XWV_RATE_11025 = 0,
	XWV_RATE_22050 = 1,
	XWV_RATE_44100 = 2,
};

enum xwvFormat_t
{
	XWV_FORMAT_PCM = 0,
	XWV_FORMAT_XMA = 1,
	XWV_FORMAT_ADPCM = 2,
};

// generated in big-endian
struct xwvHeader_t
{
	unsigned int	id;
	unsigned int	version;
	unsigned int	headerSize;		// header only
	unsigned int	staticDataSize;		// follows header
	unsigned int	dataOffset;		// start of samples, possibly sector aligned
	unsigned int	dataSize;		// length of samples in bytes
	unsigned int	numDecodedSamples;	// for duration calcs
	int		loopStart;		// -1 = no loop, offset of loop in samples
	unsigned short	loopBlock;		// the xma block where the loop starts 
	unsigned short	numLeadingSamples;	// number of leading samples in the loop block to discard
	unsigned short	numTrailingSamples;	// number of trailing samples at the final block to discard
	unsigned short	vdatSize;		// follows seek table
	byte		format;
	byte		bitsPerSample;
	byte		sampleRate;
	byte		channels;
	byte		quality;
	byte		bHasSeekTable;		// indicates presence, follows header
	byte		padding[2];		// created as 0
};