;;; CRES.CAL
;;;
;;; This CAL routine causes a crescendo (or decrescendo) by
;;; scaling note velocities.  The user enters the beginning
;;; and ending percentages and these correspond to FROM and
;;; THRU times.  Note events that occur in between FROM and
;;; THRU are scaled by the appropriate ratio.
;;;


;;; Prolog
(do
   (int frompct 100)
   (int thrupct 100)
   (int diffpct)
   (int nowpct)
   (dword length)
   (dword ofs)

   (getInt frompct "FROM percentage?" 1 1000)
   (getInt thrupct "THRU percentage?" 1 1000)
   (= length (- Thru From))
   (= diffpct (- thrupct frompct))
)
;;; Body
(if (== Event.Kind NOTE)
   (do
      (= ofs (- Event.Time From))   ;;; number of ticks from From
      (*= ofs 100)
      (/= ofs length)               ;;; percent of distance 
      (= nowpct (* ofs diffpct))    ;;; percent at now
      (/= nowpct 100)
      (+= nowpct frompct)
      (*= Note.Vel nowpct)
      (/= Note.Vel 100)
   )
   NIL
)

;;; Epilog
NIL







