我需要执行FFT,我有一个声音样本.wav格式.该功能需要 double[] xRe, double[] xIm, REAL PART and imaginary part如何将声音文件转换为double []?我从来没有见过这样的东西.无法在互联网上找到那种操作.这是一个声音样本:http:
//www.speedyshare.com/fFD8t/e.wav
请帮助,因为我使用Pascal,现在不知道该怎么做.
这是一个简单的流操作.
从MSDN粘贴:
BinaryReader reader = new BinaryReader(waveFileStream);
//Read the wave file header from the buffer.
int chunkID = reader.ReadInt32();
int fileSize = reader.ReadInt32();
int riffType = reader.ReadInt32();
int fmtID = reader.ReadInt32();
int fmtSize = reader.ReadInt32();
int fmtCode = reader.ReadInt16();
int channels = reader.ReadInt16();
int sampleRate = reader.ReadInt32();
int fmtAvgBPS = reader.ReadInt32();
int fmtBlockAlign = reader.ReadInt16();
int bitDepth = reader.ReadInt16();
if (fmtSize == 18)
{
// Read any extra values
int fmtExtraSize = reader.ReadInt16();
reader.ReadBytes(fmtExtraSize);
}
int dataID = reader.ReadInt32();
int dataSize = reader.ReadInt32();
// Store the audio data of the wave file to a byte array.
byteArray = reader.ReadBytes(dataSize);
// After this you have to split that byte array for each channel (Left,Right)
// Wav supports many channels, so you have to read channel from header
Run Code Online (Sandbox Code Playgroud)
这里有更详细的解释:
http://msdn.microsoft.com/en-us/library/ff827591.aspx
在这里你可以阅读有关WAV文件格式:
https://ccrma.stanford.edu/courses/422/projects/WaveFormat/
关于WAV的复杂数字和FFT: