- [Class]
heap
Generates random permutations of its elements (sampling without replacement).
heap
supports the following slot initializations:
:state
random-state- Sets the random state object of the pattern to random-state. Defaults to *random-state*.
See generic pattern initializations for documentation on additional keyword initializations to the pattern.
Examples:
Example 1. The heap pattern.
(define pat1 (new heap :keynums '(a4 b c5 d))) (next pat1 #t) ⇒ (69 72 74 71) (next pat1 #t) ⇒ (72 74 71 69) (next pat1 #t) ⇒ (72 71 69 74) (next pat1 #t) ⇒ (71 69 74 72)
Example 2. Two levels of heaps.
(define pat1 (new heap :of (list (new cycle :notes '(c4 cs d ef e f)) (new cycle :of (list (new heap :notes '(c3 cs d ef)) (new heap :notes '(e3 f fs g)) (new heap :notes '(gs3 a as b)))) (new cycle :notes '(fs2 g gs a as b))))) (define (play-pat reps pat rate) (process repeat reps for k = (next pat) output (new midi :time (now) :keynum k :duration (* rate 1.5)) wait rate)) (events (play-pat 120 pat1 .1) "test.mid") ⇒ "test.mid"
See also:
- Pattern classes [Topic]