 (ns sc-three
   (:use [overtone.live]))
+
+;; Helpers
 
 ;; This is the default synth. Is it accessible from Overtone?
 (comment

  (def t (atom 1))

  (defn go1 []
   (loop []
     (when (not (nil? @x)) (release @x 0.1))
     (when @cont
       (reset! x (s :freq (midi->hz 61) :amp 0.2))
       (Thread/sleep (/ 200 @t))
       (release @x 0.1)
       (reset! x (s :freq (midi->hz 67) :amp 0.2))
       (Thread/sleep (/ (ranged-rand 75 250) @t))
       (recur))))

  (defn go2 []
    (reset! y (s :freq (midi->hz 73) :amp 0.3)))

  (defn go3 []
    (when (not (nil? @y)) (release @y 0.1))
    (reset! y (s :freq (midi->hz 79) :amp 0.3))
    (reset! t 2))

  (defn go4 []
    (when (not (nil? @y)) (release @y 0.1))
    (reset! cont false))
)

(go1)
(go2)
(go3)
(go4)

  )
)

(def go
  (let [y (atom nil)]
   (generator
    (fn []
      (let [x (s :freq (midi->hz 76))]
        (after-delay
         1000
         #(do
            (release x 0.1)
            (reset! y (s :freq (midi->hz 73)))))))
    (fn []
      (wait-release y 0.1)
      (let [z (s :freq (midi->hz 69))]
        (after-delay
         2000
         #(release z)))))))
(go)
(go)

