我需要使用44100hz sampleRate从麦克风获取数据。 并且每0.1秒用fft进行一些分析。 这是我的代码:
dt.Interval = TimeSpan.FromMilliseconds(33);
dt.Tick += new EventHandler(dt_Tick);
dt.Start();
// Event handler for getting audio data when the buffer is full
microphone.BufferReady += new EventHandler<EventArgs>(microphone_BufferReady);
// Get audio data in 1/10 second chunks
microphone.BufferDuration = TimeSpan.FromMilliseconds(100);
// Allocate memory to hold the audio data
buffer = new byte[microphone.GetSampleSizeInBytes(microphone.BufferDuration)];
// Start recording
microphone.Start();
void microphone_BufferReady(object sender, EventArgs e)
{
// Retrieve audio data
microphone.GetData(buffer);
System.Diagnostics.Debug.WriteLine(buffer.Length + " " + microphone.SampleRate);
// ... fft(buffer) ... some analysis
}
如何将SampleRate更改为44100并获得每0.1秒大小为4410(或4096)的缓冲区??? 谢谢
答案 0 :(得分:0)
不幸的是,Microphone类不支持采样率转换。您无法更改Windows Phone设备上的采样率。音频播放和录制速率由OEM设置。因此,您需要自己进行采样率对话。
我希望这有帮助,
詹姆斯