January 31, 20233 yr Hello, I'm hitting a brick wall with m thinking from object-oriented approaches. Basically, I want to create a melody line that "flutters" pitches in a key corresponding to a bass pitch, and only when that bass pitch occurs. It's easy enough for an "If, then" statement but my attempt to solve this are leading me to take a first step of interpolating between bass pitches (as integers) and manually calculating the remains of the bar manually. However this is not ideal as I would prefer to use euclidean-rhythm with a rotation, so finding a parametric approach this would be ideal. Here's the general approach I've begun. Any advice from people more experienced with LISP is appreciated. (setf bass '((g2)(c3)(a2)(e3)(fs3))) (setf bassint (pitch-to-integer bass)) => ((-17) (-12) (-15) (-8) (-6)) ;;; create a set of integers from interpolation ;;; between bass integers (bassint), ;;; then convert those to pitches (setf melody (gen-transition 1 10 10 1)) Thanks, Tom
February 1, 20233 yr May be this can help a bit, I've tried this: (setf bass '(g2 c3 a2 e3 fs3)) (setf bassint (pitch-to-integer bass)) ;=> (-17 -12 -15 -8 -6) ;;; create a set of integers from interpolation ;;; between bass integers (bassint), ;;; then convert those to pitches (defun linear-interpolation (numbers steps) (let ((interpolated-numbers nil)) (loop for i from 0 below (- (length numbers) 1) for number = (nth i numbers) for next-number = (nth (1+ i) numbers) do (loop for j from 0 to steps do (push (+ (* (- next-number number) (/ (float j) steps)) number) interpolated-numbers) ) (push next-number interpolated-numbers)) (filter-repeat 1 (nreverse interpolated-numbers)))) (setf n-steps 4) (setf new-ints (mapcar 'round (linear-interpolation bassint n-steps))) (setf melody (integer-to-pitch new-ints)) (setf sop (filter-tie (make-omn :pitch (pitch-transpose 24 melody) :length '(e) :span :pitch ))) (setf bas (make-omn :pitch bass :length '(h) :span :pitch )) (ps 'gm :fl (list sop) :bn (list bas) :time-signature '(4 4)) SB.
February 1, 20233 yr Author This is beautiful, @Stephane Boussuge! First use of a for loop and a defined function for me with OM. This opens up a whole new world. Thank you so much! THT
February 1, 20233 yr Author One question @Stephane Boussuge - what is 'round ? Context - (setf new-ints (mapcar 'round (linear-interpolation bassint n-steps))) I'm unable to find that in the documentation.
February 1, 20233 yr Better doc: CLHS: Function FLOOR, FFLOOR, CEILING, FCEILING... WWW.LISPWORKS.COM
Create an account or sign in to comment