Posted April 23Apr 23 a simple small function I had to write for a project: it generates a kind of accelerando towards the value 1(defun gen-acc (alist) (loop while (not (equal alist (gen-repeat (length alist) 1))) collect (setf alist (loop for i in alist when (> i 1) collect (- i 1) else collect i)))) (gen-acc (rnd-order (primes 11))) => ((30 2 6 12 10 18 28 1 4 16 22) (29 1 5 11 9 17 27 1 3 15 21) (28 1 4 10 8 16 26 1 2 14 20) (27 1 3 9 7 15 25 1 1 13 19) (26 1 2 8 6 14 24 1 1 12 18) (25 1 1 7 5 13 23 1 1 11 17) (24 1 1 6 4 12 22 1 1 10 16) (23 1 1 5 3 11 21 1 1 9 15) (22 1 1 4 2 10 20 1 1 8 14) (21 1 1 3 1 9 19 1 1 7 13) (20 1 1 2 1 8 18 1 1 6 12) (19 1 1 1 1 7 17 1 1 5 11) (18 1 1 1 1 6 16 1 1 4 10) (17 1 1 1 1 5 15 1 1 3 9) (16 1 1 1 1 4 14 1 1 2 8) (15 1 1 1 1 3 13 1 1 1 7) (14 1 1 1 1 2 12 1 1 1 6) (13 1 1 1 1 1 11 1 1 1 5) (12 1 1 1 1 1 10 1 1 1 4) (11 1 1 1 1 1 9 1 1 1 3) (10 1 1 1 1 1 8 1 1 1 2) (9 1 1 1 1 1 7 1 1 1 1) (8 1 1 1 1 1 6 1 1 1 1) (7 1 1 1 1 1 5 1 1 1 1) (6 1 1 1 1 1 4 1 1 1 1) (5 1 1 1 1 1 3 1 1 1 1) (4 1 1 1 1 1 2 1 1 1 1) (3 1 1 1 1 1 1 1 1 1 1) (2 1 1 1 1 1 1 1 1 1 1) (1 1 1 1 1 1 1 1 1 1 1)) (length-list-plot (omn-to-time-signature (flatten (gen-length (gen-acc (rnd-order (primes 11))) 1/32)) '(4 4)) :join-points t :style :fill :line-width 0.5) ;; press: cmd1Here are two practical examples in combination with GEN-SORT(progn (setf pitchseq (vector-to-pitch '(fs3 g5) (gen-noise 8))) (make-omn :pitch (setf pitches (flatten (gen-sort pitchseq))) :length (filter-last (length pitches) (gen-length (gen-acc (rnd-sample (length pitchseq) (primes 11))) 1/32)))) (progn (setf pitchseq (vector-to-pitch '(fs3 g5) (gen-noise 11))) (make-omn :pitch (setf pitches (flatten (gen-sort pitchseq))) :length (length-staccato (filter-last (length pitches) (gen-length (gen-acc (rnd-sample (length pitchseq) (primes 11))) 1/32)) :value 1/32)))
Create an account or sign in to comment