• Advertisement
Sign in to follow this  

What do you use for Audio in DirectX applications?

This topic is 1928 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement

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 smile.png.

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. blink.png

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.[/quote]

Share this post


Link to post
Share on other sites
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

for more information read this. Edited by nader

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

for more information read this.


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?

Share this post


Link to post
Share on other sites
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.

Helpful things:

  • Delay Load DLLs
  • LoadLibrary, etc.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement