Direct Sound

Started by
3 comments, last by RoyChen204 15 years, 9 months ago
I seem to be unable to use DirectSound in my projects. I added dmusici.h, dmusicc.h and d3d8types.h, but when I did this IDirectMusicLoader8 *Loader; and changed it to NULL at starting, following the book on Opengl Game Programming, and linked dxguid.lib ,dsound.lib ,dxerr8.lib. However it seems to fail to create the loader object, cause each time it hits the test it fails. The test is if (FAILED(CoCreateInstance(CLSID_DirectMusicLoader, NULL, CLSCTX_INPROC, IID_IDirectMusicLoader8, (void**)&Loader))) Could someone help me please?
Advertisement
What error code do you get? If you print out the return value as an 8-digit hex number, it should look like 0x88760001 or something.

Also, I'm not sure, the Debug Runtimes might help (Ignore the D3D specific stuff in that link).

Also, it may be worth mentioning that DirectMusic isn't recommended any more, I believe XAudio or XACT is preferable (Although I can't recall which) for music, or plain DirectSound for low level audio stuff.

EDIT: Have you called CoInitialize before calling CoCreateInstance?
In addition to Steves point on debug, I started using the DirectSound Debug runtime yesterday, and found the control panel is only half the answer. (It'll do nothing if you just drag that slider to max).

You need to download the DXSDK extras which will include a debug version of dsound.dll. Stick that in your run directory and you'll start seeing the debug output.
---When I'm in command, every mission's a suicide mission!
have you called CoInitialize() ?
okay, thanks, it works now! thanks to those who answered/replied !

This topic is closed to new replies.

Advertisement