 
 (defn await-promise
   "Read the reply received from the server, waiting for timeout ms if the message hasn't yet been received. Returns :timeout if a timeout occurs."
-    ([prom] (await-promise prom REPLY-TIMEOUT))
-    ([prom timeout]
-       (try
-         (.get (future @prom) timeout TimeUnit/MILLISECONDS)
-         (catch TimeoutException t
-           :timeout))))
+  ([prom] (await-promise prom REPLY-TIMEOUT))
+  ([prom timeout]
+     (try
+       (.get (future @prom) timeout TimeUnit/MILLISECONDS)
+       (catch TimeoutException t
+         :timeout))))
 
 (defn await-promise!
   "Read the reply received from the server, waiting for timeout ms if the message hasn't yet been received. Raises an exception if the message hasn't been received within timeout ms"
-    ([prom] (await-promise prom REPLY-TIMEOUT))
-    ([prom timeout]
-       (.get (future @prom) timeout TimeUnit/MILLISECONDS)))
+  ([prom] (await-promise prom REPLY-TIMEOUT))
+  ([prom timeout]
+     (.get (future @prom) timeout TimeUnit/MILLISECONDS)))
 
 (defn- parse-status [args]
   (let [[_ ugens synths groups loaded avg peak nominal actual] args]

(ns
  ^{:doc "An interface to the SuperCollider synthesis server.
          This is at heart an OSC client library for the SuperCollider
          scsynth DSP engine."
     :author "Jeff Rose"}
  overtone.sc.core
  (:import
    [java.net InetSocketAddress]
    [java.util.regex Pattern]
    [java.util.concurrent TimeUnit TimeoutException]
    [java.io BufferedInputStream]
    [supercollider ScSynth ScSynthStartedListener MessageReceivedListener])
  (:require [overtone.log :as log])
  (:use
    [overtone event config setup util time-utils deps]
    [overtone.sc allocator]
    [clojure.contrib.java-utils :only [file]]
    [clojure.contrib pprint]
    [clojure.contrib shell-out]
    osc))

(def SERVER-HOST "127.0.0.1")
(def SERVER-PORT nil) ; nil means a random port
(def N-RETRIES 20)

; Max number of milliseconds to wait for a reply from the server
(def REPLY-TIMEOUT 500)

(def MAX-OSC-SAMPLES 8192)

(defn- boot-internal
  ([] (boot-internal (+ (rand-int 50000) 2000)))
  ([port]
     (log/info "boot-internal: " port)
     (when (not (connected?))
       (on-deps :booted ::connect-internal connect)
       (let [sc-thread (Thread. #(internal-booter port))]
         (.setDaemon sc-thread true)
         (log/debug "Booting SuperCollider internal server (scsynth)...")
         (.start sc-thread)
         (dosync (ref-set server-thread* sc-thread))
         :booting))))

(defn- sc-log
  "Pull audio server log data from a pipe and store for later printing."
