   (go
    (loop [instrument (update-size (create-instrument (scales/c-minor)) canvas-id)]
      (>! c-instrument instrument)
-     (let [[data c] (alts! [c-touch c-orientation-change])]
+     (let [[data c] (alts! [c-touch c-orientation-change (timeout 16)])]
        (condp = c
          c-orientation-change (recur (update-size instrument canvas-id))
-         c-touch (recur (fire-touch-data-on-instrument instrument data))))))
+         c-touch (recur (fire-touch-data-on-instrument instrument data))
+         (recur (assoc instrument :playhead (.getTime (js/Date.))))))))
   )

  (util/find-first (fn [note] (= freq (-> note :freq)))
                   (-> instrument :notes)))

(defn draw-instrument [draw-ctx instrument]
  (let [{w :w h :h} instrument
        freqs (-> instrument :piano-keys keys)
        piano-key-w (piano-key-width (:piano-keys instrument) w)]
    (.clearRect draw-ctx 0 0 w h)
    (dotimes [n (count freqs)]
      (let [note (latest-note instrument (nth freqs n))
            piano-key-on (and note (-> note :off nil?))]
        (set! (.-fillStyle draw-ctx)
              ((if piano-key-on :light :dark)
               (nth colors (mod n (count colors)))))
        (.fillRect draw-ctx (* n piano-key-w) 0 piano-key-w h)))))

(defn touch->note
  [x w scale]
  (let [note-index (.floor js/Math (/ x (piano-key-width scale w)))]
    (nth scale note-index)))

(defn create-note-synth
  [freq]


(def timbre js/T)

(def colors [{:note "#676767" :light "#6DA0CB" :dark "#000000"}
             {:note "#929292" :light "#A76AB9" :dark "#1E1E1E"}
             {:note "#B9B9B9" :light "#BB67A2" :dark "#3D3D3D"}
             {:note "#DCDCDC" :light "#C55D83" :dark "#5C5C5C"}
             {:note "#FFFFFF" :light "#D35E4C" :dark "#7A7A7A"}
             {:note "#000000" :light "#E18C43" :dark "#999999"}
             {:note "#393939" :light "#E1B040" :dark "#B9B9B9"}])

(defn piano-key-width
  [{piano-keys :piano-keys w :w}]
  (.round js/Math (/ w (count piano-keys))))

(defn latest-note
