Skip to content

Legacy XAudio 2.7 Notes

Chuck Walbourn edited this page Apr 26, 2022 · 6 revisions

The release for XAudio2Redist has removed the need to use the legacy DirectX SDK, so May 2020 was the last release to support the option for using the legacy DirectX SDK's XAudio 2.7.

XAudio 2.7 supports Windows 7 and older operating systems. It is deployed by the legacy DirectX End User Runtime package and requires the legacy DirectX SDK (June 2010) to develop with. Due to some technical issues, it must be installed to the 'default' location of C:\Program Files (x86)\Microsoft DirectX SDK (June 2010). To install the legacy DirectX SDK on your development system, see this post and be sure to read this article for a known issue with the installer.

Legacy DirectX SDK

DirectXTK makes use of the latest Direct3D 11.1 headers available in the Windows 8.x / 10 SDK, and there are a number of file conflicts between the Windows 8.x / 10 SDK and the legacy DirectX SDK. Therefore, when building for down-level support with XAudio 2.7, Audio.h explicitly includes the DirectX SDK version of XAudio2 headers with a full path name. These reflect the default install locations, and if you have installed it elsewhere you will need to update this header. The *_DXSDK.vcxproj files use the DXSDK_DIR environment variable, so only the Audio.h references need updating for an alternative location.

// Using XAudio 2.7 requires the DirectX SDK
#include <C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include\comdecl.h>
#include <C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include\xaudio2.h>
#include <C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include\xaudio2fx.h>
#pragma warning(push)
#pragma warning( disable : 4005 )
#include <C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include\x3daudio.h>

KB2728613

Where is the DirectX SDK?

When using the legacy DirectX SDK you need to set up VC++ Directories paths in your project (particularly your EXE/DLL). For the Windows 8.1 SDK or Windows 10 SDK, you need to set up those paths in reverse order from previous include orders. You really only need a small portion of the legacy DirectX SDK for XAudio 2.7, and want to be using the Windows 8.1 SDK / Windows 10 SDK for everything else. For more details see The Zombie DirectX SDK.

XAudio 2.7

To use XAudio 2.7, you u se one of the Win32 desktop DirectX Tool Kit configurations for graphics, input, and math then add the DirectX Tool Kit for Audio project:

DirectXTKAudio_Desktop_2017_DXSDK When targeting Windows 7 with the legacy DirectX SDK, use DirectXTKAudioDX.lib which is implemented using XAudio 2.7. Use of the legacy DirectX SDK is not recommended, and requires use the DirectSetup to deploy the XAudio 2.7 DLL to end-user machines.
  1. Right-click on your solution in the Solution Explorer, and select Add / Existing Project...
  2. Browse into the "DirectXTK\Audio" folder and select DirectXTKAudio_Desktop_201x_DXSDK.vcxproj, click "Open"
  3. If Visual Studio presents a "Security Warning", select "OK". Optional: Uncheck "Ask me for every project in this solution" first.
  4. Right-click on your project in the Solution Explorer, and select Add / References...
  5. Check DirectXTKAudio_Desktop_201x_DXSDK.vcxproj and select "OK"
  6. Select "OK"

Add Reference (DirectX SDK)

This option is not recommended, but is included for completeness. Xaudio 2.7 has a number of known bugs.

Adding the headers

If you are using XAudio 2.7 for Windows 7 compatibility (_WIN32_WINNT set to 0x0601), we also need to add the legacy DirectX SDK include and library paths to your project. First go to Project / Properties and select "VC++ Directories" on the left. Then set Configuration to "All Configurations" and Platform to "x86". Add to the end of these paths:

  • Include Directories: ;$(DXSDK_DIR)Include
  • Library Directories: ;$(DXSDK_DIR)Lib\x86

Click "Apply".

VC++ Directories (x86)

Then set Configuration to "All Configurations" and Platform to "x64". Add to the end of these paths:

  • Include Directories: ;$(DXSDK_DIR)Include
  • Library Directories: ;$(DXSDK_DIR)Lib\x64

Click "Apply".

VC++ Directories (x64)

It is important that the legacy DirectX SDK paths be after the existing path since are making use of the Windows 8.1 / 10 SDK. See Where is the DirectX SDK? for more details.

Click here for troubleshooting advice

If you get a compilation error indicating you are missing "comdecl.h", there are two possible reasons:

  • You have incorrectly configured your VC++ Directory include paths. If you get a link error indicating you are missing x3daudio.lib, then you incorrectly configured your VC++ Directory library paths.
  • You have incorrectly configured the ``_WIN32_WINNT`` variable. See Using the Windows Headers

Deployment

If you are using XAudio 2.7, then your application has a dependency on the DirectX End-User Runtime. See Not So DirectSetup for information on using this package. Again, this is not recommended for use.

Debugging

When using the debug version of XAudio 2.7 on Windows 7, you can get a break-point exception thrown even with a valid device. The debug output window message will be the following. You can safely ignore this and click "Continue".

################################################################################
### XAUDIO2: enginerendererconnection.cpp:334:
### ASSERT FAILED: FramesToLeapTime(uOutputBufferFramesObtained, m_pOutputFormat, RoundUp) >= rtRequestedBufferDuration
################################################################################

See Adding the DirectX Tool Kit for Audio

For Use

  • Universal Windows Platform apps
  • Windows desktop apps
  • Windows 11
  • Windows 10
  • Windows 8.1
  • Xbox One

Architecture

  • x86
  • x64
  • ARM64

For Development

  • Visual Studio 2022
  • Visual Studio 2019 (16.11)
  • clang/LLVM v12 - v18
  • MinGW 12.2, 13.2
  • CMake 3.20

Related Projects

DirectX Tool Kit for DirectX 12

DirectXMesh

DirectXTex

DirectXMath

Win2D

Tools

Test Suite

Model Viewer

Content Exporter

DxCapsViewer

Clone this wiki locally