 
 (defn create-instrument
   [scale]
-  {:notes (apply sorted-map
+  {:piano-keys (apply sorted-map
                  (flatten (map vector
                                scale
-                               (map (fn [x] {:synth (create-note-synth x) :touch-id nil})
+                               (map (fn [x] {:synth (create-note-synth x) :notes []})
                                     scale))))
    :w 0
    :h 0})

  (scales/quantize (get touch :clientX)
                   0
                   (:w instrument)
                   (keys (:notes instrument))))

(def instrument-fns
  {"touchstart" (fn
                  [instrument {touch-id :touch-id :as event}]
                  (let [freq (touch->freq instrument event)
                        note (get (:notes instrument) freq)]
                    (if (not (:touch-id note))
                      (do
                        (.play (.bang (:synth note)))
                        (assoc-in instrument [:notes freq :touch-id] touch-id)))))
   "touchend" (fn
                [{notes :notes :as instrument} {touch-id :touch-id :as event}]
                (if-let [freq (first (filter (fn [x] (= touch-id (:touch-id (get notes x))))
                                             (keys notes)))]
                    (do
                      (.release (:synth (get notes freq)))
                      (assoc-in instrument [:notes freq :touch-id] nil))))})

(defn fire-event-on-instrument
  [instrument event]

               (center-dimension w-window w-text)
               (center-dimension h-window h-text))))
  (let [{w :w h :h} instrument
        freqs (keys (:piano-keys instrument))
        note-count (count freqs)
        note-width (/ w note-count)]
    (.clearRect draw-ctx 0 0 w h)
    (dotimes [n note-count]
      (let [note (first (:notes (get (:piano-keys instrument) (nth freqs n))))
            note-on (and note (nil? (:off note)))]
        (set! (.-fillStyle draw-ctx)
              ((if note-on :dark :light)
               (nth colors (mod n (count colors)))))
        (.fillRect draw-ctx (* n note-width) 0 note-width h)))))

(defn create-note-synth
  [freq]
