Jump to content

Chord Inversion question


Recommended Posts

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!

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

Terms of Use Privacy Policy