예제 #1
0
        /// <summary>
        /// Called when audio samples buffer is filled. Starts main calculation chain.
        /// </summary>
        /// <param name="o"></param>
        /// <param name="e"></param>
        private void OnBufferFilled(object o, BufferFilledEventArgs e)
        {
            //if (e.Volume < -50f) return;
            autocorrelator.CalculateAutocorrelation();
            int maxLag = autocorrelator.MaxValueLag;

            if (maxLag == autocorrelator.MinLag)
            {
                return;
            }
            float interpolatedVal = interpolator.Interpolate(maxLag, autocorrelator.Output);
            float frequency       = sampleRate / interpolatedVal;

            frequencyBuffer.AddFrequency(frequency);
        }
예제 #2
0
        /// <summary>
        /// Raised when buffer is filled. Also volume in dB is calculated and passed in EventArgs.
        /// </summary>
        protected virtual void OnBufferFilled()
        {
            float vol = 20 * (float)Math.Log10(currentMax);

            if (float.IsInfinity(vol) || float.IsNaN(vol))
            {
                vol = -90;
            }
            BufferFilledEventArgs e = new BufferFilledEventArgs
            {
                Volume = vol
            };

            position   = 0;
            currentMax = 0;
            BufferFilled?.Invoke(this, e);
        }
예제 #3
0
 private void OnBufferFilled(object o, BufferFilledEventArgs e)
 {
     view.ChangeVolumeLevel(e.Volume + 90);
 }