private void RunTest() { Setup(); SimpleDFT.DFT(inputReal, outputReal, outputImag); FFTn.FFT(input, fftn); FFTn.IFFT(fftn, ifftn); FFTm.FFT(input, fftm); FFTm.IFFT(fftm, ifftm); CompareFFTn(); CompareIFFTn(); CompareFFTm(); CompareIFFTm(); }
public static double[][][] TransformWavetable(double[][] wavetable) { var waveCount = wavetable.Length; var newWavetable = new double[waveCount][][]; if (wavetable.Any(x => x.Length != WaveSize)) { throw new Exception("Wave length must be " + WaveSize); } var trans = new TransformNative(WaveSize); for (var w = 0; w < waveCount; w++) { newWavetable[w] = new double[PartialsTableCount][]; var baseWave = wavetable[w]; var complexIn = baseWave.Select(x => new Complex(x, 0)).ToArray(); var fft = new Complex[complexIn.Length]; var ifft = new Complex[fft.Length]; trans.FFT(complexIn, fft); for (var i = 0; i < PartialsTableCount; i++) { var partials = PartialsPerWave[i]; for (var n = partials + 1; n < fft.Length - partials; n++) { fft[n].Real = 0; fft[n].Imag = 0; } trans.IFFT(fft, ifft); newWavetable[w][i] = ifft.Select(x => x.Real).ToArray(); } } return(newWavetable); }