3D and Surround Sound
3D and surround sound in XAudio2 is perhaps the biggest
departure from DirectSound’s model. In DirectSound, DirectSound3D buffers and
the DirectSound3DListener were used to take a sound emitter’s x, y,
z position in 3D space and cause the
sound to seem to come from the appropriate location. In XAudio2, there is no
inherent notion of 3D—there is nothing analogous to a DirectSound3D buffer.
Instead, an application specifies individual volume levels for each speaker,
typically 5.1 or 7.1. A game can put a sound only in a specific speaker (for
example, the center channel for dialogue), or it can calculate the appropriate
volume level for each speaker given the x,
y, z positions of sound source and camera.
To make this easy, a
complementary API, X3DAudio, is used. X3DAudio converts simple
game geometry data into signal processing parameters suitable for passing to
XAudio2. It takes x, y, z
coordinates for sound sources and listeners, and outputs a vector of speaker
volumes for each output speaker.
X3DAudio has only two functions, X3DAudioInitialize and X3DAudioCalculate.
X3DAudio allows for multiple sound sources, multiple listeners, cones, and a
flexible mapping model. X3DAudio also returns the results of some of its own
internal calculations, such as source-to-listener distance, internal data from
Doppler calculations and other information valuable to the game engine itself.
By separating the signal processing library, XAudio2, from
the geometry library, X3DAudio, 3D audio becomes much more flexible and
transparent. The following figure shows how X3DAudio and XAudio2 are used
together by the game engine to create 3D/Surround sound.
The Audio Stack: Top to Bottom
On Xbox 360, XAudio2 sits on top of the XMA hardware decoder
and the audio output system of Xbox 360. On Windows Vista, XAudio2 streams
directly into the lowest audio API, WASAPI, while on Windows XP, it streams its
output to a single DirectSound buffer. For games that use XACT3, XAudio2 is the
audio signal processing engine that runs underneath the high-level XACT 3
library.
XAudio2 in Other APIs
As a low-level audio engine, XAudio2 is under the hood in
several other APIs. XAudio2 is the low-level engine driving XACT3. For Windows
developers, this is transparent. Xbox 360 developers will notice a change in
the way that audio DSP effects are used, which requires some code changes to
reflect the new xAPO model.
On Xbox 360, the XHV and XMV APIs now have XAudio2
counterparts: XHV2 and XMV2. These are versions of the Xbox 360 voice and
full-motion video player libraries that use XAudio2 under the hood.
When Will XAudio2 Be Available?
XAudio2 is available today as part of the November Xbox 360
XDK and DirectX SDK. If you haven’t taken a look, now’s a great time to do so.
The first approved version for Xbox 360 and release version for Windows will be
available in the March 2008 XDK/SDK, with updates and enhancements following in
June.
The audio team at XNA is tremendously excited about XAudio2 for both Xbox 360 and Windows. It
completes a major piece of our cross-platform initiative for audio technologies
that we’ve had in the making for some time, and it provides a strong foundation
for game audio well into the future.
|