3
我一直在尝试用一些类似的代码的频率下,从麦克风读取电流声C#的Silverlight播放声音
_Capture是CaptureSource
和_Encoder是(自定义类)
_Capture = new CaptureSource();
_Encoder = new SimpleAudioEncoder(this);
_Encoder.CaptureSource = _Capture;
if (_Capture != null)
{
_Capture.AudioCaptureDevice = CaptureDeviceConfiguration.GetDefaultAudioCaptureDevice();
CaptureDeviceConfiguration.GetDefaultAudioCaptureDevice();
if (CaptureDeviceConfiguration.AllowedDeviceAccess || CaptureDeviceConfiguration.RequestDeviceAccess())
{
MessageBox.Show("_Capture.Start()");
_Capture.Start();
}
}
public class SimpleAudioEncoder : AudioSink
{
public SimpleAudioEncoder() {
}
protected override void OnCaptureStarted()
{
}
protected override void OnCaptureStopped()
{
}
protected override void OnFormatChange(
AudioFormat audioFormat) {
}
protected override void OnSamples(
long sampleTimeInHundredNanoseconds,
long sampleDurationInHundredNanoseconds,
byte[] sampleData)
{
}
}
Im的
定义猜测的sampleData
byte[]
阵列具有我正在查找的数据,但我如何使用它来查找声音的频率?
这将是巨大的,如果我能找到像
public double GetFreq(byte[] data)
功能使用像
double hertz = GetFreq(sampleData)
什么是一些第三方库? –
也可以使用这个傅里叶变换类http://www.codeproject.com/script/Articles/ViewDownloads.aspx?aid=20025点击FourierTansform.cs –
另请参阅http://stackoverflow.com/questions/1847633/net-library-to-identify-pitches/1847723,因为这主要是要求在Silverlight中进行数字运算。 –