     (pattern-param? val) (get-pattern-param val time)
     ; If value is a lazy sequence, get first one in sequence
     (seq? val) (first val)
-    ; If a keyword was given, this is a sound parameter
+    ; If a keyword was given, this is a sound parameter (as opposed to a synth)
     key (snd/sound-param key val)
     ; Otherwise use the param value as is
     :else val))

  [derefed-pattern]
  (log/debug "Resetting pattern" (:name derefed-pattern) "to original synth and params")
  (assoc derefed-pattern :synth (:orig-synth derefed-pattern) :params (:orig-params derefed-pattern) :reset-flag false))

(defn- set-start-time
  ; Pattern is de-referenced since this function is called by swap!
  [derefed-pattern time]
  (assoc derefed-pattern :params (setup-params (:params derefed-pattern) :start-time time)))


;

  [pattern-key & {:as params}]
  (let [pattern (get-pattern pattern-key)]
    (log/debug "Enqueueing pattern changes for" (:name @pattern) "to:" (print-params params))
    (swap! pattern update :new-params merge params)
    true))

(defn- update-pattern
  [derefed-pattern time]
  (log/debug "Changing pattern" (:name derefed-pattern) "to:" (print-params (:new-params derefed-pattern)))
  ; Set start time in new pattern params in case any are a PatternParam protocol
  (let [new-params (init-pat-params (:new-params derefed-pattern) time)]
    ; Merge in queued param changes and then reset queue to empty
    (-> derefed-pattern
        (update :params merge new-params)
        (assoc :new-params {}))))

(defn- dequeue-param-changes
  ; Pattern is de-referenced since this function is called by swap!
