public void TestRepeat() { var samples = new double[] { -1, 2, 3, -4 }; var output = WaveMath.Repeat(samples, 1, 1); Assert.IsTrue(output.SequenceEqual(new double[] { -1, -1, 2, 2, 3, 3, -4, -4 })); output = WaveMath.Repeat(samples, 1, 2); Assert.IsTrue(output.SequenceEqual(new double[] { -1, -1, -1, 2, 2, 2, 3, 3, 3, -4, -4, -4 })); output = WaveMath.Repeat(samples, 1, 3); Assert.IsTrue(output.SequenceEqual(new double[] { -1, -1, -1, -1, 2, 2, 2, 2, 3, 3, 3, 3, -4, -4, -4, -4 })); output = WaveMath.Repeat(samples, 1, 4); Assert.IsTrue(output.SequenceEqual(new double[] { -1, -1, -1, -1, -1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, -4, -4, -4, -4, -4 })); output = WaveMath.Repeat(samples, 2, 1); Assert.IsTrue(output.SequenceEqual(new double[] { -1, 2, -1, 2, 3, -4, 3, -4 })); output = WaveMath.Repeat(samples, 2, 2); Assert.IsTrue(output.SequenceEqual(new double[] { -1, 2, -1, 2, -1, 2, 3, -4, 3, -4, 3, -4 })); output = WaveMath.Repeat(samples, 2, 3); Assert.IsTrue(output.SequenceEqual(new double[] { -1, 2, -1, 2, -1, 2, -1, 2, 3, -4, 3, -4, 3, -4, 3, -4 })); output = WaveMath.Repeat(samples, 3, 4); Assert.IsTrue(output.SequenceEqual(new double[] { -1, 2, 3, -1, 2, 3, -1, 2, 3, -1, 2, 3, -1, 2, 3, -4, -4, -4, -4, -4 })); output = WaveMath.Repeat(samples, 0, 1); Assert.IsTrue(output.SequenceEqual(new double[] { -1, 2, 3, -4 })); output = WaveMath.Repeat(samples, 1, 0); Assert.IsTrue(output.SequenceEqual(new double[] { -1, 2, 3, -4 })); samples = new double[] { }; output = WaveMath.Repeat(samples, 2, 2); Assert.IsTrue(output.SequenceEqual(new double[] { })); samples = DateTime.Now.Second >= 0 ? null : new double[0]; output = WaveMath.Repeat(samples, 2, 2); Assert.IsNull(output); }
public void TestRepeatSignal() { var samples = new Signal(-1, 2, 3, -4) { Start = -1, Finish = 0.5, SamplingInterval = 0.5 }; var output = WaveMath.Repeat(samples, 1, 1, true); Assert.IsTrue(output.Samples.SequenceEqual(new double[] { -1, -1, 2, 2, 3, 3, -4, -4 })); Assert.AreEqual(0.5, output.SamplingInterval); Assert.AreEqual(-1, output.Start); Assert.AreEqual(2.5, output.Finish); output = WaveMath.Repeat(samples, 1, 1, false); Assert.IsTrue(output.Samples.SequenceEqual(new double[] { -1, -1, 2, 2, 3, 3, -4, -4 })); Assert.AreEqual(0.1875, output.SamplingInterval); Assert.AreEqual(-1, output.Start); Assert.AreEqual(0.5, output.Finish); }
/// <summary> /// Executes the block /// </summary> public override void Execute() { var inputNode = InputNodes[0].ConnectingNode as BlockOutputNode; if (inputNode == null || inputNode.Object == null) { return; } OutputNodes[0].Object.Clear(); foreach (var signal in inputNode.Object) { OutputNodes[0].Object.Add(WaveMath.Repeat(signal, FrameSize, RepetitionCount, KeepSamplingRate)); } if (Cascade && OutputNodes[0].ConnectingNode != null) { OutputNodes[0].ConnectingNode.Root.Execute(); } }