> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview of xWMA

> xWMA audio format for XBOX games: a WMA Professional subset decoded in software by XAudio2 for compressed dialog and music streams.

xWMA is a subset of the Windows Media Audio (WMA) Professional compression format. xWMA decoding is supported by [XAudio2](/build/console-features/audio/overviews/xaudio2-overview) in software. xWMA uses the WMA bit-stream format in a lightweight wrapper and is useful for dialog and music where a small usage of the CPU can be afforded as a cost of achieving greater compression. A quality setting allows the user to vary the bit rate of the compressed sound.

<Note>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.</Note>

In this topic:

* [xWMA encoding](#ID4EW)
* [xWMA decoding](#ID4E6B)
* [xWMA looping](#ID4ETD)
* [Structure of an xWMA file](#ID4ESE)

<a id="ID4EW" />

## 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](/build/console-features/audio/tools/xwmaencode-tools).

### XWMAEncoder.lib

XWMAEncoder.lib is a statically linked library that's available as an alternative to the [xWMA command-line encoder](/build/console-features/audio/tools/xwmaencode-tools) 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.

<a id="ID4E6B" />

## xWMA decoding

Software decoding of xWMA is supported on Windows and on XBOX One in XAudio2, as well as through the xWMADecode API.

| Technology | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| XACT       | XACT isn't supported on XBOX One.                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| XAudio2    | To use xWMA-encoded data in XAudio2, (1) initialize a WAVEFORMATEXTENSIBLE structure with xWMA-specific values, and (2) pass the structure as an argument to [CreateSourceVoice](https://learn.microsoft.com/windows/desktop/api/xaudio2/nf-xaudio2-ixaudio2-createsourcevoice) when creating a source voice. For an example of loading and playing sounds in XAudio2, see [How to: playing a sound with XAudio2](https://msdn.microsoft.com/library/windows/desktop/ee415787\(v=vs.85\).aspx). |
| XWMADecode | Use the XWMADecode API to decode xWMA buffers into PCM buffers directly, without using XAudio2.                                                                                                                                                                                                                                                                                                                                                                                                 |

<a id="ID4ETD" />

## 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](https://learn.microsoft.com/windows/desktop/api/xaudio2/ns-xaudio2-xaudio2_buffer) that's passed to [IXAudio2SourceVoice::SubmitSourceBuffer](https://learn.microsoft.com/windows/desktop/api/xaudio2/nf-xaudio2-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.

1. XAUDIO2\_BUFFER.LoopBegin must always be zero.
2. XAUDIO2\_BUFFER.LoopLength must be zero or the size, in samples, of the entire file's xWMA data.
3. XAUDIO2\_BUFFER.LoopCount can have 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 be looped only manually by resubmitting the series of buffers.

Because a period of silence might be introduced while xWMA audio is looped, looping of xWMA audio should generally be used only with sounds that have smooth fade-ins and fade-outs. Examples include the sounds of ocean waves and certain kinds of subtle ambient noise.

<a id="ID4ESE" />

## 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: <br />1. In the first four bytes of its data section, contains a file type with the value `XWMA`. <br /> 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](https://learn.microsoft.com/windows/desktop/api/mmreg/ns-mmreg-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](https://learn.microsoft.com/windows/desktop/api/xaudio2/ns-xaudio2-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](https://learn.microsoft.com/windows/desktop/api/xaudio2/ns-xaudio2-xaudio2_buffer_wma) structure. |

<a id="ID4EPG" />

## See also

[xWMA command-line encoder](/build/console-features/audio/tools/xwmaencode-tools)


## Related topics

- [Overviews](/build/console-features/audio/overviews/index.md)
- [The audio architecture in XBOX One](/build/console-features/audio/overviews/xbox-one-audio-architecture.md)
- [Audio](/build/console-features/audio/gc-audio-toc.md)
- [Overview of XMA2](/build/console-features/audio/overviews/xma2-overview.md)
- [xWMA Encoder reference information](/build/console-features/audio/tools/xwmaencoder/atoc-xwmaencoder.md)
