本文整理匯總了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();
}