[Function]
(vary value pct [fit] [state])

Returns a random number that deviates from value by up to pct percentage. The optional fit parameter determines how the variance will be applied to value: :above returns a percentage variance with value at the minimum, :below returns a percentage variance with value at the maximum and :around returns a percentage variance with value in the middle. The default value is :around.

Examples:

Example 1. The vary function.

(vary 100 .05 )
 98.2
(vary 100 .05 )
 102.34006
(vary 100 .05 ':above)
 103.237
(vary 100 .05 ':below)
 96.933

Example 2. Varied pulse rate.

(define (play-vary len lb ub rate env)
  (process for i below len
           for r = (vary rate (interpl (/ i len) env))
           for k = (between lb ub k)
           output (new midi :time (now)
                      :keynum k 
                      :duration (* r 1.5))
           wait r))

(define varyenv '(0 0 .1 0 .5 .75 .9 0 1 0))

(events (play-vary 60 70 90 .2 varyenv) "test.mid")
 "test.mid"

See also: