public void ComputeInverseMatrixUsingLomontTableFFT(Matrix m, int column, ref double[] signal, int winsize, int overlap) { double[] spectrogramWindow = m.GetColumn(column); // extend window with the inverse duplicate array int len = spectrogramWindow.Length; var extendedWindow = new double[len * 2]; Array.Copy(spectrogramWindow, extendedWindow, len); for (int i = 1; i < len; i++) { extendedWindow[len + i] = spectrogramWindow[len - i]; } double[] complexSignal = FFTUtils.DoubleToComplexDouble(extendedWindow); lomonFFT.TableFFT(complexSignal, false); double[] window = win.Window; // multiply by window w/ overlap-add int N = complexSignal.Length / 2; var returnArray = new double[N]; for (int j = 0; j < N; j++) { double re = complexSignal[2 * j] / Math.Sqrt(winsize); //double img = complexSignal[2*j + 1]; returnArray[j] = re * window[j]; // smooth yet another time (also did this when doing FFT) // overlap-add method // scale with 2 just because the volume got so much lower when using a second smoothing filter when reconstrcting signal[j + overlap * column] = signal[j + overlap * column] + returnArray[j]; // * 3; } }
// seem to the be the fastest FFT? static double[] FFTWLIB(double[] signal) { var complexSignal = FFTUtils.DoubleToComplexDouble(signal); // prepare the input arrays var complexInput = new fftw_complexarray(complexSignal); var complexOutput = new fftw_complexarray(complexSignal.Length / 2); fftw_plan fft = fftw_plan.dft_1d(complexSignal.Length / 2, complexInput, complexOutput, fftw_direction.Forward, fftw_flags.Estimate); // perform the FFT fft.Execute(); // get the result var spectrum_fft_abs = complexOutput.Abs; //Export.ExportCSV("audio_buffer_padded2.csv", signal); //Export.ExportCSV("spectrum_fft_abs2.csv", spectrum_fft_abs2, fftSize); // free up memory complexInput = null; complexOutput = null; return(spectrum_fft_abs); }