从麦克风声音从VS扬声器的声音 [英] Sound from mic vs sound from speaker

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

问题描述

我想从麦克风和扬声器都捕获音频 - 分开。我该如何区分它们?我可以一个或其他使用波的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读取音频输入结果
高清读取音频输出结果
网络摄像头...

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?)

在code从<一所href=\"http://www.daveamenta.com/2011-05/programmatically-or-command-line-change-the-default-sound-playback-device-in-windows-7/\"相对=nofollow>这篇文章。你可以看看它正确的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.

希望这是有帮助的。

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

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