Skip to content

XAudio2

Chuck Walbourn edited this page Nov 20, 2024 · 8 revisions

This is a collection of the DirectX SDK's original XAudio2 samples updated to use modern Visual Studio and the Windows SDK without any dependencies on legacy DirectX SDK content.

The XAudio2Samples_201x_Win10 projects build using XAudio 2.9 which requires Windows 10 or Windows 11. The XAudio2Samples_NuGetRedist_201xK projects build using XAudio 2.9 via the XAudio2Redist and supports Windows 7 SP1, Windows 8.0, Windows 8.1, or Windows 10.

XAudio2BasicSound (UPDATED)

This sample demonstrates the XAudio2 API by showing you how to initialize the XAudio2 engine, create a mastering voice, and play sample files.

XAudio2AsyncStream (UPDATED)

This sample shows you how to play streaming audio using asynchronous file I/O and the XAudio2 API.

Note: Originally called "XAudio2BasicStream" in the legacy DirectX SDK.

XAudio2Sound3D (UPDATED)

This sample shows you how to use the X3DAudio API with XAudio2 for playing spatialized audio.

XAudio2CustomAPO (UPDATED)

This sample shows you how to create and use custom APOs with XAudio2.

XAudio2Enumerate (NEW)

This sample shows how to enumerate audio devices and initialize an XAudio2 mastering voice for a specific device.

XAudio2MFStream (NEW)

This samples uses Media Foundation to decode a media audio file (which could be compressed with any number of codecs) and streams it through an XAudio2 voice. This technique is most useful for XAudio 2.8 on Windows 8.x which only supports PCM and ADPCM, and not more aggressive lossy compressed schemes which are supported by Media Foundation.

XAudio2WaveBank (NEW)

This sample shows how to play in-memory audio using an XACT-style wave bank.

Additional Content

  • WAVFileReader.h/.cpp module which can be used to load a .WAV file for playback with XAudio2. It optionally returns loop-point information as well as supporting the standard PCM, MS-ADPCM, and WAVEFORMATEXTENSIBLE formats supported by XAudio2.
  • WaveBankReader.h/.cpp module which is used by the XAudio2AsyncStream and XAudio2WaveBank samples. It is used to parse XACT3-style wave banks.
  • The XBWTool command-line tool is a simple way to build XACT-style wave banks without using the legacy DirectX SDK's XACT tool or XACTBLD command-line tool. It can be used to build .xwb files suitable for both the XAudio2AsyncStream or XAudio2WaveBank samples, and are binary compatible with the XACT3 DirectX SDK (June 2010) wave bank format. This tool cannot generate XACT sound banks.

These are from the DirectX Tool Kit for Audio. For more information, see here and here.

For Use

  • Windows desktop apps
  • Windows 11
  • Windows 10
  • Windows 8.1
  • Windows 7 Service Pack 1

For Development

  • Visual Studio 2019

Related Projects

DirectX Tool Kit

DirectXTex

Effects 11

DXUT11

Content Exporter

DirectX Tool Kit Samples

Clone this wiki locally