On 1/14/19, Davide Bonetti <d...@davidebonetti.it> 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) (ly:music-transpose (list-ref elts (- l n)) (ly:make-pitch -1 0)))) music))) 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 } } %%%%%%%%%%%% V. _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user