コード例 #1
0
        private void DetectBeat()
        {
            DateTime now    = DateTime.Now;
            double   millis = now.Subtract(lastBeat).TotalMilliseconds;

            if (millis > BeatMinSpacingMillis)
            {
                BeatDetected?.Invoke(this, null);

                float bpm = (float)(60 / millis * 1000);

                bpmBuffer.Add(bpm);

                float avgBpm = 0;

                for (int i = 0; i < bpmBuffer.Count; i++)
                {
                    avgBpm += bpmBuffer[i];
                }

                avgBpm /= bpmBuffer.Count;

                BpmDetected?.Invoke(this, new BpmEventArgs(bpm, avgBpm));

                lastBeat = now;
            }
        }
コード例 #2
0
 protected virtual void OnBeatDetected(TimeSpan e)
 {
     BeatDetected?.Invoke(this, e);
 }
コード例 #3
0
 protected void OnBeatDetected()
 {
     BeatDetected?.Invoke(this, new BeatDetectedEventArgs());
 }