   (recv "/synced"))
 
 ; size is in samples
-(defn buffer 
+(defn buffer
   "Allocate a new buffer for storing audio data."
   [size]
   (let [id (next-buffer-id)]

  [path]
  (snd "/d_recv" (synthdef-bytes (synthdef-read path))))

(defn reset 
  "Clear all synthesizers, groups and pending messages from the audio server."
  []
  (try

      (Thread/sleep 250))
    (.destroy proc)))

(defn connect-jack-ports
  "Maybe this isn't necessary, since we can use the SC_JACK_DEFAULT_OUTPUTS
  environment variable..."
  [n-channels]
  (let [port-list (sh "jack_lsp")
        sc-outputs (re-find #"SuperCollider.*:out_" port-list)]
  (doseq [i (range n-channels)]
    (sh "jack_connect"
        (str sc-outputs (+ i 1))
        (str "system:playback_" (+ i 1))))))

(def SC-PATHS {:linux "scsynth"
               :windows "C:/Program Files/SuperCollider/scsynth.exe"
               :mac  "/Applications/SuperCollider/scsynth" })

(def SC-ARGS  {:linux []
               :windows []
               :mac   ["-U" "/Applications/SuperCollider/plugins"] })

(def SC-PATH (SC-PATHS (config :os)))
(def SC-ARG (SC-ARGS (config :os)))

(defn boot
  ([] (boot SERVER-HOST SERVER-PORT))
  ([host port]
   (let [port (if (nil? port) (+ (rand-int 50000) 2000) port)
         cmd (into-array String (concat [SC-PATH "-u" (str port)] SC-ARG))
         sc-thread (Thread. #(boot-thread cmd))]
     (.setDaemon sc-thread true)
     (log/info "Booting SuperCollider server (scsynth)...")
