public void Should_provide_the_FFT_provider_result_via_the_DataReady_event() { var buffers = new float[][] { new float[4] }; var expected = new float[] { 5f, 6f, 7f, 8f }; transformProvider.FFT(Arg.Any <bool>(), Arg.Any <int>(), Arg.Do <Complex[]>(x => { x[0] = new Complex { X = expected[0], Y = 0f }; x[1] = new Complex { X = expected[1], Y = 0f }; x[2] = new Complex { X = expected[2], Y = 0f }; x[3] = new Complex { X = expected[3], Y = 0f }; })); target = new FourierTransform(transformProvider, windowFunction, 4); float[] actual = null; target.DataReady += (s, e) => actual = e.Real; target.Format = new WaveFormat(44100, 1); target.Process(buffers, 4); CollectionAssert.AreEqual(expected, actual, new FloatComparer()); }
private void calculateTransform(ChannelData channel) { for (int i = 0; i < transformLength; i++) { channel.Complex[i] = new Complex { X = channel.InputHistory[i] * window[i], Y = 0f }; } transformProvider.FFT(true, m, channel.Complex); var e = new FourierTransformEventArgs( transformLength, channel.Index, channel.Complex); if (DataReady != null) { DataReady.Invoke(this, e); } }