TomTolleson Posted January 31 Share Posted January 31 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 Quote Link to comment Share on other sites More sharing options...
Stephane Boussuge Posted February 1 Share Posted February 1 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. opmo and TomTolleson 1 1 Quote Link to comment Share on other sites More sharing options...
TomTolleson Posted February 1 Author Share Posted February 1 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 Quote Link to comment Share on other sites More sharing options...
TomTolleson Posted February 1 Author Share Posted February 1 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. Quote Link to comment Share on other sites More sharing options...
Stephane Boussuge Posted February 1 Share Posted February 1 Here's the doc: Simplified Common Lisp reference - round JTRA.CZ TomTolleson 1 Quote Link to comment Share on other sites More sharing options...
Stephane Boussuge Posted February 1 Share Posted February 1 Better doc: CLHS: Function FLOOR, FFLOOR, CEILING, FCEILING... WWW.LISPWORKS.COM TomTolleson 1 Quote Link to comment Share on other sites More sharing options...
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.