eboats Posted July 20, 2024 Posted July 20, 2024 Hello, If I have a list like ( (c4) (cs4d4) (f4) (e4fs4) ), I'd like to modify just the chord sublists so that it shows the root and all inversions of the chord. If I do (chord-inversion 1 '((c4) (cs4d4) (f4) (e4fs4)) :series t :root t ) , I get (((c4) c4) ((cs4d4) d4cs5) ((f4) f4) ((e4fs4) fs4e5)) but I'd want the chord-inversion function to ignore the single note sublists ( e.g. (c4) ) since they aren't chords. So, how would I get a result similar to the below? ( (c4) (cs4d4 d4cs5) (f4) (e4fs4 fs4e5) ) Also, is there a way to identify which sublists have a chord versus just a single note? Thanks for any info! Quote
opmo Posted July 21, 2024 Posted July 21, 2024 Loop iteration is one of the most powerful and useful functions in environments like Opusmodus. I recommend spending some time understanding the grammar of the iteration possibilities. loop for i in '((c4) (cs4d4) (f4) (e4fs4)) collect (flatten (filter-repeat 1 (chord-inversion 1 i :series t :root t)))) => ((c4) (cs4d4 d4cs5) (f4) (e4fs4 fs4e5)) It would be better to flatten the sequence first: (flatten (loop for i in '(c4 cs4d4 f4 e4fs4) collect (filter-repeat 1 (chord-inversion 1 i :series t :root t)))) => (c4 cs4d4 d4cs5 f4 e4fs4 fs4e5) I could modify the function to prevent single pitch repetitions. With the possibile change: (chord-inversion 1 '(c4 cs4d4 f4 e4fs4) :series t :root t) => ((c4) (cs4d4 d4cs5) (f4) (e4fs4 fs4e5)) Quote
eboats Posted July 21, 2024 Author Posted July 21, 2024 Thanks much! Yes, I think I need to spend some time learning more about Common Lisp. For the chord-inversion function, it does seem like it should ignore single notes. Also, when looping through or processing a list, is there a function for checking whether an item is a chord or not, e.g. if ( is-chord item ) ? I can see how that could be useful for deciding whether to take action on an item in a list. Quote
eboats Posted July 21, 2024 Author Posted July 21, 2024 31 minutes ago, jesele said: chordp Jesper Ah thank you. In the docs, what folder is that under? For chord related stuff, I usually look in /Pitches/Chords but didn't see it there. Quote
opmo Posted August 8, 2024 Posted August 8, 2024 Update to chord-inversion function. OM 3.0.29352 Please check the document. Quote
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.