我需要一個快速的方法來存儲數組中的所有wav文件樣本。我目前正在通過播放音樂並存儲來自示例提供程序的值來解決此問題,但這不太優雅。在數組中存儲一個wav文件
從n音訊演示我有Audioplayer類具有此方法:
private ISampleProvider CreateInputStream(string fileName)
{
if (fileName.EndsWith(".wav"))
{
fileStream = OpenWavStream(fileName);
}
throw new InvalidOperationException("Unsupported extension");
}
var inputStream = new SampleChannel(fileStream, true);
var sampleStream = new NotifyingSampleProvider(inputStream);
SampleRate = sampleStream.WaveFormat.SampleRate;
sampleStream.Sample += (s, e) => { aggregator.Add(e.Left); }; // at this point the aggregator gets the current sample value, while playing the wav file
return sampleStream;
}
我想跳過獲取樣本值,同時播放該文件的這一進展,而不是我立刻想要的值,而無需等待,直到文件結尾。基本上像matlab中的wavread命令。
爲什麼它不優雅?你能粘貼到目前爲止已經嘗試過的任何東西,在幫助你時給別人什麼東西繼續? – 2013-03-14 20:41:47
因爲我想從一個wav文件創建一個STFT,我想通過一個按鈕單擊來計算它。爲此,我需要所有樣本值。 我會嘗試添加一些代碼並編輯我的第一篇文章 – 2013-03-14 20:50:54