   "Handles MIDI communication, including syncing a show metronome to MIDI clock pulses."
   (:require [afterglow.rhythm :as rhythm]
             [amalloy.ring-buffer :refer [ring-buffer]]
+            [clojure.math.numeric-tower :as math]
             [overtone.at-at :refer [now]]
             [overtone.midi :as midi]
             [taoensso.timbre :as timbre])


       1 (fn [^afterglow.rhythm.Metronome metronome]
           (let [sync-handler (ClockSync. metronome (first result) (ref (ring-buffer max-clock-intervals))
                                          (ref {:master (get-in @clock-sources [(first result) :master])}))]
             (sync-start sync-handler)
             sync-handler))


(def ^:private max-clock-intervals
  "How many MIDI clock pulses should be kept around for averaging?"
  30)

(def ^:private max-tempo-taps
  "How many tempo taps should be kept around for averaging?"
