本文整理汇总了C#中Microsoft.Xna.Framework.Audio.Microphone.Start方法的典型用法代码示例。如果您正苦于以下问题:C# Microphone.Start方法的具体用法?C# Microphone.Start怎么用?C# Microphone.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Audio.Microphone
的用法示例。
在下文中一共展示了Microphone.Start方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StartCapture
public void StartCapture()
{
try
{
if (_microphone == null)
{
_microphone = Microphone.Default;
_microphone.BufferDuration = TimeSpan.FromMilliseconds(100);
var sampleSize = _microphone.GetSampleSizeInBytes(_microphone.BufferDuration);
_baBuffer = new byte[sampleSize];
_microphone.BufferReady += MicrophoneBufferReady;
_microphone.Start();
}
}
catch (Exception)
{
}
}
示例2: MicrophoneButton
private MicrophoneButton(Microphone microphone)
{
FrameworkDispatcher.Update();
var minSupportedBufferDurationMs = 100;
var duration = TimeSpan.FromMilliseconds(minSupportedBufferDurationMs);
Microphone = microphone;
Microphone.BufferDuration = duration;
Buffer = new byte[Microphone.GetSampleSizeInBytes(duration)];
Buffer2D = new Color[TexWidth * byte.MaxValue];
Texture2D = Texture2D ?? Program.Renderer.LeaseFor<Gray, byte>(TexWidth, byte.MaxValue);
Texture2D.SetData(Buffer2D);
Microphone.BufferReady += OnBufferReady;
Microphone.Start();
}