Click here to Skip to main content
15,884,032 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
hello;
im working on an c++ audio application and i want to be able to enumerate all availlable sound cards and choose one of them to play my generated sound
any help? thanks
Posted
Updated 24-May-11 22:23pm
v2
Comments
Sandeep Mewara 25-May-11 4:51am    
Good to know. Any effort from your side?
Joan M 25-May-11 4:58am    
Youuuuu bad boy! :-D Only if we could vote the comments...
[no name] 25-May-11 5:28am    
It seems to me, that you can use direct sound form DirectX.

You can use (as pointed out by Kozlow_Sergey in the comments) DirectX to enumerate the devices;

C++
#include <iostream>
#include <stdio.h>
#include <dsound.h>

using namespace std;

#ifdef UNICODE
BOOL CALLBACK DirectSoundEnum(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVOID context)
{
    wcout << "Device: " << desc << endl;
    return TRUE;
}
#else
BOOL CALLBACK DirectSoundEnum(LPGUID guid, LPCSTR desc, LPCSTR module, LPVOID context)
{
    cout << "Device: " << desc << endl;
    return TRUE;
}
#endif

int main(int argc, char* argv[])
{
    if (DirectSoundEnumerate(DirectSoundEnum, NULL) != DS_OK)
        cerr << "Failed to enumerate sound devices";

    return 0;
}





This snippet requires that you link against d3dx9.lib and dsound.lib (actually you might be able to skip the first one).

Hope this helps,
Fredrik Bornander
 
Share this answer
 
v2
Comments
kinani 27-May-11 10:07am    
thanks i tried this but i have 2 errors
DS_OK not declared and DirectSoundEnumerateA not found
any idea again ?
Fredrik Bornander 27-May-11 10:19am    
What version of the DirectX SDK do you have?
Are you building x86 or x64 application?
kinani 27-May-11 10:32am    
the version is DirectX 9.0 SDK (April 2005) and i don't know if i have x86 or x64 !
do you have any idea ?thanks
Fredrik Bornander 27-May-11 10:45am    
Can you open the dsound.h file?
kinani 27-May-11 10:55am    
yes i can open it i have added mmsystem.h before dsound.h if not i had many errors in dsound.h .
If you can't use Direct Sound you can use this link
http://msdn.microsoft.com/en-us/library/dd370840%28v=VS.85%29.aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900