eboats Posted July 20 Share Posted July 20 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 Link to comment Share on other sites More sharing options...
opmo Posted July 21 Share Posted July 21 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 Link to comment Share on other sites More sharing options...
eboats Posted July 21 Author Share Posted July 21 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 Link to comment Share on other sites More sharing options...
jesele Posted July 21 Share Posted July 21 chordp Jesper Quote Link to comment Share on other sites More sharing options...
eboats Posted July 21 Author Share Posted July 21 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 Link to comment Share on other sites More sharing options...
jesele Posted July 21 Share Posted July 21 eboats 1 Quote Link to comment Share on other sites More sharing options...
opmo Posted August 8 Share Posted August 8 Update to chord-inversion function. OM 3.0.29352 Please check the document. 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.