born Posted March 7 Share Posted March 7 Is there a function that returns all intervals from a chord? Thanks, Achim Quote Link to comment Share on other sites More sharing options...
AM Posted March 7 Share Posted March 7 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) Stephane Boussuge 1 Quote Link to comment Share on other sites More sharing options...
erka Posted March 7 Share Posted March 7 (pitch-to-interval '(c4d4e4f6)) Quote Link to comment Share on other sites More sharing options...
AM Posted March 7 Share Posted March 7 different approach... (pitch-to-interval '(c4d4e4f6)) => intervals between neighbours (get-all-intervals '(c4d4e4f6)) => all intervals INSIDE the chord (between all pitches) Quote Link to comment Share on other sites More sharing options...
erka Posted March 8 Share Posted March 8 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. Stephane Boussuge 1 Quote Link to comment Share on other sites More sharing options...
erka Posted March 8 Share Posted March 8 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) Stephane Boussuge 1 Quote Link to comment Share on other sites More sharing options...
erka Posted March 8 Share Posted March 8 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. Stephane Boussuge 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.