• Create Account

## What do you use for Audio in DirectX applications?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

14 replies to this topic

### #1mrheisenberg  Members

Posted 07 September 2012 - 11:07 AM

This concerns mainly a problem I found with the new windows SDK that includes DirectX headers.Even with this + Visual Studio 2012,it still gives me the ''The program can't start because XAudio2_8.dll is missing from your computer.Try reinstalling the program to fix the problem.'' error.Would it be better to just use DirectSound instead of XAudio2?Is XAudio2 really worth the trouble?

### #2bschmidt1962  Members

Posted 07 September 2012 - 04:24 PM

POPULAR

That probably depends on your audio needs.

XAudio 2 was designed to address some of the limitations of the original DirectSound API, which was designed back in the mid 1990's when ISA soundcards with on-board audio RAM were all the rage and a cutting edge PC was a 66MHz Pentium I. XAudio 2 was designed with a software implementation in mind.
If all you need to do is play back a few sound effects, and you know DirectSound, then it'll probably work just fine.
XAudio 2 does support several useful features that DSound doesn't, though.
Native run-time decompression (ADPCM and wma), digital signal processing (for reverbs, filtering or arbitrary audio processing), submixing, audio graphbuilding and a more transparent 3D implementation. If you think you may want to use those at some point, it's probably worth learning and using XAudio 2. (the compressed sound support alone may be worth the switch).

Big Disclaimer-- I was the primary architect for XAudio 2 back when I was at Microsoft, so may be biased .

There are of course other 3rd party audio API's out there such as FMOD, WWise, Miles, etc, that may be worth looking at.

Brian Schmidt
Final 3 weeks for Earlybird Discount
GameSoundCon 2012, San Francisco.
Oct 24-25

Brian Schmidt

Executive Director, GameSoundCon:

GameSoundCon 2016:September  27-28, Los Angeles, CA

Founder, Brian Schmidt Studios, LLC

Music Composition & Sound Design

Audio Technology Consultant

### #3mrheisenberg  Members

Posted 07 September 2012 - 05:29 PM

That probably depends on your audio needs.

XAudio 2 was designed to address some of the limitations of the original DirectSound API, which was designed back in the mid 1990's when ISA soundcards with on-board audio RAM were all the rage and a cutting edge PC was a 66MHz Pentium I. XAudio 2 was designed with a software implementation in mind.
If all you need to do is play back a few sound effects, and you know DirectSound, then it'll probably work just fine.
XAudio 2 does support several useful features that DSound doesn't, though.
Native run-time decompression (ADPCM and wma), digital signal processing (for reverbs, filtering or arbitrary audio processing), submixing, audio graphbuilding and a more transparent 3D implementation. If you think you may want to use those at some point, it's probably worth learning and using XAudio 2. (the compressed sound support alone may be worth the switch).

Big Disclaimer-- I was the primary architect for XAudio 2 back when I was at Microsoft, so may be biased .

There are of course other 3rd party audio API's out there such as FMOD, WWise, Miles, etc, that may be worth looking at.

Brian Schmidt
Final 3 weeks for Earlybird Discount
GameSoundCon 2012, San Francisco.
Oct 24-25

XAudio2 is perfect,however it just doesn't run,it wants some XAudio2_8.dll.I don't understant WHY it wants the DLL,when it's obviously a Windows 8 dll that hasn't even come out yet,why does my code in Windows7 in a normal DirectX11 application require me to have a DLL that is in Windows 8,how do I get that DLL?No one seems to have info on the issue of missing XAudio2_8.dll.I can't even call it missing,since it's not even supposed to be there,Windows 7 has XAudio2_7.dll.Why my program requires a dll that it shouldn't even know about is beyond me.

### #4MJP  Moderators

Posted 07 September 2012 - 06:36 PM

It requires you to have that DLL because you're linking against it. Unless MS decides to package it up in a redistributable or install it via service pack, I don't think you can use it on Windows 7.

### #5mrheisenberg  Members

Posted 07 September 2012 - 06:49 PM

I'm only including this:

#include <xaudio2.h>
#include <x3daudio.h>
#include <xaudio2fx.h>

#pragma comment (lib, "xaudio2.lib")
#pragma comment (lib, "x3daudio.lib")

It worked fine before with just

#include <xaudio2.h>
#pragma comment (lib, "xaudio2.lib")

However I don't understand why implementing 3D audio causes the problem.I mean the same headers and libraries are included in the SDK 3D Audio sample and I can run it fine,however when I use these functions in my project,the missing DLL thing comes up.Now I've checked project options carefuly at both my project and the SDK sample one,all the settings are the same,I checked all their code,there is no reference in the source for such a dll,so perhaps it's called for in the libs?But how can that be if those libs were made over 2 years ago while this dll that it wants is from Windows 8

### #6kunos  Members

Posted 08 September 2012 - 12:48 AM

to use the old (v7) version of XAudio2 you should install the DirectX 2010 SDK and make sure your project is pointing at it for headers and lib files. I haven't moved to VS 2012 yet (waiting for the official release next week) but reading around this seems to be the way to go to support Win7.

### #7mrheisenberg  Members

Posted 08 September 2012 - 07:44 AM

to use the old (v7) version of XAudio2 you should install the DirectX 2010 SDK and make sure your project is pointing at it for headers and lib files. I haven't moved to VS 2012 yet (waiting for the official release next week) but reading around this seems to be the way to go to support Win7.

Ok I found something weird:In the DirectX 2010 SDK(atleast in mine,which I reainstalled 3 times) there is no XAudio2.lib and in the sample XAudio2 projects from the SDK,no XAudio2.lib is linked.However,there is XAudio2.lib in the new Windows 8 SDK,so I figured I should just not be linking it.But when I unlink it,it gives me

Unhandled exception at 0x5019DEF0 (msvcr110d.dll) in Engine.exe: 0xC0000005: Access violation writing location 0x0F7B0460.

Posted 08 September 2012 - 12:43 PM

You can use something like this:
#if (_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/)
#include <xaudio2.h> // from Windows 8.0 SDK
#pragma comment(lib,"xaudio2.lib")
#else
#include <c:\dxsdk\include\xaudio2.h> // from DirectX SDK
#endif


Edited by nader, 08 September 2012 - 12:46 PM.

### #9MJP  Moderators

Posted 08 September 2012 - 02:25 PM

I'm only including this:

#include <xaudio2.h>
#include <x3daudio.h>
#include <xaudio2fx.h>

#pragma comment (lib, "xaudio2.lib")
#pragma comment (lib, "x3daudio.lib")

It worked fine before with just

#include <xaudio2.h>
#pragma comment (lib, "xaudio2.lib")

However I don't understand why implementing 3D audio causes the problem.I mean the same headers and libraries are included in the SDK 3D Audio sample and I can run it fine,however when I use these functions in my project,the missing DLL thing comes up.Now I've checked project options carefuly at both my project and the SDK sample one,all the settings are the same,I checked all their code,there is no reference in the source for such a dll,so perhaps it's called for in the libs?But how can that be if those libs were made over 2 years ago while this dll that it wants is from Windows 8

Those libraries you're linking to are import libraries. Basically they're just stubs that allow to linker to hook up your code's function calls to the functions exported by the DLL, instead of having to manually ask for the address of the DLL function at runtime. When you link to a DLL's import lib your app now has a dependency on that DLL, which means it will attempt to load that DLL when the app starts up. If it can't find the right DLL, you get that error.

### #10mrheisenberg  Members

Posted 11 September 2012 - 05:00 PM

You can use something like this:

#if (_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/)
#include <xaudio2.h> // from Windows 8.0 SDK
#pragma comment(lib,"xaudio2.lib")
#else
#include <c:\dxsdk\include\xaudio2.h> // from DirectX SDK
#endif


I did all this and this time it actualy loads XAudio2_7.dll properly(I see it quickly in the orange bar at the bottom after build time),but it gives me a Unhandled exception at 0x52FEDEF0 (msvcr110d.dll) in Engine.exe: 0xC0000005: Access violation writing location 0x0F7E0460. with no source code avaliable.Is there anything else special that I must install/import?

### #11kubera  Members

Posted 12 September 2012 - 10:39 AM

It would be not enough. DXAudio 2.7 API is a bit different. You should develop separate codes for both and link your executable against different libraries, depending on a destination host.
(or you could create one complex audio support)
Please consider using only 2.7 API and deploying it with your application. Two separate libraries and their API headers should be used separetely.

### #12mrheisenberg  Members

Posted 14 September 2012 - 06:39 PM

Please consider using only 2.7 API and deploying it with your application.

well that's just the thing o_O I want to use only 2.7,the only problem was that it required the 2.8dll even when I directly copied the code from the 2010 SDK(and in visual studio 2010).

Edited by mrheisenberg, 14 September 2012 - 10:27 PM.

### #13papulko  Members

Posted 18 September 2012 - 04:34 AM

Hey did you manage to solve it? I've got the exact same problem, xaudio2.lib just isn't in there ( june 2010 directx sdk )

### #14zdd  Members

Posted 14 October 2012 - 04:25 AM

I answered a same question from stack overflow. just for your reference

The basic rule is, if you develop XAudio2 program on Win 8, use the Windows SDK, otherwise, use DirectX SDK.
If you are working on Win7, make sure
• the head file XAudio2.h you are using comes from the DirectX SDK, that's something like C:\Program Files\Microsoft DirectX SDK (June 2010)\Include\XAudio2.h, not come from the Win8 SDK, something like C:\Program Files\Windows Kits\8.0\Include\um\XAudio2.h(in case you installed the Win8 SDK)
• Call CoInitializeEx(NULL, COINIT_MULTITHREADED); before calling XAudio2Create, since the old version(before 2.8) of XAaudio2 was created by COM, so it does not need a .lib file, and there is no .lib file for XAudio2 before Win8.
This page below contains a detail introduction of the version of XAudio2, you can take a look.
XAudio2 Versions

Edited by zdd, 14 October 2012 - 04:26 AM.

### #15kubera  Members

Posted 14 October 2012 - 07:26 AM