   (:require midi))
 
 ;; helpers
-(declare color->velocity coord->note)
+(declare color->velocity coord->note -update!)
 
 (defprotocol Protocol
   (reset 


;; helpers
(defn color->velocity
  ;; convert the (red,green) pair to the appropriate MIDI velocity
  [[red green]]
  (bit-or red
          0xC
          (bit-shift-left green 4)))

(defn coord->note [[x y]]
  ;; convert the (x,y) coordinate to the appropriate MIDI note
  (+ x
     (* 0x10 y)))

;; In all of the above, the value is a color (2-element vector of red and green
;; values, ranging from 0 to 3)
(defrecord State [grid top right])

(def initial-state
  "The quintessentially quiescent Launchpad."
  (let [octet (vec (repeat 8 [0 0]))]
    (State. (vec (repeat 8 octet))
            octet
            octet)))

;; combine the state, the midi device, and the actions on them
(defrecord Launchpad [^clojure.lang.Atom state device]
  Protocol
  (grid [this [x y] [red green]]
    (-update! this (assoc-in @(.state this)
