public static IEnumerable <LocalRange> PreparePeaks(this List <double> data, IProcessorModel <float> model) { var dataLength = data.Count; for (int sampleLocation = NEIGHBOURS_COUNT; sampleLocation < data.Count - NEIGHBOURS_COUNT; sampleLocation++) { if (data[sampleLocation] < CONSIDERED_VOLUME) { continue; } var isPeak = true; for (int sampleMove = 0; sampleMove < NEIGHBOURS_COUNT; sampleMove++) { //left var leftNeighbour = sampleLocation - sampleMove; if (data[leftNeighbour] < data[leftNeighbour - 1]) //data is represent with negative number { isPeak = false; break; } //right var rightNeighbour = sampleLocation + sampleMove; if (data[rightNeighbour] < data[rightNeighbour + 1]) { isPeak = false; break; } } if (isPeak) { yield return(model.RangeInit(sampleLocation, NEIGHBOURS_COUNT)); } } }
public static LocalRange RangeInit(this IProcessorModel <float> model, int peakIndex, int threshold) { var leftIndex = peakIndex - threshold; var rightIndex = peakIndex + threshold; var leftThreshold = FrequencyHelpers.GetFrequency(model.InputSamplesCount, leftIndex, model.SampleRate) * 2; var rightThreshold = FrequencyHelpers.GetFrequency(model.InputSamplesCount, rightIndex, model.SampleRate) * 2; var peak = FrequencyHelpers.GetFrequency(model.InputSamplesCount, peakIndex, model.SampleRate) * 2; return(new LocalRange(GetZoomOptions(leftThreshold, rightThreshold, peak)) { LeftThreshold = leftThreshold, RightThreshold = rightThreshold, Peak = peak }); }
public FFTProcessorViewModel(IProcessorModel <float> model) { this.Model = model; }