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

# SetShapeDmaCommand

> SetShapeDmaCommand

# SetShapeDmaCommand

Initializes a SHAPE DMA command.

## Syntax

```cpp theme={null}
HRESULT SetShapeDmaCommand(  
         SHAPE_FLOWGRAPH_COMMAND* command,  
         UINT32 contextId,  
         UINT32 mixBuffer,  
         bool writeToMixBuffer  
)  
```

### Parameters

*command*   \_Inout\_\
Type: SHAPE\_FLOWGRAPH\_COMMAND\*

The [SHAPE\_FLOWGRAPH\_COMMAND](/reference/audio/shapeflowgraph/structs/shape_flowgraph_command) command to initialize.

*contextId*   \
Type: UINT32

DMA context ID (that is, the index) this command will reference.

*mixBuffer*   \
Type: UINT32

The mix buffer to be read from or written to, depending on the setting of the *writeToMemory* flag.

*writeToMixBuffer*   \
Type: bool

True if the DMA command is to write to the specified mix buffer and to read from main memory. False if the DMA command is to read from the specified mix buffer and to write to main memory.

### Return value

Type: HRESULT

If the function succeeds, it returns `S_OK`. If one or more of the arguments are invalid, the function returns `E_INVALIDARG`.

## Remarks

The Direct Memory Access (DMA) system supports read and write functionality with automatic float-to-integer and integer-to-float conversion. The DMA system uses circular buffers containing de-interleaved samples in 128 sample blocks.

The DMA processor allows the Scalable Hardware Audio Processing Engine (SHAPE) to send data from mix buffers to main system memory and retrieve data from main system into the mix buffers for further processing. DMA is done on a block basis, transferring one audio frame of data at a time. To enable block-interleaved data, a skip value specifies the number of audio frame blocks in system memory to skip from the base address when reading or writing samples. Multichannel streams require one DMA context per channel. Audio data samples are always read and written as 32-bit values, either integer or float, as specified in the DMA context `floatConvert` flag.

<Note>the direction of the DMA (read or write) is specified in the DMA command, not in the DMA context. This helps reduce the amount of data bandwidth. The DMA engine has no signal processing, but it can perform float-to-integer conversion or integer-to-float. This allows the application CPU to process data samples in floating-point format.</Note>

## Requirements

**Header:** shapeflowgraph.h

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

## See also

[ACP Overview](/build/console-features/audio/overviews/acp-overview)

[SHAPE Overview](/build/console-features/audio/overviews/shape-overview)

[shapeflowgraph](/reference/audio/shapeflowgraph/shapeflowgraph_members)


## Related topics

- [ShapeFlowGraph](/reference/audio/shapeflowgraph/shapeflowgraph_members.md)
- [SHAPE_FLOWGRAPH_DMA_COMMAND](/reference/audio/shapeflowgraph/structs/shape_flowgraph_dma_command.md)
- [SetShapeDmaBufferFull](/reference/audio/shapedmacontext/functions/setshapedmabufferfull.md)
- [SetShapeDmaAudioBuffer](/reference/audio/shapedmacontext/functions/setshapedmaaudiobuffer_2.md)
- [SetShapeDmaNumFrames](/reference/audio/shapedmacontext/functions/setshapedmanumframes.md)
