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

Kjetil S. Matheussen k.s.matheussen@notam02.no
Tue, 28 Oct 2003 13:26:22 +0100 (MET)

```On Tue, 28 Oct 2003, Bill Schottstaedt wrote:

>  > What I need is a general formula for the scale-factor 's'
>  > between two points (x1,y1) and (x2,y2), where y1 and y2 are
>  > always positive values.
>
> I think you want the average of the inverse; the "tempo map"
> idea here would be to integrate the inverse of the envelope,
> then multiply that by the in-coming note length.  But for
> each segment, I think this would do it:
>
> (define (invert-average x1 y1 x2 y2)
>    (/ (- x2 x1) (* .5 (+ y1 y2))))
>
> (Didn't actually test this...)

This is more or less exactly what I do now, and which does not
work.

Lets say I have the following graphs:

(define a '(1 1 0 5))
(define b '(1 1 0.5 0.5))
(define c '(0.5 0.5 0 0))

The following should be true:

(= (invert-average a) (+ (invert-average b) (invert-average c)))

But its not.

I think an integral function of some sort is needed instead.

--

```