Stephane Boussuge Posted January 11 Posted January 11 Hi folks, here's a function I find useful for my work and sharing it here. This is an anti oscillation function to remove aba type patterns when working on algorithmically generated material. (defun anti-oscil (lst) "Supprime les éléments formant des oscillations de type x _ x dans LST. Exemple : (anti-oscil '(a b a a c)) => (a b c)" (labels ((rec (remaining result) (if (null remaining) ;; Plus rien à traiter, on renvoie le résultat tel quel result (let ((x (car remaining))) (if (and (>= (length result) 2) (equal x (nth (- (length result) 2) result))) ;; x forme une oscillation x _ x : on l'ignore (rec (cdr remaining) result) ;; Sinon, on l'ajoute à la fin du résultat (rec (cdr remaining) (append result (list x)))))))) ;; On démarre la récursion avec la liste complète et un résultat vide (rec lst '()))) #| Usage examples (filter-repeat 1 (anti-oscil (vector-to-pitch '(c3 c5) (vector-smooth 0.2 (gen-noise 128 :seed 42))) )) (tonality-map '(messiaen-mode2 :map 'step) (filter-repeat 1 (anti-oscil (vector-to-pitch '(0 20) (vector-smooth 0.2 (gen-noise 128))) ))) |# jesele and jon 2 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.