 (def saw (partial oscillator "sawtooth"))
 (def square (partial oscillator "square"))
 
-(defn modulator [freq duration]
-  (fn [at context]
-    (let [modulatee (saw freq duration)
-          carrier (>> (sin-osc 2 duration) (gain freq))]
-      ((connect carrier (.-frequency modulatee)) at context)
-      modulatee)))
-
 (defn biquad-filter [type freq]
   (fn [at context]
     (doto (.createBiquadFilter context)
-      (-> .-frequency .-value (set! freq))
+      (-> .-frequency (plug freq at context))
       (-> .-type (set! type)))))
 
 (def lpf (partial biquad-filter "lowpass"))

(ns klangmeister.instruments)

(defn gain [level]
  (fn [at context]
    (doto (.createGain context)
      (-> .-gain (.setValueAtTime level at)))))


(defn line
  "Build a line out of [x y] coordinates, starting at [0 0]."
  [& corners]
  (fn [at context]
    (let [node (.createGain context)


(defn blend [ugen1 ugen2]
  (fn [at context]
    (doto ((gain 1.0) at context)
      (-> .-gain (plug ugen1 at context))
      (-> .-gain (plug ugen2 at context)))))

(defn >< [& nodes]
  (reduce blend nodes))
