       (let [elapsed (or (:elapsed event) 0.0)]
         (cond->
           (assoc this
-               :bands (mapv (fn [p] (* p (ctl/bound [0.0 1.0] (- 1.0 (* falloff elapsed))))) bands)
+               :bands (mapv #(apply-decay % elapsed decay) bands)
                :rotation (sphere/wrap-angle (+ rotation (* elapsed (/ rotation-rate 1000))))
                :color-shift (ctl/wrap [0.0 1.0] (+ color-shift (* elapsed (/ shift-rate 1000)))))
           (compare-and-set! log-next? true false)

    (let [[_ polar azimuth] (:sphere pixel)
          [i1 i2 p] (azimuth->bands (count bands) (+ azimuth rotation))
          hue-index (/ (+ i1 p) (count bands))
          energy (+ (* (nth bands i1) (- 1 p))
                    (* (nth bands i2) p))
          polar-max (* 1/6 tau)
          transition-point (* polar-max (- 1 (Math/exp (- energy))))
          transition-width (/ tau 16)
          brightness (cond
                       (< polar (- transition-point transition-width))
                         1.0

;;
;; As a stretch goal, if beats are detected, color the first few pixels of the
;; strips (up to a max) a totally different color which fades back to zero.

(def power-factor 9/10)
(def power-decay 1/200)


(defrecord FrequencyBand
  [gain    ; Multiplier for the energy input to this band
   energy  ; Smoothed recent energy levels after applying gain
   power   ; Power output integral over a longer time period (no gain)
   ])


(defn- apply-decay
  "Updats a frequency band to indicate time has passed and decayed the value."
  [band elapsed decay]
  (-> band
      (update :energy * (ctl/bound [0.0 1.0] (- 1.0 (* 1/1000 decay elapsed))))
      (update :power  * (ctl/bound [0.0 1.0] (- 1.0 (* power-decay elapsed))))))


(defn- update-energy
  "Updates a frequency band with a new input energy sample."
  [band energy smoothing]
  (assoc band
         :energy (+ (* smoothing (or (:energy band) 0.0))
                    (* (- 1 smoothing)
                       (or (:gain band) 0.0)
                       (or energy 0.0)))
         :power (+ (* power-factor (or (:power band) 0.0))
                   (* (- 1 power-factor) (or energy 0.0)))))


(defn- azimuth->bands
