The currently recommended way to express format information for XMA2 files is this XMA2WAVEFORMATEX structure. This structure is fully compliant with the WAVEFORMATEX standard and contains all the information needed to parse and manage XMA2 files in a compact way.
typedef struct XMA2WAVEFORMATEX {
WAVEFORMATEX wfx;
WORD NumStreams;
DWORD ChannelMask;
DWORD SamplesEncoded;
DWORD BytesPerBlock;
DWORD PlayBegin;
DWORD PlayLength;
DWORD LoopBegin;
DWORD LoopLength;
BYTE LoopCount;
BYTE EncoderVersion;
WORD BlockCount;
} XMA2WAVEFORMATEX, *PXMA2WAVEFORMATEX;
wfx
A WAVEFORMATEX structure.
NumStreams
Number of audio streams (1 or 2 channels each).
ChannelMask
Spatial positions of the channels in this file. Refer to the XMA_SPEAKER… macros.
SamplesEncoded
Total number of PCM samples the file decodes to.
BytesPerBlock
XMA block size (but the last one may be shorter).
PlayBegin
First valid sample in the decoded audio.
PlayLength
Length of the valid part of the decoded audio.
LoopBegin
Beginning of the loop region in decoded sample terms.
LoopLength
Length of the loop region in decoded sample terms.
LoopCount
Number of loop repetitions; 255 = infinite.
EncoderVersion
Version of XMA encoder that generated the file.
BlockCount
XMA blocks in file (and entries in its seek table).
The XMA2 format is Xbox 360 compatible, and the seek table needs to be ULONG byte-swapped for Xbox One. If the input is a WAVE file the output can be used without alteration.
To byte-swap the seek table use the following lines of code.
for(UINT32 i = 0;(i < xmaformat->BlockCount);i++)
{
rgpXMASeekTable[i] = _byteswap_ulong(rgpXMASeekTable[i]);
}
Consider adding the lines of code to your app to test the funcionality, then perhaps writing a separate tool to perform the swap so no pre-processing is required of your app.
Header: Declared in xma2defs.h.
Library: Use xaudio2.lib and acphal.lib.