 ; Combinators
 
 (defn connect
-  "Use the output of one node as the input to another."
-  [node1 node2]
+  "Use the output of one synth as the input to another."
+  [upstream-synth downstream-synth]
   (fn [context at duration]
-    (let [sink (-> node2 (run-with context at duration))]
-      (-> node1 (run-with context at duration) (.connect sink))
-      sink)))
+    (let [{downstream-input :input downstream-output :output} (-> downstream-synth (run-with context at duration))
+          {upstream-input :input upstream-output :output} (-> upstream-synth (run-with context at duration))]
+      (-> upstream-output (.connect downstream-input))
+      (section upstream-input downstream-output))))
 
 (defn connect->
-  "Connect nodes in series."
+  "Connect synths in series."
   [& nodes]
   (reduce connect nodes))
 
 (defn add
-  "Add together nodes by connecting them all to the same gain."
-  [& nodes]
+  "Add together synths by connecting them all to the same gain."
+  [& synths]
   (fn [context at duration]
-    (let [sink (-> (gain 1.0) (run-with context at duration))]
-      (doseq [node nodes]
-        (-> node (run-with context at duration) (.connect sink)))
-      sink)))
+    (let [{downstream-input :input downstream-output :output} (-> (gain 1.0) (run-with context at duration))]
+      (doseq [synth synths]
+        (let [{:keys [input output]} (-> synth (run-with context at duration))]
+          (-> output (.connect downstream-input))))
+      (section downstream-input downstream-output))))
 
 
 ; Noise

(defn biquad-filter
  ([type freq q]
   (fn [context at duration]
     (doto (-> (biquad-filter type freq) (run-with context at duration))
       (-> .-Q (plug q context at duration)))))
  ([type freq]
   (fn [context at duration]
     (doto (.createBiquadFilter context)
       (-> .-frequency .-value (set! 0))
       (-> .-frequency (plug freq context at duration))
       (-> .-type (set! type))))))

(def low-pass (partial biquad-filter "lowpass"))
(def high-pass (partial biquad-filter "highpass"))

          (+ dx x))
        at
        corners)
      (section audio-node))))

(defn adshr [attack decay sustain hold release]
  (envelope [attack 1.0] [decay sustain] [hold sustain] [release 0]))
