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

# GetXmaDecodePositionForSample

> GetXmaDecodePositionForSample

# GetXmaDecodePositionForSample

Obtains data needed to make the decoder generate audio starting at a specified sample position relative to the beginning of the specified XBOX Media Audio (XMA) block.

## Syntax

```cpp theme={null}
HRESULT GetXmaDecodePositionForSample(  
         const BYTE* pXmaData,  
         DWORD nXmaDataBytes,  
         DWORD nStreamIndex,  
         DWORD nDesiredSample,  
         DWORD* pnBitOffset,  
         DWORD* pnSubFrame  
)  
```

### Parameters

*pXmaData*   \_In\_bytecount\_(nXmaDataBytes)\
Type: BYTE\*

Pointer to XMA blocks.

*nXmaDataBytes*   \
Type: DWORD

Size of pXmaData, in bytes.

*nStreamIndex*   \
Type: DWORD

Stream within which to seek.

*nDesiredSample*   \
Type: DWORD

Sample sought.

*pnBitOffset*   \_Out\_\
Type: DWORD\*

Returns the bit offset within pXmaData of the frame that contains the sample sought.

*pnSubFrame*   \_Out\_\
Type: DWORD\*

Returns the subframe that contains the sample.

### Return value

Type: HRESULT

Success `S_OK` or error `E_FAIL` code.

## Remarks

This function obtains data needed to make the decoder generate audio starting at a given sample position relative to the beginning of the given XMA block. This includes the bit offset of the appropriate frame and the right subframe within that frame. The data can be passed directly to the `XMAPlaybackSetDecodePosition` function. For more information about XMA2, see [Overview of XMA2](/build/console-features/audio/overviews/xma2-overview). For an overview of the audio architecture of XBOX One, see **The sound of the future**: [The audio architecture in XBOX One](/build/console-features/audio/overviews/xbox-one-audio-architecture).

## Requirements

**Header:** xma2defs.h

**Supported platforms:** XBOX One family consoles and XBOX Series consoles

## See also

[xma2defs](/reference/audio/xma2defs/xma2defs_members)


## Related topics

- [XMA2Defs](/reference/audio/xma2defs/xma2defs_members.md)
- [GetXmaBlockContainingSample](/reference/audio/xma2defs/functions/getxmablockcontainingsample.md)
- [XMA2WAVEFORMATEX](/reference/audio/xma2defs/structs/xma2waveformatex.md)
- [GetXmaFrameBitPosition](/reference/audio/xma2defs/functions/getxmaframebitposition.md)
- [GetLastXmaFrameBitPosition](/reference/audio/xma2defs/functions/getlastxmaframebitposition.md)
