Skip to main content
In this topic, we will walk through the expected code flow about how to use hardware for FFT/IFFT on XBOX Series X devices by using one of the samples included with the Microsoft Game Development Kit (GDK).

Hardware connection and startup

A connection has to be established with the hardware acceleration unit via XDspConnect. The caller sets the requirements for the connection by using the following parameters:
  1. baseBuffer - A pointer to the user allocated memory enough to hold input, output and/or block multiplier buffers that will be passed to the hardware. This memory should be allocated via XMemAlloc with these attributes: XALLOC_MEMTYPE_PHYSICAL_CACHEABLE, XALLOC_PAGESIZE_64KB, XALLOC_ALIGNMENT_64K. These attributes should be set using MAKE_XALLOC_ATTRIBUTES(), as shown in the example below. This memory should not be freed until XDspDisconnect call succeeds. This buffer should be at least 64KB in size.
  2. baseBufferLength - The length of the baseBuffer in bytes. This buffer should be at least 64KB.
  3. aggregateImpulseResponseInSeconds - It represents the overall duration of all the individual impulse responses that will be activated simultaneously using XDspActivate with XDspProcessType::Convolution. If this value is 0, no streams with XDspProcessType::Convolution can be activated.
  4. handle - a pointer to the XDspClientHandle to hold the handle returned by this call.
If the call succeeds, the baseBuffer can be used by the caller to pass input data and retrieve the output data of the streams via XDspCommand parameters. Any buffer that is passed in the XDspCommand should be 16 byte aligned. The following example of a simple buffer manager can be used for managing the input and output buffers.
Following is the code example for the first step to allocate memory and establish a connection.
Where XMemAllocAttributes represents the attributes mentioned above. The following code sets the aggregateImpulseResponse to 32 seconds.

Activation and deactivation of streams

After the connection is established with the device, the caller should send a stream activation command to engage a convolution, FFT or IFFT. The caller must specify the XDspProcessType, block frame count, channel count, impulse response length in floats and a pointer to the impulse response data in frequency domain in the XDspActivationParameters. Only mono or stereo streams are allowed. For XDspProcessType::ForwardFourierTransform and XDspProcessType::inverseFourierTransform, XDspActivationParameters::impulseResponse should be nullptr and XDspActivationParameters::impulseResponseLengthInFloats = 0. XDspActivationOptions should be set appropriately. Following is the code to activate one stream for Forward Fourier Transform and the code similar for Inverse Fourier Transform.
XDspActivate returns a XDspStatus buffer as one of its parameters. This XDspStatus buffer should be used to find the status of the commands processed by the hardware for this stream. After the activation result is received, the caller can start submitting data for Convolution/FFT/IFFT. This should be done by using the XDspSubmitCommand API. For each XDspSubmitCommand, the caller must do the following:
  1. Fill the input buffer with exactly blockFrameCount of data.
  2. Fill in the XDspCommand with appropriate values and input and output buffers that are 16 byte aligned.
  3. Call XDspSubmitCommand to submit the command to the hardware. This function returns a command sequence number that can be used to track the number of commands sent to the hardware.
Next, XDspStatus can be checked to find the status of the commands submitted to the hardware as follows:
The packets in the stream are processed or the hardware returns an error in XDspStatus result, XDspDeactivate should be called.
XDspDeactivate returns XDSP_E_PENDING_RESULTS if the hardware is not done processing all commands submitted for this stream.

Termination

After XDspDeactivate succeeds, the caller must call XDspDisconnect to disconnect from the audio hardware acceleration unit to free all the allocated resources. If all streams are not deactivated, XDspDisconnect will return XDSP_E_NOT_ALL_HANDLES_DEACTIVATED error.
Last modified on August 20, 2026