private void GeneratePeaks(int secondsPerRead, IPeakFinder peakFinder) { var readBuffer = new byte[reader.WaveFormat.AverageBytesPerSecond * secondsPerRead]; var stopWatch = new Stopwatch(); while (true) { var read = reader.Read(readBuffer, 0, readBuffer.Length); if (read == 0) { break; } stopWatch.Start(); peakFinder.FindPeaks(readBuffer, read, 44100 / 10); stopWatch.Stop(); } Console.WriteLine("{0} took {1}ms", peakFinder.GetType().Name, stopWatch.ElapsedMilliseconds); }
private void CompareFinders(IPeakFinder firstFinder, IPeakFinder secondFinder) { var readBuffer = new byte[reader.WaveFormat.AverageBytesPerSecond * 4]; var read = reader.Read(readBuffer, 0, readBuffer.Length); var samplesPerPeak = 44100 / 10; var firstPeaks = firstFinder.FindPeaks(readBuffer, read, samplesPerPeak); var secondPeaks = secondFinder.FindPeaks(readBuffer, read, samplesPerPeak); Assert.AreEqual(firstPeaks, secondPeaks, String.Format("peaks from {0} don't match peaks from {1}", firstFinder.GetType().Name, secondFinder.GetType().Name)); }