C#获取话筒主峰值(实时音频输出分贝量)

2021-02-06 08:14

阅读:544

public float GetVoicePeakValue()
{
var enumerator = new MMDeviceEnumerator();
var CaptureDevices = enumerator.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.Active).ToArray();
var defaultDevice = enumerator.GetDefaultAudioEndpoint(DataFlow.Capture, Role.Console);
var selectedDevice = CaptureDevices.FirstOrDefault(c => c.ID == defaultDevice.ID);
return selectedDevice.AudioMeterInformation.MasterPeakValue;
}


评论


亲,登录后才可以留言!