               state (atom {:beat/at 0
                            :beat/power 0.0
                            :freq/at 0
-                           :freq/spectrum []})]
+                           :freq/spectrum (vec (repeat history-size [0.0]))
+                           :freq/pos 0})]
           (component/system-map
             :state state
             :input (audio/audio-input channel 100)

  []
  (quil/background 0)
  (when-let [audio (some-> system :state deref)]
    (let [spectrum (:freq/spectrum audio)
          band-height (/ (- (quil/height) 40) (inc (count spectrum)))]
      (doseq [i (range (count spectrum))]
        (quil/with-translation [20 (+ 20 (* i band-height))]
          (let [power (nth spectrum i)]
            (quil/fill (color/rgb 0 0 1))
            (quil/rect 20 5 (* power 10) (- band-height 10))
            (quil/fill (color/gray 0.8))
            (quil/text (str i) 0 5) ; TODO: frequency?
            (quil/text (format "%4.1f" power) 25 5)))))
    (let [beat-elapsed (- (System/currentTimeMillis) (:beat/at audio))
          decay-r 0.2
          saturation (/ (Math/pow (+ 1.0 decay-r) (/ beat-elapsed 100.0)))]
      (quil/with-translation [(- (quil/width) 30) (- (quil/height) 30)]
        (quil/fill (color/rgb saturation 0 0))
        (quil/ellipse 0 0 20 20)
        (quil/fill (color/gray 0.8))
        (quil/text (format "%4.1f" (:beat/power audio)) -30 5)))))


(defn init!

    [org.playasophy.wonderdome.input.audio :as audio]
    [org.playasophy.wonderdome.util.color :as color]
    [quil.core :as quil]))


(def ^:constant ^:private history-size 100)


(def system nil)
