2016-02-07 14:30 GMT+01:00 Jakub Pavlík <jkb.pav...@gmail.com>: > Hi, > > is it possible to detect slurred notes in a callback function? I would like > to use a callback function to modify properties of all slurred notes. > > Below is my unsuccessful attempt. > The callback function receives NoteHead grob as argument. The grob itself > doesn't seem to contain information about slur attached, so I get it's > event-cause. I know that slurs are stored in the NoteEvent's "articulations" > property, but this property either isn't accessible this way (the object > returned by event-cause doesn't seem to be a regular NoteEvent; what is it > actually?), or I fail to find the correct way to access it. > > --- > > #(define (in-slur? notehead) > (begin > (display "grob") > (newline) > (display-scheme-music notehead) > (display "NoteEvent?") > (newline) > (display-scheme-music (event-cause notehead)) > (display "try to dig slur") > (newline) > (display-scheme-music (ly:event-property (event-cause notehead) > 'articulations)) > #f)) > > \score { > \relative c'' { > \override NoteHead #'color = #(lambda (grob) > (if (in-slur? grob) > red > blue)) > > a a > a( a) > a( a a) > } > } > > --- > > Thanks for any help, > Jakub
Hi Jakub, if you look at the terminal output of \displayMusic { a( a a) } then you'll notice that the middle note has no info whether it is under a slur or not. Only chance I see, is to get start and stop of the slur, and knowing this, get the NoteHeads between. Nevertheless, below a draft of improving your initial code, you'll see the midle note isn't catched. #(define (in-slur? notehead) (let ((tst (if (null? (map (lambda (m) (music-is-of-type? m 'slur-event)) (ly:music-property (ly:prob-property (event-cause notehead) 'music-cause) 'articulations))) #f #t))) (newline) (display-scheme-music tst) tst)) \score { \relative c'' { \override NoteHead #'color = #(lambda (grob) (if (in-slur? grob) red blue)) %\displayMusic { a( a a) } } } HTH a bit, Harm _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user