gpt4 book ai didi

windows-phone-7 - 获取Windows Phone中麦克风的幅度

转载 作者:行者123 更新时间:2023-12-03 00:49:35 27 4
gpt4 key购买 nike

我想获取Windows Phone中麦克风输入的实时幅度。最简单有效的方法是什么?

最佳答案

要获得振幅,您将必须处理Microphone类的BufferReady事件:

http://msdn.microsoft.com/en-us/library/windowsphone/develop/gg442302(v=vs.105).aspx

设定码

Microphone microphone = Microphone.Default;
microphone.BufferReady += new EventHandler<EventArgs>(microphone_BufferReady);
microphone.BufferDuration = TimeSpan.FromMilliseconds(1000);

byte[] buffer;
buffer = new byte[microphone.GetSampleSizeInBytes(microphone.BufferDuration)];

microphone.Start();

事件处理程序块
void microphone_BufferReady(object sender, EventArgs e)
{

microphone.GetData(buffer);


for(int i = 0; i< buffer.Length; i+=2)
{
//The value of sample is the amplitude of the signal
short sample = BitConverter.ToInt16(new byte[2] { buffer[i], buffer[i + 1] }, 0);
}
}

关于windows-phone-7 - 获取Windows Phone中麦克风的幅度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22948388/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com