 
 ;; handles note on/off, key pressure, cc, program change, channel pressure, pitch bend messages
 (defn parse-note [notes state]
-  (if (empty? notes)
+  (if (or (empty? notes)
+          (not (or (= (type (first notes)) MidiMessage)
+                   (symbol? (first notes)))))
     state
     (if (= (type (first notes)) MidiMessage)
       (merge state {:key (first notes) :notes (vec-rest notes)})

                          :else
                          (throw (Exception. (format "Could not parse key: %s" key))))
                        (merge state {:position
                                      (if (vector? (:notes state))
                                        (:position state)
                                        (+ (:position state) (or (:repeat-length state) (:length state))))})))
              notes (:notes state)]

      state)))

(defn parse-length [notes state]
  (if (or (empty? notes)
          (not (or (ratio? (first notes))
                   (symbol? (first notes)))))
    state
    (let [length (first notes)
          ppq (.getResolution (.getSequence (:sequencer state)))]
      (cond
        (ratio? length)
        (merge state {:key (if (< length 0) nil (:key state))
                      :length (Math/abs (* 4.0 length ppq))
                      :repeat-length nil
