Sat May 4 13:12:46 EDT 2013


How to implement event triggering?  There are only signals, no events,
so this needs either direct state modification or some workaround.

Instead of working with pulses, it might be simpler to work with
transitions, since those are easier to define as a primitive.  After
that a positive/negative edge can be generated.

Really, a simple differentiator should do the trick.

        y = x (1 - z^{-1})

Note that problems like this are created by requiring that state
access is not allowed.

This is really hard to express without vectored conditional
assignment.  Currently that is not supported.  I want this:

(define (env-AD (level setpoint rate prev-gate) (gate attack decay))
        (+ level (* rate (- setpoint level))))
        (< prev-gate gate  (vector attack 1)   ;; 0->1  start new cycle
        (< 0.9 level       (vector decay  0)   ;; attack done, start decay
                           (vector rate   setpoint)))) ;; keep coefs
        (unvector next-params)))
    (values next-level
            ;; out.  1 sample delayed to pipeline computations

Maybe ai-array prims should automatically lift?  Still, in this case
it would compute the conditionals multiple times.

Not ready yet!