我一直在使用waveInGetDevsCap获取波段名称。 在装置中,但WAVEINCAPS 结构只支持31个特性加上一个无效,也就是说,在我的计算机上,我收到的装置名称被压缩:
Microphone / Line In (SigmaTel
Microphone Array (SigmaTel High,
我确信,必须有一种获得全部装置名称的途径,但任何人都知道什么?
我一直在使用waveInGetDevsCap获取波段名称。 在装置中,但WAVEINCAPS 结构只支持31个特性加上一个无效,也就是说,在我的计算机上,我收到的装置名称被压缩:
Microphone / Line In (SigmaTel
Microphone Array (SigmaTel High,
我确信,必须有一种获得全部装置名称的途径,但任何人都知道什么?
是的,有工作。 我曾多次在航运法典中解决这一问题。
带有直接电能的计数音频捕获装置。 AP是直接电算。 它将把装置的全时名称归还给你。
当然,你也许会想到“谁是伟大的,但我守则的其余部分是为了使用波段的,而不是直接的。 我不想转而去。 因此,我怎么能够把直接电算法数字返回的GUID ID,看上去《波伦报》所使用的立格识别器?”
解决办法是CreateInstance for the DirectSoundPrivate Object (or calls GetClassObject direct from d well.dll) to have a pointer to an IKsPropertySet cross. 从这一接口中,你可以获取国际数据库数据集,以绘制全球信息数据库。 详情见网页:
你们想要利用《综合安全标准》。 如上文所述网页所示。
根据@Andrea Bertucelli的答复改进/完善的C# WPF代码
using NAudio.CoreAudioApi;
using NAudio.Wave;
using System;
using System.Collections.Generic;
using System.Windows;
namespace WpfApp2
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
foreach (KeyValuePair<string, MMDevice> device in GetInputAudioDevices())
{
Console.WriteLine("Name: {0}, State: {1}", device.Key, device.Value.State);
}
}
public Dictionary<string, MMDevice> GetInputAudioDevices()
{
Dictionary<string, MMDevice> retVal = new Dictionary<string, MMDevice>();
MMDeviceEnumerator enumerator = new MMDeviceEnumerator();
int waveInDevices = WaveIn.DeviceCount;
for (int waveInDevice = 0; waveInDevice < waveInDevices; waveInDevice++)
{
WaveInCapabilities deviceInfo = WaveIn.GetCapabilities(waveInDevice);
foreach (MMDevice device in enumerator.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.All))
{
if (device.FriendlyName.StartsWith(deviceInfo.ProductName))
{
retVal.Add(device.FriendlyName, device);
break;
}
}
}
return retVal;
}
}
}
我完成了波段的名称。 在装置中,探究从MMDeviceE计数人处返回的名字。 每一波 在装置上,如果名称不完整是计算器之一的全名的一部分,我就将这一全名用于照相机箱。 在装置中。
视觉基础网络:
Dim wain = New WaveIn()
Dim DeviceInfoI As WaveInCapabilities
Dim nomedevice As String
For de = 0 To wain.DeviceCount - 1
DeviceInfoI = wain.GetCapabilities(de)
nomedevice = DeviceInfoI.ProductName
For deg = 0 To devices.Count - 1
If InStr(devices.Item(deg).FriendlyName, nomedevice) Then
nomedevice = devices.Item(deg).FriendlyName
Exit For
End If
Next
cmbMessaggiVocaliMIC.Items.Add(nomedevice)
Next
cmbMessaggiVocaliMIC.SelectedIndex = 0
waveIn.DeviceNumber = cmbMessaggiVocaliMIC.SelectedIndex
登记处采用的办法比使用直接通知更简单。 如果你使用WAVEINCAPS2结构,它有一个名称GUID,即参照KongLMSystemCurrentControlSetControlMediaCategories的钥匙。 如果钥匙确实存在,那么就在结构中使用名称。 http://msdn.microsoft.com/en-us/library/windows/hardware/ff536382%28v=vs.85%29.aspx”rel=“nofollow”http://msdn.microsoft.com/en-us/library/windows/hardware/ff536382%28v=vs.85%29.aspx。 例如:
public static ICollection<AudioInputDevice> GetDevices()
{
RegistryKey namesKey = Registry.LocalMachine.OpenSubKey(@"SystemCurrentControlSetControlMediaCategories");
List<AudioInputDevice> devices = new List<AudioInputDevice>();
for(int i=0, deviceCount=waveInGetNumDevs(); i<deviceCount; i++)
{
WAVEINCAPS2 caps;
if(waveInGetDevCaps(new IntPtr(i), out caps, Marshal.SizeOf(typeof(WAVEINCAPS2))) == 0 && caps.Formats != 0)
{
string name = null;
if(namesKey != null)
{
RegistryKey nameKey = namesKey.OpenSubKey(caps.NameGuid.ToString("B"));
if(nameKey != null) name = nameKey.GetValue("Name") as string;
}
devices.Add(new AudioInputDevice(name ?? caps.Name, caps.ProductGuid));
}
}
return devices;
}
struct WAVEINCAPS2
{
public short ManufacturerId, ProductId;
public uint DriverVersion;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)] public string Name;
public uint Formats;
public short Channels;
ushort Reserved;
public Guid ManufacturerGuid, ProductGuid, NameGuid;
}
[DllImport("winmm.dll")]
static extern int waveInGetDevCaps(IntPtr deviceId, out WAVEINCAPS2 caps, int capsSize);
[DllImport("winmm.dll", ExactSpelling=true)]
static extern int waveInGetNumDevs();
象“直接繁荣”一样,有一些问题。 我正试图从一个空洞的项目中获取,并做得当。 然而,当我试图从COM DLLLL或从DLL读取时,它就返回了E_NOTPRIL
。 编号:Get。
但我看到了另一个陷阱。 直接公示似乎在潮湿的次序(不包括第一次违约)中捕获和制造装置。
我们仍然必须同老的波段预报系统进行互动,而且仍然缺乏这样做的适当途径。 直接 展示会提供基于波浪In的音频投入装置,我需要获得相应的西非经货共同体溢价和逆差。
利用NAudio,即使用该代码获得全方位装置名称......
using NAudio.CoreAudioApi;
using NAudio.Wave;
获取所有录音设备:
//create enumerator
var enumerator = new MMDeviceEnumerator();
//cycle through all audio devices
for (int i = 0; i < WaveIn.DeviceCount; i++)
Console.WriteLine(enumerator.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.Active)[i]);
//clean up
enumerator.Dispose();
获取所有捕获装置:
//create enumerator
var enumerator = new MMDeviceEnumerator();
//cyckle trough all audio devices
for (int i = 0; i < WaveOut.DeviceCount; i++)
Console.WriteLine(enumerator.EnumerateAudioEndPoints(DataFlow.Render, DeviceState.Active)[i]);
//clean up
enumerator.Dispose();
我找到了另一种方式,利用登记册找到全称的视听设备,包括投入和产出。
视窗7和视窗10。
这种方法首先尝试了Adam M.的方法。 他的方法对我不利,但就在我工作的情况下,我作为首选方法补充了。
Delphi:
procedure TForm_Config.FormCreate(Sender: TObject);
type
tagWAVEOUTCAPS2A = packed record
wMid: WORD;
wPid: WORD;
vDriverVersion: MMVERSION;
szPname: array[0..MAXPNAMELEN-1] of AnsiChar;
dwFormats: DWORD;
wChannels: WORD;
wReserved1: WORD;
dwSupport: DWORD;
ManufacturerGuid: System.TGUID;
ProductGuid: System.TGUID;
NameGuid: System.TGUID;
end;
var
i,outdevs: Integer;
woCaps: tagWAVEOUTCAPS2A;
RegistryService: TRegistry;
iClasses, iSubClasses, iNames: Integer;
audioDeviceClasses, audioDeviceSubClasses, audioDeviceNames: TStringList;
initialDeviceName, partialDeviceName, fullDeviceName: string;
begin
audioDeviceClasses := TStringList.Create;
audioDeviceSubClasses := TStringList.Create;
audioDeviceNames := TStringList.Create;
try
RegistryService := TRegistry.Create;
try
RegistryService.RootKey := HKEY_LOCAL_MACHINE;
if RegistryService.OpenKeyReadOnly( SYSTEMCurrentControlSetEnumHDAUDIO ) then begin
RegistryService.GetKeyNames(audioDeviceClasses);
RegistryService.CloseKey();
for iClasses := 0 to audioDeviceClasses.Count - 1 do begin
if RegistryService.OpenKeyReadOnly( SYSTEMCurrentControlSetEnumHDAUDIO +audioDeviceClasses[iClasses]) then begin
RegistryService.GetKeyNames(audioDeviceSubClasses);
RegistryService.CloseKey();
for iSubClasses := 0 to audioDeviceSubClasses.Count - 1 do begin
if RegistryService.OpenKeyReadOnly( SYSTEMCurrentControlSetEnumHDAUDIO +audioDeviceClasses[iClasses]+ +audioDeviceSubClasses[iSubClasses]) then begin
if RegistryService.ValueExists( DeviceDesc ) then begin
fullDeviceName := Trim(RegistryService.ReadString( DeviceDesc ));
if AnsiPos( ; ,fullDeviceName) > 0 then begin
fullDeviceName := Trim(AnsiMidStr(fullDeviceName, AnsiPos( ; ,fullDeviceName)+1, Length(fullDeviceName)));
end;
audioDeviceNames.Add(fullDeviceName);
end;
RegistryService.CloseKey();
end;
end;
end;
end;
end;
finally
FreeAndNil(RegistryService);
end;
// WaveOutDevComboBox is a selection box (combo) placed in the form and will receive the list of output audio devices
WaveOutDevComboBox.Clear;
try
outdevs := waveOutGetNumDevs;
for i := 0 to outdevs - 1 do begin
ZeroMemory(@woCaps, sizeof(woCaps));
if waveOutGetDevCaps(i, @woCaps, sizeof(woCaps)) = MMSYSERR_NOERROR then begin
RegistryService := TRegistry.Create;
try
RegistryService.RootKey := HKEY_LOCAL_MACHINE;
if RegistryService.OpenKeyReadOnly( SystemCurrentControlSetControlMediaCategories + GUIDToString(woCaps.NameGuid)) then begin
WaveOutDevComboBox.Items.Add(RegistryService.ReadString( Name ));
RegistryService.CloseKey();
end
else begin
initialDeviceName := ;
partialDeviceName := Trim(woCaps.szPname);
if AnsiPos( ( ,partialDeviceName) > 0 then begin
initialDeviceName := Trim(AnsiLeftStr(partialDeviceName,AnsiPos( ( ,partialDeviceName)-1));
partialDeviceName := Trim(AnsiMidStr(partialDeviceName,AnsiPos( ( ,partialDeviceName)+1,Length(partialDeviceName)));
if AnsiPos( ) ,partialDeviceName) > 0 then begin
partialDeviceName := Trim(AnsiLeftStr(partialDeviceName,AnsiPos( ) ,partialDeviceName)-1));
end;
end;
for iNames := 0 to audioDeviceNames.Count - 1 do begin
fullDeviceName := audioDeviceNames[iNames];
if AnsiStartsText(partialDeviceName,fullDeviceName) then begin
break;
end
else begin
fullDeviceName := partialDeviceName;
end;
end;
WaveOutDevComboBox.Items.Add(initialDeviceName + IfThen(initialDeviceName<>EmptyStr, ( , ) + fullDeviceName + IfThen(initialDeviceName<>EmptyStr, ) , ));
end;
finally
FreeAndNil(RegistryService);
end;
end;
end;
except
WaveOutDevComboBox.Enabled := False;
end;
finally
FreeAndNil(audioDeviceClasses);
FreeAndNil(audioDeviceSubClasses);
FreeAndNil(audioDeviceNames);
end;
end;