Example #1
0
        /// <summary>
        /// Called when buffer is filled. Output frequency is estimated and passed in event args.
        /// </summary>
        protected virtual void OnFrequencyBufferFilled()
        {
            position = 0;
            float estimatedFrequency = 0;

            if (estimation == EstimationType.Median)
            {
                estimatedFrequency = GetMedian();
            }
            if (estimation == EstimationType.Average)
            {
                estimatedFrequency = GetAverage();
            }

            if ((estimatedFrequency - data[0]) > 10)
            {
                return;
            }
            FrequencyBufferFilledEventArgs e = new FrequencyBufferFilledEventArgs
            {
                EstimatedFrequency = estimatedFrequency
            };

            FrequencyBufferFilled?.Invoke(this, e);
        }
Example #2
0
 /// <summary>
 /// Called when frequency buffer is filled.
 /// </summary>
 /// <param name="o"></param>
 /// <param name="e"></param>
 private void OnFrequencyBufferFilled(object o, FrequencyBufferFilledEventArgs e)
 {
     fundamentalFrequency = e.EstimatedFrequency;
     OnFundamentalFrequencyDetected();
 }