0
class Main
{
WaveFileReader reader;
short[] sample;
Complex[] tmpComplexArray;
public Main()
{
//read in wav, to raw data in byte array then to short array.
reader = new WaveFileReader("C:\\Users\\minford\\Downloads\\English_Subtitles_.wav");
byte[] buffer = new byte[reader.Length];
reader.Read(buffer, 0 , buffer.Length);
sample = new short[reader.Length];
for (int n = 0; n < buffer.Length; n += 2)
{
sample[n] = BitConverter.ToInt16(buffer, n);
}
// short array to complex
Complex[] complexData = new Complex[sample.Length];
for (int i = 0; i < complexData.Length; i++)
{
Complex tmp = new Complex(sample[i],0);
complexData[i] = tmp;
}
//to get first 500 for testing.
tmpComplexArray = new Complex[500];
for (int i = 0; i < 500; i++)
{
Complex a = new Complex(complexData[i]);
tmpComplexArray[i] = a;
}
//run FFT
FourierTransform.DFT(tmpComplexArray ,FourierTransform.Direction.Forward);
//print result
for (int i = 0; i < complexData.Length; i++)
{
Console.Write(complexData[i]);
}
}
}
我同時使用來自AForge的FFT有這個問題。這是使用它的正確方法嗎?返回的複數(此時僅返回前500個)每次都有第二個數字爲0。