我試圖在C#中實現Hanning and Hamming window functions。我無法在任何地方找到任何.Net樣本,我不確定我是否嘗試從C++樣本轉換成功。C中的漢寧和漢明窗口函數#
我的問題主要是看formulas我想他們需要在方程右邊的某個地方有原始數字 - 我只是不明白公式。 (我的數學不是很好但很明顯。)
我有什麼至今:
public Complex[] Hamming(Complex[] iwv)
{
Complex[] owv = new Complex[iwv.Length];
double omega = 2.0 * Math.PI/(iwv.Length);
// owv[i].Re = real number (raw wave data)
// owv[i].Im = imaginary number (0 since it hasn't gone through FFT yet)
for (int i = 1; i < owv.Length; i++)
// Translated from c++ sample I found somewhere
owv[i].Re = (0.54 - 0.46 * Math.Cos(omega * (i))) * iwv[i].Re;
return owv;
}
public Complex[] Hanning(Complex[] iwv)
{
Complex[] owv = new Complex[iwv.Length];
double omega = 2.0 * Math.PI/(iwv.Length);
for (int i = 1; i < owv.Length; i++)
owv[i].Re = (0.5 + (1 - Math.Cos((2d * Math.PI)/(i -1)))); // Uhm... wrong
return owv;
}
退房的循環 - 它簡單跳過第一個元素的數組 'owv [0]'。它必須是:for(int i = 0; i
Vladislav