2

FFTを実行する必要があり、サウンドサンプルの.wav形式があります。関数 double[] xRe, double[] xIm, REAL PART and imaginary partには、サウンドファイルをdouble []に​​変換する方法が必要ですか?私はそのようなものを見たことがありません。そのような操作をインターネットで見つけることができませんでした。これはこのサウンドサンプルです: http ://www.speedyshare.com/fFD8t/e.wav

助けてください、私がPascalを使用したので、ここで何をすべきかわからないからです。

4

2 に答える 2

6

これは単純なストリーム操作です。

  1. wav ファイルのヘッダーを読み取る必要があります。
  2. データバイトを読み取る必要があります。

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

これはより詳細な説明です:

http://msdn.microsoft.com/en-us/library/ff827591.aspx

ここでは、WAV ファイル形式について読むことができます。

https://ccrma.stanford.edu/courses/422/projects/WaveFormat/

そして、複素数と FFT としての WAV について:

波形データを複素数に変換する方法

于 2012-11-15T02:11:25.673 に答える