Both xWMA and XMA2 have their origins in the codecs developed for Windows Media Audio (WMA) and both have been developed specifically for XBOX games. The subset of the available codecs and parameters used by XMA2 is smaller than the subset used by xWMA. While both xWMA and XMA2 were developed for XBOX, they’re not interchangeable: the headers for each file format differ, and the formats are incompatible with PC versions of Windows. The codecs used for XMA2 and xWMA are slightly different, too, so each will have its own artifacts from the compression system that’s used.
xWMA encoding
To encode audio data to xWMA, use the xWMAEncode command-line tool or a custom tool that relies on XWMAEncoder.lib.xWMAEncode
To encode audio files as xWMA for use with XAudio2, use the xWMA command-line encoder.XWMAEncoder.lib
XWMAEncoder.lib is a statically linked library that’s available as an alternative to the xWMA command-line encoder command-line tool. Your custom tools rely on this library to perform xWMA encoding by using the XWMAEncoder function. For details and examples of using this function, see the XBOX 360 documentation.xWMA decoding
Software decoding of xWMA is supported on Windows and on XBOX One in XAudio2, as well as through the xWMADecode API.xWMA looping
xWMA doesn’t support loop regions or looping of arbitrary packets within an xWMA file. Only an entire xWMA file can be looped. In XAudio2, xWMA has restrictions related to looping for the values in the XAUDIO2_BUFFER that’s passed to IXAudio2SourceVoice::SubmitSourceBuffer. If all the xWMA file’s audio data is submitted as one buffer, and if the user wants to loop it, the following restrictions must be met.- XAUDIO2_BUFFER.LoopBegin must always be zero.
- XAUDIO2_BUFFER.LoopLength must be zero or the size, in samples, of the entire file’s xWMA data.
- XAUDIO2_BUFFER.LoopCount can have any value.
- XAUDIO2_BUFFER.Flags must be set to XAUDIO2_END_OF_STREAM.
Structure of an xWMA file
An xWMA file is a standard RIFF file with the following types of chunks. | Chunk FCC| Description| | --- | --- | --- | --- | | RIFF| The standard RIFF chunk contains the following:1. In the first four bytes of its data section, contains a file type with the value
XWMA. 2. In the remainder of the data section, contains the other chunks in the file. | | fmt| This chunk contains the format header for the xWMA file. The data in this chunk corresponds to a WAVEFORMATEX structure for xWMA data with one or two channels, or to a WAVEFORMATEXTENSIBLE structure for xWMA data with three or more channels. | | data| This chunk contains the encoded xWMA audio data. When xWMA is used in XAudio2, the contents of the data chunk will be read into a buffer and passed to a source voice as the pAudioData member of an XAUDIO2_BUFFER structure. The contents of the data chunk don’t need to be byte-swapped. | | dpds| This chunk contains the decoded packet cumulative data size array where each element is the number of bytes accumulated after the corresponding xWMA packet is decoded in order. The size of this chunk, measured in UINT32, and the contents of its data section are used in XAudio2 to fill out an XAUDIO2_BUFFER_WMA structure. |
