Search the Community
Showing results for tags 'chord'.
-
;;; THIS FUNCTION DOING SYMM TRANSPOSITIONS TO CONRACT (OR EXPAND, depends on INTERVAL) A CHORD or PITCH-SEQ ;;; default setting: it changes in every generation the highest and lowest pitch by an OCTAVE ;;; by changing :position (see examples) you could change which position should be changed/transposed ;;; default interval is 12 ;;; FUNCTION (defun chord-contraction/expansion (n pitchlist &key (position nil) (interval 12) (chord nil)) (let* ((pitchlist (if (chordp (car pitchlist)) (melodize pitchlist) pitchlist)) (position (if (null position) (list 0 (1- (length pitchlist))) (if (listp position) position (list position (- (1- (length pitchlist)) position))))) (pitchlist (cons pitchlist (loop repeat n collect (setf pitchlist (sort-asc (flatten (position-replace position (list (pitch-transpose interval (list (nth (car position) pitchlist))) (pitch-transpose (neg! interval) (list (nth (cadr position) pitchlist)))) pitchlist)))))))) (if (null chord) pitchlist (chordize pitchlist)))) ;;; EXAMPLES: evaluate by cmd3 (setf 12-tone-field '(f3 fs3 gs3 c4 d4 e4 b4 cs5 eb5 g5 a5 bb5)) (chord-contraction/expansion 4 12-tone-field :chord t) => ((f3fs3gs3c4d4e4b4cs5eb5g5a5bb5) (fs3gs3c4d4e4f4bb4b4cs5eb5g5a5) (gs3c4d4e4f4fs4a4bb4b4cs5eb5g5) (c4d4e4f4fs4g4gs4a4bb4b4cs5eb5) (d4eb4e4f4fs4g4gs4a4bb4b4c5cs5)) (chord-contraction/expansion 4 12-tone-field :chord t :interval 48) => ((f3fs3gs3c4d4e4b4cs5eb5g5a5bb5) (bb1fs3gs3c4d4e4b4cs5eb5g5a5f7) (f3fs3gs3c4d4e4b4cs5eb5g5a5bb5) (bb1fs3gs3c4d4e4b4cs5eb5g5a5f7) (f3fs3gs3c4d4e4b4cs5eb5g5a5bb5)) ;;; with spezific positions (inner change) (chord-contraction/expansion 4 12-tone-field :chord t :position 3) => ((f3fs3gs3c4d4e4b4cs5eb5g5a5bb5) (f3fs3gs3d4eb4e4b4c5cs5g5a5bb5) (f3fs3gs3cs4eb4e4b4c5d5g5a5bb5) (f3fs3gs3d4eb4e4b4c5cs5g5a5bb5) (f3fs3gs3cs4eb4e4b4c5d5g5a5bb5)) (chord-contraction/expansion 4 12-tone-field :chord t :position '(0 5)) => ((f3fs3gs3c4d4e4b4cs5eb5g5a5bb5) (e3fs3gs3c4d4f4b4cs5eb5g5a5bb5) (f3fs3gs3c4d4e4b4cs5eb5g5a5bb5) (e3fs3gs3c4d4f4b4cs5eb5g5a5bb5) (f3fs3gs3c4d4e4b4cs5eb5g5a5bb5)) ;;;; with different intervals (chord-contraction/expansion 4 12-tone-field :chord t :interval 11) => ((f3fs3gs3c4d4e4b4cs5eb5g5a5bb5) (fs3gs3c4d4e4e4b4b4cs5eb5g5a5) (gs3c4d4e4e4f4bb4b4b4cs5eb5g5) (c4d4e4e4f4g4gs4bb4b4b4cs5eb5) (d4e4e4e4f4g4gs4bb4b4b4b4cs5)) (chord-contraction/expansion 4 12-tone-field :chord t :interval 7) => ((f3fs3gs3c4d4e4b4cs5eb5g5a5bb5) (fs3gs3c4c4d4e4b4cs5eb5eb5g5a5) (gs3c4c4cs4d4e4b4cs5d5eb5eb5g5) (c4c4cs4d4eb4e4b4c5cs5d5eb5eb5) (c4cs4d4eb4e4g4gs4b4c5cs5d5eb5))
-
Here's a new function a bit similar to my old "add-interval-if-length" function but bit more sophisticated. It use gen-chord3 to create chord on defined length. ;;; ============================================== ;;; UTILITY FUNCTIONS ;;; (defun make-chord-if-length-aux (omn &key (test #'>) (length-val 1/8) (interval-list '((4 7)(7 12))) (cycle t)(relative nil) seed) (setf seed (rnd-seed seed)) (let ((s-events (single-events omn))) (loop for e in s-events for i in (gen-trim (length s-events) interval-list) when (funcall test (omn-encode (first e)) length-val) append (omn-replace :pitch (gen-chord3 (list (second e)) i :cycle cycle :relative relative :seed (seed)) e ) else append e))) ;(make-chord-if-length-aux '(q c4 d4 e4 f4 e g4 a4)) ;(make-chord-if-length-aux '(q c4 d4 e4 f4 e g4 a4) :interval-list '((4 7)(3 10))) ;(make-chord-if-length-aux '(q c4 d4 e4 f4 e g4 a4) :interval-list '((4 7 11 14)(7 9 16)) :cycle nil) ;(make-chord-if-length-aux '(q c4 d4 e4 f4 e g4 a4) :interval-list '((4 7 11 14)(7 9 16)) :cycle nil :seed 4) ;(make-chord-if-length-aux '(q c4 d4 e4 f4 e g4 a4) :interval-list '((4 7 11 14)(7 9 16)) :cycle nil :relative t) ;(make-chord-if-length-aux '(q c4 d4 e4 f4 e g4 a4) :interval-list '((4 7 11 14)(7 9 16)) :cycle nil :relative t :seed 4) ;;; ============================= ;;; MAIN FUNCTION (defun make-chord-if-length (omn &key (test #'>) (length-val 1/8) (interval-list '((4 7)(7 12)))(cycle nil)(relative nil) seed) (setf seed (rnd-seed seed)) (do-verbose ("make-chord-if-length :seed ~s :length-val ~s :interval-list ~s :cycle ~s :relative ~s" seed length-val interval-list cycle relative) (let ((test-fn (case test (> #'>) (< #'<) (= #'=) (otherwise test)))) (if (listp (car omn)) (mapcar #'(lambda (x) (make-chord-if-length-aux x :test test-fn :length-val (omn-encode length-val) :interval-list interval-list :cycle cycle :relative relative :seed (seed))) omn) (make-chord-if-length-aux omn :test test-fn :length-val (omn-encode length-val) :interval-list interval-list :cycle cycle :relative relative :seed (seed)))))) ;;; Tests ;(make-chord-if-length '((q c4 e d4 e4 f4 h d4)(s a4 b4 a4 g4 h f4)(q c4 d4 h e4))) ;(make-chord-if-length '((q c4 e d4 e4 f4 h d4)(s a4 b4 a4 g4 h f4)(q c4 d4 h e4)) :seed 8) ;(make-chord-if-length '((q c4 e d4 e4 f4 h d4)(s a4 b4 a4 g4 h f4)(q c4 d4 h e4)) :interval-list '((2 9)(7 11))) ;(make-chord-if-length '((q c4 d4 e4 f4 g4)(s a4 b4 a4 g4 h f4)(q c4 d4 h e4)) :cycle t) ;(make-chord-if-length '((q c4 e d4 e4 f4 h d4)(s a4 b4 a4 g4 h f4)(q c4 d4 h e4)) :cycle nil :relative t) ;(make-chord-if-length '((q c4 e d4 e4 f4 h d4)(s a4 b4 a4 g4 h f4)(q c4 d4 h e4)) :cycle nil :relative t :seed 8) i've also attached the original file to this post. SB. make-chord-if-length.lisp