              (list 'out 0 body))]
     `(let [s# (synth "audition-synth" ~b2)
            note# (s#)]
-       (at-at/at (+ (at-at/now) ~demo-time) #(node-free note#))
+       (after-delay ~demo-time #(node-free note#))
        note#)))
 
 (defn active-synths


(def ^{:dynamic true} *demo-time* 2000)

(defmacro demo
  "Try out an anonymous synth definition.  Useful for experimentation.  If the
  root node is not an out ugen, then it will add one automatically.
  You can specify a timeout in seconds as the first argument otherwise it
  defaults to *demo-time* ms.

  (demo (sin-osc 440))      ;=> plays a sine wave for *demo-time* ms
  (demo 0.5 (sin-osc 440))  ;=> plays a sine wave for half a second"
  [& body]
  (let [[demo-time body] (if (number? (first body))
                           [(* 1000 (first body)) (second body)]

  overtone.sc.synth
  (:use [overtone.util lib old-contrib]
        [overtone.libs event]
        [overtone.music time]
        [overtone.sc.machinery.ugen fn-gen defaults common specs sc-ugen]
        [overtone.sc.machinery synthdef]
        [overtone.sc server node buffer])
