How to control the Microphone Boost in Windows 7?

孤街醉人 提交于 2019-12-13 16:42:11

问题


I am trying to control the Microphone Boost (level/(un)mute) in Windows 7 using the MIXER API in a C/C++ application, but I do not get the controls for the same. Can it be done using WASAPI? Can somebody suggest any other API to control the Microphone Boost in Windows 7?

This is what I have written so far ...

const IID IID_IDeviceTopology = __uuidof(IDeviceTopology);
const IID IID_IPart = __uuidof(IPart);
const IID IID_IAudioAutoGainControl = __uuidof(IAudioAutoGainControl);

HRESULT hr = S_OK;
CoInitialize(NULL);

IMMDeviceEnumerator *deviceEnumerator = NULL;
hr = CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_INPROC_SERVER, __uuidof(IMMDeviceEnumerator), (LPVOID *)&deviceEnumerator);

IMMDevice *pEndptDev = NULL;

hr = deviceEnumerator->GetDefaultAudioEndpoint(eCapture, eConsole, &pEndptDev);
deviceEnumerator->Release();
deviceEnumerator = NULL;


IDeviceTopology *pDevTopoEndpt = NULL;
IConnector *pConnEndpt = NULL;
IConnector *pConnHWDev = NULL;
IPart *pPartConn = NULL;
IAudioAutoGainControl *pAGC = NULL;
IControlInterface *pControl = NULL;
UINT pCount = 0;
LPCGUID pIID = ;

// Get the endpoint device's IDeviceTopology interface.
hr = pEndptDev->Activate(IID_IDeviceTopology, CLSCTX_ALL, NULL, (void**)&pDevTopoEndpt);

// The device topology for an endpoint device always
// contains just one connector (connector number 0).
hr = pDevTopoEndpt->GetConnector(0, &pConnEndpt);

// Use the connector in the endpoint device to get the
// connector in the adapter device.
hr = pConnEndpt->GetConnectedTo(&pConnHWDev);

// Query the connector in the adapter device for
// its IPart interface.
hr = pConnHWDev->QueryInterface(IID_IPart, (void**)&pPartConn);

// Use the connector's IPart interface to get the
// IDeviceTopology interface for the adapter device.
hr = pPartConn->Activate(CLSCTX_ALL, IID_IAudioAutoGainControl, (void**)&pAGC);
hr = pPartConn->GetControlInterfaceCount(&pCount);
hr = pPartConn->GetControlInterface(pCount - 1, &pControl);
hr = pControl->GetIID((GUID *)pIID);

//BOOL bEnabled = false;
hr = pAGC->SetEnabled(true, pIID);

回答1:


WASAPI is the way to do this.

http://msdn.microsoft.com/en-us/library/windows/desktop/dd316531%28v=vs.85%29.aspx

http://msdn.microsoft.com/en-us/library/windows/desktop/dd370853%28v=vs.85%29.aspx



来源:https://stackoverflow.com/questions/8905599/how-to-control-the-microphone-boost-in-windows-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!