 
 (def NUM_BEATS 4)
 (def NUM_BARS 4)
+
+(defn dissoc-in
+  "Dissociates an entry from a nested associative structure returning a new
+  nested structure. keys is a sequence of keys. Any empty maps that result
+  will not be present in the new structure."
+  [m [k & ks :as keys]]
+  (if ks
+    (if-let [nextmap (get m k)]
+      (let [newmap (dissoc-in nextmap ks)]
+        (if (seq newmap)
+          (assoc m k newmap)
+          (dissoc m k)))
+      m)
+    (dissoc m k)))
 
 
 (defn note-matrix [notes n-octaves n-measures n-bars n-beats n-steps-per-beat]

            (draw g
              (rounded-rect x y w h 3 3) 
                (style :stroke 1.0 
                       :background (color 0 255 0 200)
                       :foreground (color 0 150 0))))
                       )
                       )))

                       (>= (- x 1) note-x)
                       (= y note-y)) ;; bounds checking
                       (do
                          (swap! r (fn [_] {note-x {note-y data}}))))
                        )))))
    @r))


