 
 (defn envelope
   "Create an envelope curve description array suitable for the EnvGen ugen."
+  ;;See prAsArray in supercollider/SCClassLibrary/Common/Audio/Env.sc
   [levels durations & [curve release-node loop-node]]
   (let [curve (or curve :linear)
         reln  (or release-node -99)
         loopn (or loop-node -99)
-        shapes (curve-to-shapes curve)
-        curves (curve-to-curves curve)]
+        shapes (shape->id curve)
+        curves (curve-value curve)]
     (apply vector
            (concat [(first levels) (count durations) reln loopn]
                    (interleave (rest levels) durations shapes curves)))))

   :cubed       7
   })

(defn- curve-to-shapes
  "Create the shapes list corresponding to either a curve type or a set of curve types."
  [c]
  (cond
    (keyword? c) (repeat (c ENV-CURVES))
    (or
      (seq? c)
      (number? c))  (repeat 5)))

(defn- curve-to-curves
  "Create the curves list for this curve type."
  [c]
  (repeat (if (number? c) c 0)))

;; Envelope specs describe a series of segments of a line, which can be used to automate
;; control values in synths.

  (:use [overtone util]
        [overtone.sc ugen]))

(def ENV-SHAPES
  {:step        0
   :lin         1
   :linear      1
