xWMA Overview

xWMA is a subset of the Windows Media Audio (WMA) Professional compression format. XAudio2 supports xWMA decoding in software. xWMA uses the WMA bit-stream format in a lightweight wrapper, and is very useful for dialog and music where a small CPU hit is affordable in order to achieve greater compression. A quality setting allows the user to vary the bit rate of the compressed sound.

xWMA Encoding

Encode audio data to xWMA using either the xWMAEncode command-line tool or with custom tools using XWMAEncoder.lib.

xWMAEncode
Use xWMA Command-Line Encoder to encode audio files as xWMA for use with XAudio2.

XWMAEncoder.lib
XWMAEncoder.lib is a statically linked library that is available as an alternative to the xWMA Command-Line Encoder command-line utility.

Your custom tools use this library to perform xWMA encoding, using the XWMAEncoder function. Consult the Xbox 360 documentation for detailed documentation and examples of using this function.

xWMA Decoding

Software decoding of xWMA is supported on both Windows and Xbox One in XAudio2, and also through the xWMADecode API.

Technology Description
XACT XACT is not supported on Xbox One.
XAudio2 In order to use xWMA encoded data in XAudio2, a WAVEFORMATEXTENSIBLE structure needs to be initialized with xWMA specific values and passed as an argument to CreateSourceVoice when a source voice is being created. For an example of loading and playing a sound in XAudio2.
XWMADecode The XWMADecode API allows the direct decoding of xWMA buffers into PCM buffers, without the use of XAudio2.

xWMA Looping

xWMA does not support loop regions or looping of arbitrary packets within an xWMA file. Only an entire xWMA file may be looped. In XAudio2 xWMA has the following rules related to looping for the values in the XAUDIO2_BUFFER that is passed to IXAudio2SourceVoice::SubmitSourceBuffer.

If all of the xWMA file’s audio data is submitted as one buffer and the user wants to loop it, the following restrictions must be met.

  1. XAUDIO2_BUFFER.LoopBegin must always be zero.
  2. XAUDIO2_BUFFER.LoopLength must be the size, in samples, of the entire file’s xWMA data or 0.
  3. XAUDIO2_BUFFER.LoopCount can be any value.
  4. XAUDIO2_BUFFER.Flags must be set to XAUDIO2_END_OF_STREAM.

If xWMA audio data is submitted as more than one buffer the audio can only be looped manually by resubmitting the series of buffers.

When looping xWMA audio, a period of silence can be introduced. Because of this possibility, looping xWMA audio should generally only be used with sounds that have smooth fade ins and outs (such as ocean waves or other subtle ambient loops).

xWMA File Structure

An xWMA file is a standard RIFF file with the following chunk types.

Chunk FCC Description
RIFF Standard RIFF chunk containing a file type with the value XWMA in the first four bytes of its data section, and the other chunks in the file in the remainder of its data section.
fmt 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 a WAVEFORMATEXTENSIBLE structure for xWMA data with three or more channels.
data Contains the encoded xWMA audio data. When using xWMA 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 do not need to be byte swapped.
dpds Contains the decoded packet cumulative data size array, each element is the number of bytes accumulated after the corresponding xWMA packet is decoded in order. The size of this chunk in UINT32 values and the contents of its data section are used in XAudio2 to fill out an XAUDIO2_BUFFER_WMA structure.

See also

xWMA Command-Line Encoder