枚举声卡 [英] enumerate sound cards

查看:201
本文介绍了枚举声卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好;
我在C ++音频应用程序上工作,我希望能够枚举所有可用的声卡并选择其中一个来播放我生成的声音
有什么帮助吗? Thanks

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

推荐答案

您可以使用DirectX枚举设备(正如Kozlow_Sergey在评论中指出的那样);

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

#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;
}






此摘要要求您链接到 d3dx9.lib dsound.lib (实际上,您可以跳过第一个).

希望这会有所帮助,
弗雷德里克·博纳德(Fredrik Bornander)






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


如果您不能使用Direct Sound,则可以使用此链接
http://msdn.microsoft.com/en-us/library/dd370840%28v = VS.85%29.aspx [ ^ ]
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[^]


这篇关于枚举声卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆