我试图从 Microphone 获取一些输入并将其保存到.wav/.mp3 文件中。我成功地从麦克风获取输入,并将其保存到文件中。但我认为保存有问题,因为当我尝试手动打开文件时,我遇到了一个错误,提示我的媒体播放器无法打开文件。如果需要此信息,我将使用 XNA 从麦克风获取音频。我的代码:
byte[] Buffer = new [Microphone.Default.GetSampleSizeInBytes(TimeSpan.FromMilliseconds(5000))];
int i = 0;
While(i != Buffer.Length - 1)
{
microphone.GetData(Buffer, 0, Buffer.Length); //With this code i'm getting the input from the Microphone..
i++;
}
System.IO.File.WriteAllBytes(@"C:\Program\TestRecord.wav", Buffer); //With this code i'm saving the input in my file.
有谁知道这个问题的原因是什么?我会很高兴得到一些帮助..
谢谢你