> ## 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.

# XWMAEncoder

> XWMAEncoder

Encodes an input buffer into xWMA data.

<a id="syntaxSection" />

## Syntax

```cpp theme={null}
HRESULT XWMAEncoder(
         const BYTE *pInputBuffer,
         DWORD inputBufferSize,
         const WAVEFORMATEX *pInputFormat,
         DWORD outputBitrate,
         BYTE **ppEncodedBuffer,
         DWORD *pEncodedBufferSize,
         WAVEFORMATEX **ppEncodedBufferFormat,
         DWORD *pEncodedBufferFormatSize,
         DWORD **ppDecodedPacketCumulativeBytes,
         DWORD *pDecodedPacketCumulativeBytesSize)  
```

<a id="ID4EG" />

### Parameters

*pInputBuffer*
Type: BYTE \*

Pointer to the input buffer containing PCM data, must contain at least one frame.

*inputBufferSize*
Type: DWORD

Input buffer size, in bytes.

*pInputFormat*
Type: WAVEFORMATEX \*

Input buffer format.

*outputBitrate*
Type: DWORD

Specifies requested bit rate, must be one of 20000, 32000, 48000, 64000, 96000, 160000 or 192000.

*ppEncodedBuffer*
Type: BYTE \*\*

Pointer to a pointer to the encoded data.

*pEncodedBufferSize*
Type: DWORD \*

Pointer to a DWORD containing the encoded data size, in bytes.

*ppEncodedBufferFormat*
Type: WAVEFORMATEX \*\*

Pointer to a pointer to the output format structure.

*pEncodedBufferFormatSize*
Type: DWORD \*

Pointer to a DWORD containing the output format structure size.

*ppDecodedPacketCumulativeBytes*
Type: DWORD \*\*

Decoded packet cumulative data size array (use free \[] to release). Each element is the number of bytes accumulated when the corresponding WMA packet is decoded in order, must have PacketCount elements. PacketCount is set in the XAUDIO2\_BUFFER\_WMA structure.

*pDecodedPacketCumulativeBytesSize*
Type: DWORD \*

Size of decoded packet cumulative data (in bytes). The number of packets = \*pDecodedPacketCumulativeBytesSize / sizeof(DWORD);

<a id="ID4EO" />

### Return value

Type: HRESULT

Returns S\_OK if successful; otherwise, returns an error code from the following table.

| Error code                          | Description                                                                               |
| ----------------------------------- | ----------------------------------------------------------------------------------------- |
| XWMA\_E\_UNSUPPORTED\_FORMATTAG     | Format tag must be WAVE\_FORMAT\_PCM or WAVE\_FORMAT\_IEEE\_FLOAT.                        |
| XWMA\_E\_UNSUPPORTED\_FRAMERATE     | nSamplesPerSec must be between 1 kHz and 200 kHz.                                         |
| XWMA\_E\_UNSUPPORTED\_CHANNELS      | nChannels must be 1, 2, or 6.                                                             |
| XWMA\_E\_UNSUPPORTED\_BITSPERSAMPLE | wBitsPerSample must be 8, 16, or 24 for integer input data or 32 for floating-point data. |
| XWMA\_E\_UNSUPPORTED\_BITRATE       | bitrate must be 20 Kbps, 32 Kbps, 48 Kbps, 64 Kbps, 96 Kbps, 16 Kbps0, or 192 Kbps.       |

<a id="remarks" />

## Remarks

The following table shows natively supported bit rates per sample rate and channel count.

\| Input| Output options|
\| --- | --- | --- | --- |
\| 22050 Hz mono| 20000|
\| 22050 Hz stereo| 32000|
\| 32000 Hz mono| 20000|
\| 32000 Hz stereo| 32000, 48000|
\| 44100 Hz mono| 32000, 48000|
\| 44100 Hz stereo| 32000, 48000, 96000, 192000|
\| 44100 Hz 5.1| 96000, 192000|
\| 48000 Hz stereo| 48000, 64000, 96000, 160000, 192000|
\| 48000 Hz 5.1| 48000, 192000|

<a id="requirements" />

## Requirements

**Header:** xwmaencoder.h

**Library:** xwmaencoder.lib

## See also

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


## Related topics

- [Xwmaencoder functions](/build/console-features/audio/tools/xwmaencoder/tech-xwmaencoder-nativereference-funcs.md)
- [xWMA Encoder reference information](/build/console-features/audio/tools/xwmaencoder/atoc-xwmaencoder.md)
- [Overview of xWMA](/build/console-features/audio/overviews/xwma-overview.md)
- [xWMA encoder library and command line tool](/build/console-features/audio/tools/xwmaencoder/index.md)
- [XMA2 encoder library and command line tool](/build/console-features/audio/tools/xma2encoder/index.md)
