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: David Nalesnik
Subject: Re: Detect slurred notes in callback function
Date: Sun, 7 Feb 2016 16:42:06 -0600

Hi Jakub,

On Sun, Feb 7, 2016 at 12:45 PM, Jakub Pavlík <address@hidden> wrote:
Thank you very much, now I know at least how to get from a grob to the corresponding music object.

In order to "catch" the notes under a slur that aren't slur attach points ("middle notes") I tried to use a closure as the callback function and store information on the "slurred state" (in slur / not in slur) in a variable. Unfortunately the callback isn't executed for the notes in input order, but in a quasi-random fashion, so this technique isn't usable at all. It seems that a property callback function isn't a tool suitable for detecting and modifying all slurred notes.

It would be interesting to see your code for this.  This randomness was the topic of an earlier thread, and I wonder if your observation is related:  http://www.mail-archive.com/lilypond-user%40gnu.org/msg106840.html


I hope that sooner or later I will find The Right Tool for the Job (TM).


Slur grobs store a pointer to an array of NoteColumns they encompass.  So, expanding on Paul's solution, you could do something like this:

 \version "2.19"

#(define (color-slur-notes grob)
   (let*
    ((note-columns (ly:grob-array->list
                    (ly:grob-object grob 'note-columns)))
     (note-heads (append-map
                  (lambda (nc) 
                    (ly:grob-array->list
                     (ly:grob-object nc 'note-heads)))
                  note-columns))
     (color-notes (lambda (n) (ly:grob-set-property! n 'color red))))
    (for-each color-notes note-heads)))

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

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

HTH,
David


reply via email to

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