XDSP.H: Digital Signal Processing helper functions

The DirectX SDK (June 2010) release includes a little utility header, XDSP.H. This contains CPU-based functions for computing the Fast Fourier Transform (FFT) as well as some related multi-channel audio interleave/deinterleave functionality primarily used in writing custom xAPOs for XAUDIO2. The DirectX SDK version makes use of SSE intrinsics, which means it supports Windows x86 and x64 native code generation. This header is not included in the Windows SDK 8.0 (see "Where is the DirectX SDK?"). If writing a custom xAPO for Windows Store apps (a.k.a. Metro style apps), you also likely want to support the Windows RT (aka Windows on ARM) platform as well.

Attached to this post is a version of XDSP.H that uses DirectXMath and compiles for x86, x64, and ARM. It can be used with either Visual Studio 2012 (aka VS 11) or VS 2010 with the Windows 8.0 SDK, and compiles for both Win32 desktop applications and Windows Store apps.

Full documentation for XDSP can be found in the offline help for the DirectX SDK (June 2010) release. These functions are in the XDSP C++ namespace, and memory buffers provided to these functions must be 16-byte aligned.

Deinterleave Deinterleaves audio samples.
FFT Fast Fourier Transform with an arbitrary number of samples.
FFT4 Four sample Fast Fourier Transform.
FFT8 Eight sample Fast Fourier Transform.
FFT16 Sixteen sample Fast Fourier Transform.
IFFTDeinterleaved Inverse Fast Fourier Transform, plus interleaved multichannel audio.
FFTInitializeUnityTable Initializes unity roots lookup table used by Fast Fourier Transform
functions (FFT, FFTDeinterleaved, and FFTInterleaved)
FFTInterleaved Fast Fourier Transform, plus deinterleaves multichannel audio before
FFTPolar Converts complex components to polar form.
FFTUnswizzle Arranges Fast Fourier Transform function output by order of increasing frequency.
Interleave Interleaves audio samples.

Note that vmulComplex, ButterflyDIT4_1, and ButterflyDIT4_4 are internal implementation functions and not intended for direct use.

Note: There is a Windows Store app sample on MSDN Code Gallery that makes use of this header.

Update: This project is now available on GitHub under the MIT license.

Comments (4)

Cancel reply

  1. Does it works in Windows Phone 8?

    because I call FFT() in WinPRT, the assert() makes my app terminated.

  2. XDSP.h compiles fine for Windows Store apps on x86, x64, and ARM as well as Win32 desktop x86 / x64. It should therefore work fine for Windows phone 8 as well as DirectXMath is supported on all of these platforms.

    I suspect the problem is you aren't respecting the alignment requirement of the memory buffer (XMVECTOR requires 16-byte aligned memory). On x86 and ARM, the default malloc or new is only 4-byte aligned. It is 16-byte aligned by default only on x64 native. You need to use __aligned_malloc( size, 16 ) to ensure the memory buffer you allocate is 16-byte aligned.

    I recommend you take the time to read through the DirectXMath Programmer's Guide. It's not long, and gives you a lot of useful information for working with SIMD math.

  3. Hi Chunk, thanks for your quick reply.

    Actually, I'm porting  Windows Store app sample on MSDN Code Gallery as you said to Windows Phone 8.(code.msdn.microsoft.com/…/Audio-player-with-real-c4413a30), It works on Win8(x64).

    I'm sure it uses  __aligned_malloc( size, 16 ) in FFTSampleAggregator::FFTSampleAggregator()  of FFTSampleAggregator.cpp

    Then it call XDSP::FFTInterleaved(), in FFTInterleaved(), it call FFT(). In FFT(), it gets error in assert((uintptr_t)pImaginary % 16 == 0);

    Could you help to check it? or give me some hints.

    thank you.

  4. Hi Chunk, I also use Windows Store app sample on MSDN Code Gallery.(code.msdn.microsoft.com/…/Audio-player-with-real-c4413a30) on Windows RT, it also has same situation.

    screen shot as below.


Skip to main content