                 (for [i instruments]
                   (let [i-vals (or (get init-vals (:name i))
                                    (vec (repeat steps false)))]
-                    {:inst i
+                    {:inst  i
+                     :param (-> i :params first :name)
                      :value i-vals})))
    })
 
+(def ^{:private true} NEW_ENTRY {:on true})
+
 (defn- toggle-playing [state]
   (update-in state [:playing?] not))
 
-(defn- toggle-entry [state row col]
-  (update-in state [:rows row :value col] not))
+(defn- get-entry [state row col]
+  (get-in state [:rows row :value col]))
 
 (defn- set-entry [state row col v]
   (if (< row (count (:rows state)))
     (assoc-in state [:rows row :value col] v)
     state))
 
-(defn- get-entry [state row col]
-  (get-in state [:rows row :value col]))
+(defn- update-entry [state row col v]
+  (if (< row (count (:rows state)))
+    (update-in state [:rows row :value col] merge NEW_ENTRY v)
+    state))
+
+(defn- mute-entry [state row col]
+  (update-in state [:rows row :value col]
+             (fn [v]
+               (if (associative? v)
+                 (assoc-in v [:on] false)
+                 v))))
+
+(defn- toggle-entry [state row col]
+  (update-in state [:rows row :value col]
+             (fn [v]
+               (if (associative? v)
+                 (update-in v [:on] not)
+                 NEW_ENTRY))))
+
+(defn- delete-entry [state row col]
+  (set-entry state row col false))
+
+(defn- get-row-param
+  [state row]
+  (get-in state [:rows row :param]))
+
+(defn- get-param-info
+  [state row]
+  (let [p-name (get-row-param state row)]
+    (first (filter #(= (:name %) p-name)
+                 (get-in state [:rows row :inst :params])))))
 
 (defn- clear-row [state row]
   (assoc-in state [:rows row :value] (vec (repeat (:steps state) false))))
+
+(defn- play-step
+  [row index]
+  (let [{:keys [inst value]} row
+        step-val (nth value index)]
+
+    (when (:on step-val)
+      (apply inst (-> step-val
+                      (dissoc :on)
+                      seq
+                      flatten)))))
 
 (defn- step-player
   [state-atom beat]

      (let [metro (:metronome state)
            steps (:steps state)
            index (mod beat steps)
            next-beat (inc beat) ]
        (swap! state-atom assoc-in [:step] index)
        (doseq [{:keys [inst value]} (:rows state)]
          (when (nth value index)
            (at (metro beat) (inst))))
        (apply-at (metro next-beat) #'step-player
                  [state-atom next-beat])))))


                                        :separator
                                        controls-btn])
          grid         (step-grid state-atom)
          inst-panels  (map (partial inst-panel state-atom)
                            instruments)
          f (frame :title    "Sequencer"
                   :content  (border-panel
                               :border 5 :hgap 5 :vgap 5
                               :north control-pane
                               :west (grid-panel :columns 1
                                                 :items inst-panels)
                               :center grid)
                   :on-close :dispose)]

      (bind/bind bpm-spinner (bind/b-do [v] (metro :bpm v)))
      (bind/bind state-atom (bind/b-do [v] (repaint! grid)))

