[Class]
funcall

Calls a function each time a new period of items is needed. The function is passed no arguments and must return the list of elements representing the next period in the pattern, or false if there are no more elements.

See generic pattern initializations for documentation on keyword initializations to the pattern.

Examples:

Example 1. Generating random rhythms followed by their retrograde.

(define (non-retro pat)
  (new funcall :of (lambda ()
                     (let ((per (next pat #t)))
                       (append per (reverse per))))))

(define messiaen
  (non-retro (new heap :of '(s e e. q q+s e.)
                 :for (new random :of '(3 4 5 )))))

(next messiaen #t)
 (q+s e s e. e. s e q+s)
(next messiaen #t)
 (e. q e e. e. e q e.)
(next messiaen #t)
 (s q+s q q q+s s)

Example 2. Generating P I R and RI of a row.

(let ((alban '(0 3 7 11 14 17 21 25 28 30 32 34)))
  (define albans
    (new heap
         :of (list (new funcall :of (lambda () alban))
                   (new funcall :of (lambda () (invert alban)))
                   (new funcall :of (lambda () (reverse alban)))
                   (new funcall :of (lambda () 
                                      (reverse (invert alban))))))))

(define transp (new funcall :of (lambda () (between 55 68))))

(define (play-rows reps rows keys rate)
  (process with key
           for i below reps
           when (= (mod i 12) 0)
           set key = (next keys)
           output (new midi :time (now) 
                       :keynum (transpose (next rows) key)
                       :duration (* rate 1.5))
           wait rate))

(events (play-rows 120 albans transp .1) "test.mid")
 "test.mid"

See Also: