lilypond-user
[Top][All Lists]
Advanced

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

Re: Detect slurred notes in callback function


From: Paul Morris
Subject: Re: Detect slurred notes in callback function
Date: Sun, 7 Feb 2016 10:53:58 -0500

Hi Jakub,

FWIW, here’s another approach that starts from slurs and goes to note heads.  
(Adapted from some code for tied notes where this works a little more cleanly 
since ties connect to note heads directly rather than to note columns…)  

Unfortunately, this one also doesn’t color notes in the middle of slurs, only 
those on the ends.  And Harm’s code that deals with note heads directly is 
probably better for addressing that.

Cheers,
-Paul


%%%%%%%%%%%%%%%%

\version "2.19.36"

#(define (color-slur-notes grob)
   (let*
    ((right-note-col (ly:spanner-bound grob RIGHT))
     (left-note-col (ly:spanner-bound grob LEFT))
     
     (right-notes (ly:grob-array->list 
                   (ly:grob-object right-note-col 'note-heads)))
     
     (left-notes (ly:grob-array->list
                  (ly:grob-object left-note-col 'note-heads)))
     
     (color-notes (lambda (n) (ly:grob-set-property! n 'color red))))

    ; (display right-notes)(newline)
    
    (for-each color-notes right-notes)
    (for-each color-notes left-notes)
    ))

\score {
  \relative c'' {
    \override Staff.Slur.before-line-breaking = #color-slur-notes
    a a
    a( a)
    a( a a)
  }
}

%%%%%%%%%%%%%%%%


reply via email to

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