     instrument
     (add-synths-to-instrument instrument)))
 
-(defn filter-type
-  [type touches]
-  (filter (fn [t] (= (t :type) type)) touches))
-
 (defn reduce-val->>
   [f coll val]
   (reduce f val coll))

(defn touches
  [canvas-id type]
  (mapcat< touch-data->touches (util/listen (dom/getElement canvas-id) type)))

;; (defn create-touch-input-channel
;;   [canvas-id]
;;   (async/merge [(touches canvas-id :touchstart)
;;                 (touches canvas-id :touchend)
;;                 (touches canvas-id :touchmove)]))

(defn scroll?
  [scroll-state cur-t]

        (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)]
