예제 #1
0
        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));
                }
            }
        }
예제 #2
0
        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
            });
        }
예제 #3
0
 public FFTProcessorViewModel(IProcessorModel <float> model)
 {
     this.Model = model;
 }