来自麦克风的声音与来自扬声器的声音 [英] Sound from mic vs sound from speaker

查看:29
本文介绍了来自麦克风的声音与来自扬声器的声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想分别从麦克风和扬声器中捕获音频.我如何区分它们?我可以使用 Wave API 捕获其中一个,例如 WaveInOpen().

I want to capture audio from both the mic and the speaker - separately. How can I distinguish between them? I can capture one or the other using the Wave API, e.g., WaveInOpen().

当我使用 waveInGetNumDevs() 和 waveInGetDevCaps()/waveoutGetDevCaps() 枚举设备时,似乎没有与特定端点设备(例如麦克风或扬声器)相关的信息.我只看到以下是适配器设备:

When I enumerate the devices using waveInGetNumDevs() and waveInGetDevCaps()/waveoutGetDevCaps(), there seems to be no information related to a particular end-point device (e.g., mic or speaker). I only see the following, which are adapter devices:

高清读取音频输入
高清读取音频输出
网络摄像头...

HD Read Audio Input
HD Read Audio Output
Webcam ...

推荐答案

我实际上对 Windows API 一无所知,所以我的答案可能不是最好的,也许还有更好的方法.

I've actually no knowledge of the windows API so my answer isn't probably the best and there maybe even better ways.

    HRESULT hr = CoInitialize(NULL);
    IMMDeviceEnumerator *pEnum = NULL;
    hr = CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&pEnum);
    if(SUCCEEDED(hr))
    {
      IMMDeviceCollection *pDevices;
      // Enumerate the output devices.
      hr = pEnum->EnumAudioEndpoints(eAll, DEVICE_STATE_ACTIVE, &pDevices);
      // You can choose between eAll, eCapture or eRender
    }

这样您就可以区分输入(捕获)和输出(渲染).(这就是你想要的吧?)

With that you'd be able to distinguish between input (capture) and output (render). (That's what you wanted right?)

代码取自 这篇文章.您可以查看它以获取正确的 API 调用和库,它甚至可能为您提供更多信息.

The code is taken from this article. You may look at it for the correct API calls and libraries, it even might give you some more information.

希望对您有所帮助.

这篇关于来自麦克风的声音与来自扬声器的声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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