public void ComputeSpectrumTest() { double[] srcData = new double[] {1, 2, 3, 4, 3, 2, 1, 0}; double[] expected = new[] { 256.0, 46.627416997969519, 0.0, 1.372583002030479, 0.0, 1.3725830020304794, 0.0, 46.627416997969519 }; Fft fft = new Fft(); DateTime start = DateTime.Now; double[] actual = fft.ComputeAmplitudeSquareSpectrum(srcData); TimeSpan elapsed = DateTime.Now - start; TestContext.WriteLine("Without lookup took {0}", elapsed); Assert.AreEqual(actual.Length, expected.Length, "Lengths are different"); for (int i = 0; i < actual.Length; i++) { Assert.AreEqual(expected[i], actual[i], 0.01, "Failure at index " + i); } }
public MainWindow() { InitializeComponent(); WaveRecorderSettings defaultSettings = WaveRecorderSettings.CreateDefault(); _fft = new Fft(defaultSettings.SamplesPerSecond); _recorder = new WaveRecorder(); _recorder.SoundRecorded += data => Dispatcher.Invoke(new WaveRecorder.SoundRecordedAction(_recorder_SoundRecorded), data); }