     {:piano-keys (into (sorted-map) (map-indexed (fn [i freq] [freq {:n i :on? false}])
                                                  scale))
      :notes ()
-     :w 0 :h 0 :sound-ready false
+     :w 0 :h 0
+     :sound-ready false
      :px-per-ms 0.1
-     ;; :cur-touches {}
-     :scrolling? false
+     :scrolling-touch-id nil
      :start start
      :playhead start}))
 

        (fn []
          (-> "sin" timbre .play .pause)
          (set! (.-ontouchstart js/document) nil))))


(defn piano-key-width
  [{piano-keys :piano-keys w :w}]

        (assoc :notes (map (fn [n] (if (note-off? n) (assoc n :off playhead) n)) notes))
        (->> (reduce-val->> stop-piano-key (->> notes (filter note-off?) (map :freq)))))))

(defn distance
  [{x1 :x y1 :y} {x2 :x y2 :y}]
  (.sqrt js/Math (+ (.pow js/Math (- x2 x1) 2) (.pow js/Math (- y2 y1) 2))))

(defn scroll
  [touch {playhead :playhead px-per-ms :px-per-ms :as instrument}]
  (-> instrument
      (assoc :scroll-touch-id (touch :touch-id))
      (assoc :playhead (+ playhead (/ (touch :y-distance) px-per-ms)))))

(defn stop-scroll
  [touch instrument]
  (if (= (touch :touch-id) (instrument :scroll-touch-id))
    (assoc instrument :scroll-touch-id nil)
    instrument))

(defn fire-touch-on-instrument
  [touch instrument]
  (condp = (touch :type)
    "touchstart" (start-note touch instrument)
    "touchmove" (scroll touch instrument)
    "touchend" (->> instrument
                    (end-notes touch)
                    (stop-scroll touch))))

(defn update-size [instrument canvas-id]
  (let [{w :w h :h :as window-size} (util/get-window-size)]
