[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: select a note in a chord

From: Valentin Villenave
Subject: Re: select a note in a chord
Date: Tue, 15 Jan 2019 01:07:02 +0100

On 1/14/19, Davide Bonetti <address@hidden> wrote:
> I'm looking for a function to select a note in a chord.
> This can be useful for automatic inversions, or to change the voicing
> (like the drop 2 in a four note chord).

Hello Davide,
Here’s how I would do it (using list-ref and list-set!), but this
assumes that the user always enters chords from the lowest to the
uppermost pitch. (It would be possible to first re-order the notes
automatically and then apply the transformation, but I’m too lazy to
add it right now :-)


#(define (drop-n n)
   (lambda (music)
     (let* ((elts (ly:music-property music 'elements))
            (l (length elts)))
       (if (and (music-is-of-type? music 'event-chord)
                (> l n))
           (list-set! elts (- l n)
              (list-ref elts (- l n))
              (ly:make-pitch -1 0))))

dropTwo =
#(define-music-function (music) (ly:music?)
   #{ \musicMap #(drop-n 2) $music #})

\dropTwo \relative {
  <c' e g b> <d f a c>
  \chordmode { d2:maj7 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]