Jump to content

Featured Replies

Posted

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!

 

  • eboats changed the title to Chord Inversion question

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))

 

  • Author

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. 

  • Author
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.

 

 

  • 3 weeks later...

Create an account or sign in to comment


Copyright © 2014-2025 Opusmodus™ Ltd. All rights reserved.
Product features, specifications, system requirements and availability are subject to change without notice.
Opusmodus, the Opusmodus logo, and other Opusmodus trademarks are either registered trademarks or trademarks of Opusmodus Ltd.
All other trademarks contained herein are the property of their respective owners.

Powered by Invision Community

Important Information

Terms of Use Privacy Policy