/// <summary> /// Takes the input array and shortens it to the correct value by passing it through a window function. /// </summary> /// <param name="input">The input array that is oversized.</param> /// <param name="reqLength">The required length of the input array.</param> /// <param name="type">The type of window you would like to apply.</param> /// <returns>The output array which is properly sized.</returns> public static double[] ApplyWindowFunction(float[] input, int reqLength, WindowType type) { WindowFunction function = new WindowFunction(type); double[] temp = new double[input.Length]; for (int i = 0; i < temp.Length; i++) temp[i] = (double)input[i]; return function.ApplyWindowFunction(temp, reqLength); }
public static double[,] FFTW(double[] y, double samplerate, WindowFunction.WindowType window) { double[] w = new double[y.Length]; for (int i = 0; i < w.Length; i++) w[i] = 1; w = WindowFunction.ApplyWindowFunction(w, w.Length, window); double mean = Mean(w) / 2 * y.Length; y = WindowFunction.ApplyWindowFunction(y, y.Length, window); var fft = FFTW(y, samplerate, 1); for (int i = 0; i < fft.Length / 2; i++) fft[1, i] /= mean; return fft; }
/// <summary> /// Takes the input array and shortens it to the correct value by passing it through a window function. /// </summary> /// <param name="input">The input array that is oversized.</param> /// <param name="reqLength">The required length of the input array.</param> /// <param name="type">The type of window you would like to apply.</param> /// <returns>The output array which is properly sized.</returns> public static double[] ApplyWindowFunction(double[] input, int reqLength, WindowType type) { WindowFunction function = new WindowFunction(type); return function.ApplyWindowFunction(input, reqLength); }