Jump to content


Popular Content

Showing content with the highest reputation since 11/19/2017 in Blog Entries

  1. 1 point
    A simple example based on an All Interval Row for pitch material and euclidean rhythm for Flute rhythmic generation. ;; All interval row generation (setf row (air 16 :prime :type :pitch)) ;;; Strings chords ;; Chords gen from Air (setf chords1 (harmonic-progression '(0 0 0 0 2 2 2 2) row :size 4 :step '(1 2 2 1) ;; step throught row :relative t ;; chords relative path voice leading :seed 8392 )) ;; Strings chords assembly with pitches from chords1 ;; and length generation (whole notes '(w) repeated 32 times) ;; dynamic = pp (setf chords1.omn (filter-tie ;; tie repeated notes (make-omn :length (gen-repeat 32 '((w))) :pitch chords1 :velocity '((pp)) ))) ;;; Melody generation for Flute ;; Get the length (size) of chords1.omn (setf size (length chords1.omn)) ;; Pitch material (setf melo1.pmat (rnd-order (melodize (gen-trim size (mclist (harmonic-progression '(0 0 0 0 2 2 2 2) row :size 5 :step '(1 2 2 1) )))))) ;; Melodic generation with euclidean rhythm (setf melo1.omn (pitch-transpose 12 (make-omn :pitch melo1.pmat :length (euclidean-rhythm (gen-repeat size '(16)) 1 12 's :type 2 ) :velocity '((mf)) ))) (def-score temp ( :key-signature 'chromatic :time-signature '(4 4) :composer "Stéphane Boussuge" :copyright "Copyright © 2017 s.boussuge" :tempo 64 ) (strings1 :omn chords1.omn :channel 1 :port 0 :sound 'gm :program 'acoustic-grand-piano :controllers (1 (gen-dynamic-controller chords1.omn)) ) (flute1 :omn melo1.omn :channel 2 :port 0 :sound 'gm :program 'acoustic-grand-piano :controllers (1 (gen-dynamic-controller melo1.omn)) ) ) SB. AudioOutput.mp3
  2. 1 point
    Patterns finding and replacement can be very useful when composing. For example, we may want to replace some unwanted motive in a melody, or we may want to generate articulation or velocity based on some patterns of length or pitch. Another use is to compose a new section based on and old one with patterns replacement from old to new etc, etc... the possibility are naturally endless. I propose here a function named motive-replace who are able to execute this task. This function is not in a "good" Lisp but works for me and i hope it can be useful for other users. Naturally, if you can improve this function, i invite you to share your thoughts on this blog. First, we define some utility function, starting with a function for find one motive and replace it: (defun one-motive-replace (old new mat) (flatten (loop for idx from 0 to (-(length mat)1) collect (if (equal (loop for i from 0 to (-(length old)1) collect (nth (+ idx i) mat)) old) (and (setf idx (+ idx (-(length old)1))) new) (nth idx mat))))) #|Usage (one-motive-replace '(a b c) '(1 2 3) '(d b s a b c e j g)) => (d b s 1 2 3 e j g) (one-motive-replace '(a b c) '(1 2) '(d b s a b c e j g)) => (d b s 1 2 e j g) |# Now, we define a function able to find and replace multiple motives: (defparameter *res* '()) (defun multi-motives-replace (oldlist newlist mat) (cond ((null oldlist) '()) (t (setf *res* (one-motive-replace (car oldlist) (car newlist) mat)) (multi-motives-replace (cdr oldlist) (cdr newlist) *res*))) *res*) #|Usage (multi-motives-replace '((a b c) (e j)) '((1 2 3) (8 9)) '(d b s a b c e j g)) => (d b s 1 2 3 8 9 g) |# And finally we define the final function for motivic-replacement who choose between one or multiple motif replace functions based on the list predicate of the first parameter: (defun motive-replace (old new mat) "motive-replace will find an exact motive (old) in a list and will replace it by a new one (new). Note: It is not pattern matching but can be useful." (do-verbose ("motive-replace") (if (listp (car new)) (multi-motives-replace old new mat) (one-motive-replace old new mat)))) #|Usage (motive-replace '(a b c) '(1 2 3) '(d b s a b c e j g)) => (d b s 1 2 3 e j g) (motive-replace '(a b c) '(1 2) '(d b s a b c e j g)) => (d b s 1 2 e j g) (motive-replace '((a b c) (e j)) '((1 2 3) (8 9)) '(d b s a b c e j g)) => (d b s 1 2 3 8 9 g) |# SB.