public void ComputeInverseComirvaMatrixUsingLomontTableFFT(Comirva.Audio.Util.Maths.Matrix m, int column, ref double[] signal, int winsize, int hopsize) { double[] spectrogramWindow = m.GetColumn(column); // extend window with the inverse duplicate array int len = spectrogramWindow.Length; double[] 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 = FFTUtilsLomont.DoubleToComplexDouble(extendedWindow); lomonFFT.TableFFT(complexSignal, false); double[] window = win.GetWindow(); // multiply by window w/ overlap-add int N = complexSignal.Length / 2; double[] 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 + hopsize * column] = signal[j + hopsize * column] + returnArray[j] * 2; } }
public void ComputeComirvaMatrixUsingLomontTableFFT(ref Comirva.Audio.Util.Maths.Matrix m, int column, float[] audiodata, int pos) { // apply the window method (e.g HammingWindow, HannWindow etc) win.Apply(ref data, audiodata, pos); double[] complexSignal = FFTUtilsLomont.FloatToComplexDouble(data); lomonFFT.TableFFT(complexSignal, true); int row = 0; for (int i = 0; i < complexSignal.Length / 4; i += 2) { double re = complexSignal[2 * i]; double img = complexSignal[2 * i + 1]; m.MatrixData[row][column] = Math.Sqrt((re * re + img * img) * complexSignal.Length / 2); row++; } }