# [CM] Finding the duration of a time-varying resampled sound.

**Kjetil S. Matheussen
**
k.s.matheussen@notam02.no

*Tue, 28 Oct 2003 16:14:03 +0100 (MET)*

On Tue, 28 Oct 2003, Bill Schottstaedt wrote:
>* > (define a '(1 1 0 5))
*>* > (define b '(1 1 0.5 0.5))
*>* > (define c '(0.5 0.5 0 0))
*>*
*>* These envelopes don't make any sense -- the x axis is
*>* going backwards?
*>*
*
Oops, it should be (0 1 1 0), (0 1 0.5 0.5) and (0.5 0.5 1 0)
To use your final ( ;) ) average-inverse function:
(define (average-inverse x1 y1 x2 y2)
(* (* .5 (+ (/ 1.0 y1) (/ 1.0 y2))) (- x2 x1)))
And define the following:
(define a '(0 1 1 0.5))
(define b '(0 1 0.5 0.75))
(define c '(0.5 0.75 1 0.5))
(define i average-inverse)
(apply i a) gives 1.5
while (+ (apply i b) (apply i c)) gives 1.41666666666667
Since both envelopes are straight lines going
from (0 1) to (1 0.5), the two numbers
should have been equal. So that proves
that just finding the average inverse factor
is not enough.
I think its only a matter of doing a straight integral
calculation of some sort, but I just cant figure out
how.
--