public void Reconstruct() { if (SelectedReconstructSignal != null && SelectedReconstructSignal.HasData()) { var sampledSignal = (SampledSignal)SelectedReconstructSignal; ContinuousSignal signal = new ContinuousSignal(); List <(double, double)> reconstructed; if (SelectedReconstruction.Substring(1, 2) == "R1") { reconstructed = Reconstruction .ZeroOrderHold(sampledSignal.PointsX.Zip(sampledSignal.PointsY, (d, d1) => (d, d1)).ToList(), sampledSignal.Frequency, NSamples) .ToList(); } else { reconstructed = Reconstruction .SincReconstruction(sampledSignal.PointsX.Zip(sampledSignal.PointsY, (d, d1) => (d, d1)).ToList(), sampledSignal.Frequency, NSamples) .ToList(); } signal.PointsX = reconstructed.Select(c => c.Item1).ToList(); signal.PointsY = reconstructed.Select(c => c.Item2).ToList(); signal.Name = ReconstructedSignalName + " - R"; SignalCreator.AddSignal(signal); } }
private void TransformMethod() { if (SelectedSignal != null) { SampledSignal signal = new SampledSignal(); signal.PointsY = SelectedSignal.PointsY; signal.Name = $"{SelectedSignal.Name} {SelectedTransform}"; Stopwatch timer = new Stopwatch(); timer.Start(); switch (SelectedTransform.Substring(1, 4)) { case "F1.1": signal.ComplexPoints = FourierTransform.Transform(signal.PointsY); break; case "F1.2": FastFourierTransform fourierTransform = new FastFourierTransform(); signal.ComplexPoints = fourierTransform.Transform(signal.PointsY); break; case "F1.3": signal.ComplexPoints = WaveletTransform.Transform(signal.PointsY); break; } timer.Stop(); Time = timer.ElapsedMilliseconds; SignalCreator.AddSignal(signal); } }
public void Correlate() { if (SelectedSignalCorrelate1 != null && SelectedSignalCorrelate1.HasData() && SelectedSignalCorrelate2 != null && SelectedSignalCorrelate2.HasData()) { SampledSignal signal = new SampledSignal(); signal.PointsY = Correlation.ComputeSignal(SelectedSignalCorrelate1.PointsY, SelectedSignalCorrelate2.PointsY); signal.Name = $"({SelectedSignalCorrelate1.Name})C({SelectedSignalCorrelate2.Name})"; SignalCreator.AddSignal(signal); } }
public void FilterMethod() { if (SelectedSignalFilter1 != null && SelectedSignalFilter1.HasData() && SelectedSignalFilter2 != null && SelectedSignalFilter2.HasData()) { SampledSignal signal = new SampledSignal(); signal.PointsY = Convolution.ComputeSignal(SelectedSignalFilter1.PointsY, SelectedSignalFilter2.PointsY).Skip((SelectedSignalFilter2.PointsY.Count - 1) / 2).Take(SelectedSignalFilter1.PointsY.Count).ToList(); signal.Name = $"({SelectedSignalFilter1.Name})*({SelectedSignalFilter2.Name})"; SignalCreator.AddSignal(signal); } }
public void Quant() { if (SelectedSampledSignal != null && SelectedSampledSignal.HasData()) { var sampledSignal = (SampledSignal)SelectedSampledSignal; SampledSignal signal = new SampledSignal(); signal.PointsX = sampledSignal.PointsX; signal.StartTime = sampledSignal.StartTime; signal.Frequency = sampledSignal.Frequency; signal.PointsY = Quantization.Quantize(sampledSignal.PointsY, QuantCount); signal.Name = QuantSignalName + " - Q"; SignalCreator.AddSignal(signal); } }
public void CreateFilter() { Func <int, double, List <double> > filterFunction = null; Func <List <double>, int, List <double> > windowFunction = null; switch (SelectedFilter.Substring(1, 2)) { case "F0": filterFunction = Filter.LowPassFilter; break; case "F1": filterFunction = Filter.MidPassFilter; break; case "F2": filterFunction = Filter.HighPassFilter; break; } switch (SelectedWindow.Substring(1, 2)) { case "O0": windowFunction = Filter.RectangularWindow; break; case "O1": windowFunction = Filter.HammingWindow; break; case "O2": windowFunction = Filter.HanningWindow; break; case "O3": windowFunction = Filter.BlackmanWindow; break; } SampledSignal signal = new SampledSignal(); signal.PointsY = Filter.CreateFilterSignal(M, K, filterFunction, windowFunction); signal.Name = FilterName + " - F"; SignalCreator.AddSignal(signal); }