 
 (defn synthdef? [obj] (= ::synthdef (type obj)))
 
+(defn ensure-synthdef!
+  [obj]
+  (when-not (synthdef? obj)
+    (throw (IllegalArgumentException. (str "Error, was expecting a synthdef, found: " (type obj))))))
+
 (defn- supercollider-synthdef-path
   "Returns a constructed path to a named synthdef on the current platform"
   [synth-name]

  "Returns the set of control parameter name/default-value pairs for a synth
  definition."
  [sdef]
  (let [names (map #(keyword (:name %1)) (:pnames sdef))
        vals (:params sdef)]
  (apply hash-map (interleave names vals))))

  "Produces a serialized representation of the synth definition understood
  by SuperCollider, and returns it in a byte array."
  [sdef]
  (ensure-synthdef! sdef)
  (spec-write-bytes synthdef-file-spec
    (cond
      (synthdef? sdef) (synthdef-file sdef)
