March 7, 20232 yr just tried in 3min. ouput correct or perhaps some BUGs in thinking? 😁 greetings andré (defun get-all-intervals (alist) (let ((alist (sort-asc (flatten (pitch-to-midi (if (chordp alist) (melodize alist) alist)))))) (rest (sort-asc (remove-duplicates (loop repeat (length alist) for cnt = 0 then (incf cnt) append (x-b (filter-last (- (length alist) cnt) alist) (nth cnt alist)))))))) (get-all-intervals '(c4 d4 e4)) => (2 4) (get-all-intervals '(c4d4e4f6)) => (2 4 25 27 29)
March 7, 20232 yr different approach... (pitch-to-interval '(c4d4e4f6)) => intervals between neighbours (get-all-intervals '(c4d4e4f6)) => all intervals INSIDE the chord (between all pitches)
March 8, 20232 yr Would this be okay, too? For getting the intervals of notes related to the first note. (defun chordintervals (chord) (x-b (pitch-to-midi (pitch-melodize chord)) (pitch-to-midi (first (pitch-melodize chord)))) ) melodize instead of pitch-melodize works too, but is not listed under functions.
March 8, 20232 yr Is that LISPier? Does the same as last post. (defun chordintervals (chord) (let* ((midimelo (pitch-to-midi (pitch-melodize chord))) (chordroot (first midimelo))) (x-b midimelo chordroot))) (chordintervals '(c4d4e4g4c5)) (chordintervals '(c4 d4 e4 g4 c5)) both return => (0 2 4 7 12)
March 8, 20232 yr And another way: (defun chordintervals (chord &key ( named nil)) (let* ((midimelo (pitch-to-midi (pitch-melodize chord))) (chordroot (first midimelo)) (numbers (x-b midimelo chordroot)) (names (cons 'base-note (rest (get-interval-name numbers))))) (if (equal named t) names numbers) )) (chordintervals '(c4d4e4g4c5)) =>(0 2 4 7 12) (chordintervals '(c4d4e4g4c5) :named t ) =>(base-note major-second major-third perfect-fifth perfect-octave) (chordintervals '(c4 d4 e4 g4 c5)) =>(0 2 4 7 12) (chordintervals '(c4 d4 e4 g4 c5) :named t) =>(base-note major-second major-third perfect-fifth perfect-octave) I hope I understood the original post correct.
Create an account or sign in to comment