public static List <TimedAmplitude> RemoveNoise(List <TimedAmplitude> timedExtremums, double maxNoise) //AVG chrono { if (maxNoise == 0) { return(timedExtremums); } TimedAmplitude FirstWave = timedExtremums.First(); List <TimedAmplitude> NoNoiseExtremums = new List <TimedAmplitude>(); NoNoiseExtremums.Add(FirstWave); double LastWaveSize = FirstWave.Amplitude; for (int i = 1; i < timedExtremums.Count - 1; i++) { TimedAmplitude wave = timedExtremums[i]; if (Math.Abs(wave.Amplitude - LastWaveSize) / Math.Max(wave.Amplitude, LastWaveSize) >= maxNoise) { NoNoiseExtremums.Add(wave); LastWaveSize = wave.Amplitude; } } NoNoiseExtremums.Add(timedExtremums.Last()); return(NoNoiseExtremums); }
public static List <Point> GetSoundCoordinates(List <TimedAmplitude> sound, WaveToCoordinatesTranformer waveToCoordinatesTranformer) { List <Point> coords = new List <Point>(); TimedAmplitude prev1 = sound.First(); TimedAmplitude prev2 = sound[1]; for (int i = 2; i < sound.Count; i++) { (double x, double y) = waveToCoordinatesTranformer(prev1, prev2, sound[i]); Point P = new Point(x, y); if (!coords.Contains(P)) { coords.Add(P); } prev1 = prev2; prev2 = sound[i]; } return(coords); }
public delegate(double x, double y) WaveToCoordinatesTranformer(TimedAmplitude min1, TimedAmplitude max, TimedAmplitude min2);