0

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().

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 ...

user732592
  • 247
  • 1
  • 7
  • 3
    Wouldn't you expect that an audio *input* device is a microphone and an *output* device is a speaker? – Cody Gray - on strike Dec 17 '11 at 14:24
  • nah, he probably meant mixer as speaker – Ulterior Dec 17 '11 at 19:00
  • I mean, the audio outputted by media players. Using EXACTLY the same app, I can capture the mic input and the audio emitted by media players. The problem is that none of the functions that I use seems to indicate the source of the audio. Of course, I know whether it's the mic or the media player, but not my app. – user732592 Dec 18 '11 at 14:24

1 Answers1

0

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

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.

Hope that's helpfull.

Lukas
  • 2,461
  • 2
  • 19
  • 32