- [Class]
cycle
Enumerates data in sequential order, loops back to the first element after the last element has been reached.
See generic pattern initializations for documentation on keyword initializations to the pattern.
Examples:
Example 1. The cycle pattern.
(define pat1 (new cycle :of '(a b c d))) (next pat1 12) ⇒ (a b c d a b c d a b c d) (define pat1 (new cycle :keynums '(c5 d e f g a) :for 12)) (next pat1 #t) ⇒ (72 74 76 77 79 81 72 74 76 77 79 81) (define pat1 (new cycle :of (list (new weighting :of '(a1 a2 a3) :for 1) (new weighting :of '(b1 b2 b3) :for 1) (new weighting :of '(c1 c2 c3) :for 1)))) (next pat1 12) ⇒ (a2 b1 c2 a1 b2 c3 a2 b3 c3 a3 b1 c2)
Example 2. Generate talea and color cycles.
(define (play-tc talea color) ;; cycle over talea and color until both at eop. (process with rhys = (new cycle :rhythms talea) and keys = (new cycle :keynums color) for r = (next rhys) for k = (next keys) output (new midi :time (now) :keynum k :duration (+ r .1)) wait r until (and (eop? rhys) (eop? keys)))) (events (play-tc '(e. s e e s e. s) '(cs4 d6 gs5 b4 g4 fs5)) "test.mid") ⇒"test.mid"
See also:
- Pattern classes [Topic]