How to check if there is a microphone and speaker from the same sound card?

My question is how to check if there is a microphone and speaker from a single sound card on a Windows platform. If they are made from different cards, the logic of processing time will be different. I use both DSound and WMME API.

+6
c ++ windows audio multimedia
source share
3 answers

WMI provides some information about sound cards. What I still could not find out is that it gives enough. Using the WMI Code Creator , the "script lists everything Win32_SoundDevice stores objects:

strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colItems = objWMIService.ExecQuery( _ "SELECT * FROM Win32_SoundDevice",,48) For Each objItem in colItems Wscript.Echo "-----------------------------------" Wscript.Echo "Win32_SoundDevice instance" Wscript.Echo "-----------------------------------" Wscript.Echo "Availability: " & objItem.Availability Wscript.Echo "Caption: " & objItem.Caption Wscript.Echo "ConfigManagerErrorCode: " & objItem.ConfigManagerErrorCode Wscript.Echo "ConfigManagerUserConfig: " & objItem.ConfigManagerUserConfig Wscript.Echo "CreationClassName: " & objItem.CreationClassName Wscript.Echo "Description: " & objItem.Description Wscript.Echo "DeviceID: " & objItem.DeviceID Wscript.Echo "DMABufferSize: " & objItem.DMABufferSize Wscript.Echo "ErrorCleared: " & objItem.ErrorCleared Wscript.Echo "ErrorDescription: " & objItem.ErrorDescription Wscript.Echo "InstallDate: " & objItem.InstallDate Wscript.Echo "LastErrorCode: " & objItem.LastErrorCode Wscript.Echo "Manufacturer: " & objItem.Manufacturer Wscript.Echo "MPU401Address: " & objItem.MPU401Address Wscript.Echo "Name: " & objItem.Name Wscript.Echo "PNPDeviceID: " & objItem.PNPDeviceID If isNull(objItem.PowerManagementCapabilities) Then Wscript.Echo "PowerManagementCapabilities: " Else Wscript.Echo "PowerManagementCapabilities: " & Join(objItem.PowerManagementCapabilities, ",") End If Wscript.Echo "PowerManagementSupported: " & objItem.PowerManagementSupported Wscript.Echo "ProductName: " & objItem.ProductName Wscript.Echo "Status: " & objItem.Status Wscript.Echo "StatusInfo: " & objItem.StatusInfo Wscript.Echo "SystemCreationClassName: " & objItem.SystemCreationClassName Wscript.Echo "SystemName: " & objItem.SystemName Next 

Running this on my laptop gives

 ----------------------------------- Win32_SoundDevice instance ----------------------------------- Availability: Caption: ATI Function Driver for High Definition Audio - ATI AA01 ConfigManagerErrorCode: 0 ConfigManagerUserConfig: False CreationClassName: Win32_SoundDevice Description: ATI Function Driver for High Definition Audio - ATI AA01 DeviceID: HDAUDIO\FUNC_01&VEN_1002&DEV_AA01&SUBSYS_00AA0100&REV_1000\5&BB7E0F3&0&0001 DMABufferSize: ErrorCleared: ErrorDescription: InstallDate: LastErrorCode: Manufacturer: ATI MPU401Address: Name: ATI Function Driver for High Definition Audio - ATI AA01 PNPDeviceID: HDAUDIO\FUNC_01&VEN_1002&DEV_AA01&SUBSYS_00AA0100&REV_1000\5&BB7E0F3&0&0001 PowerManagementCapabilities: PowerManagementSupported: False ProductName: ATI Function Driver for High Definition Audio - ATI AA01 Status: OK StatusInfo: 3 SystemCreationClassName: Win32_ComputerSystem SystemName: BABEL ----------------------------------- Win32_SoundDevice instance ----------------------------------- Availability: Caption: Conexant High Definition SmartAudio 221 ConfigManagerErrorCode: 0 ConfigManagerUserConfig: False CreationClassName: Win32_SoundDevice Description: Conexant High Definition SmartAudio 221 DeviceID: HDAUDIO\FUNC_01&VEN_14F1&DEV_5051&SUBSYS_1179FF5B&REV_1000\4&2DBDAC14&0&0001 DMABufferSize: ErrorCleared: ErrorDescription: InstallDate: LastErrorCode: Manufacturer: Conexant MPU401Address: Name: Conexant High Definition SmartAudio 221 PNPDeviceID: HDAUDIO\FUNC_01&VEN_14F1&DEV_5051&SUBSYS_1179FF5B&REV_1000\4&2DBDAC14&0&0001 PowerManagementCapabilities: PowerManagementSupported: False ProductName: Conexant High Definition SmartAudio 221 Status: OK StatusInfo: 3 SystemCreationClassName: Win32_ComputerSystem SystemName: BABEL 

I don't know if anything will help with this. It's a difficult question.

+1
source share

Assuming you have an input and output device identifier, you can use something like the following to get the appropriate mixer identifiers. If they are both the same, they are both attached to the same mixer and most likely belong to the same physical equipment.

  /// <summary> /// Get the ID of the mixer associated with the given input device ID /// Returns -1 if no such mixer can be found /// </summary> static public int GetMixerIdInput(int inputId) { int mixerId = -1; int result = MmeMixerApi.mixerGetID(inputId, ref mixerId, MIXER_OBJECTFLAG.WAVEIN); if (((MMError)result != MMError.MMSYSERR_NOERROR) && ((MMError)result != MMError.MMSYSERR_NODRIVER)) { throw new MmeException((MMError)result); } return mixerId; } /// <summary> /// Get the ID of the mixer associated with the given output device ID /// Returns -1 if no such mixer can be found /// </summary> static public int GetMixerIdOutput(int outputId) { int mixerId = -1; int result = MmeMixerApi.mixerGetID(outputId, ref mixerId, MIXER_OBJECTFLAG.WAVEOUT); if (((MMError)result != MMError.MMSYSERR_NOERROR) && ((MMError)result != MMError.MMSYSERR_NODRIVER)) { throw new MmeException((MMError)result); } return mixerId; } 

If you only have a name for the input device, you can use something like the following to find the device ID:

  /// <summary> /// Find the ID of the input device given a name /// </summary> static public int GetWaveInputId(string name) { int id = MmeWaveApi.WAVE_MAPPER; int devCount = MmeWaveApi.waveInGetNumDevs(); WAVEINCAPS caps = new WAVEINCAPS(); for (int dev = 0; (dev < devCount) && (id == MmeWaveApi.WAVE_MAPPER); dev++) { int result = MmeWaveApi.waveInGetDevCaps(dev, ref caps, Marshal.SizeOf(caps)); if ((MMError)result == MMError.MMSYSERR_NOERROR) { if (string.Compare(name, 0, caps.szPname, 0, Math.Min(name.Length, caps.szPname.Length)) == 0) { id = dev; } } } return id; } 
+1
source share

Never use WMI (there is nothing to do here) Use MM apis.

0
source share

All Articles