;;; -*- logo -*-
;; This is offered as part of the sound API.
;;
;; copyright University of Victoria, 2005


;;Settime is meant to be used with the sound, harmony, tonewt, soundwt
;;and harmonywt procedures.  It scales the times in the arguments
;;defining the envelope to something relative to the base time argument.
;;
;;For instance, and argument of [[.9 50] [0 950]] and a base time
;;argument of 500 would output [[.9 25] [0 425]].  While this certainly
;;changes the dynamics of the envelope, it can be used to take arbitrary
;;envelopes and make them work together in some beat sequence.  Let the
;;ear decide!

to settime :env :base
  make "duration calculateduration env
  output map [list first ? int ((last ?) * base/duration) ] env
end


to calculateduration :xxs
  ifelse (empty? xxs) [ output 0  ] [
    output (last (first xxs)) + calculateduration butfirst xxs d
  ]
end



