Jigberto
Jigberto

Reputation: 1533

Select recording device in C++ (Windows)

How to select recording device in C++ , Windows. I want to record sound from PC, and I want a function in C++ which can select device: Line, Microphone or Stereo Mix. I dont know how to do that. Please show me example or give me links to learn this.

I found something related in C++, but it not working good: http://forums.codeguru.com/showthread.php?t=449213

Please help.

Upvotes: 0

Views: 3750

Answers (1)

Ashwin
Ashwin

Reputation: 1960

What you can try is by calling the waveInGetNumDevs

The waveInGetNumDevs function returns the number of waveform-audio input devices present in the system.

UINT waveInGetNumDevs(VOID);

Returns the number of devices. A return value of zero means that no devices are present or that an error occurred.

Here is an example:

#include <tchar.h>
#include <windows.h>
#include "mmsystem.h"

#pragma comment(lib, "winmm.lib")

int _tmain( int argc, wchar_t *argv[] )
{
    UINT deviceCount = waveInGetNumDevs();

    if ( deviceCount > 0 )
    {
        for ( int i = 0; i < deviceCount; i++ )
        {
            WAVEINCAPSW waveInCaps;    
            waveInGetDevCapsW( i, &waveInCaps, sizeof( WAVEINCAPS ) );

            //Your code here
        }
    }

    return 0;
}

Upvotes: 2

Related Questions