2009/5/9 Marc Hohl <m...@hohlart.de>: > I tried to receive the informations needed by overriding the Glissando > #'stencil with > a function which simply displays the values obtained by the ly:spanner-bound > call > before calling ly:line-spanner::print, but I get only #<Grob NoteHead > on > the terminal. > > What am I doing wrong here?
Nothing, though to be on the safe side, it's best to ensure you're dealing with the unbroken spanner by using ly:grob-original: if a user decides to have a glissando over a line break, it won't be possible to get noteheads for both bounds. Once you have the NoteHead grobs, you can retrieve their pitches from the events which created them: \relative c' { \override NoteHead #'stencil = #(lambda (grob) ;; event-cause is a convenient shorthand in this case for (ly:grob-property grob 'cause) (display (event-cause grob)) (ly:note-head::print grob)) c4 } >> #<Prob: Stream_event C++: Stream_event((music-cause . #<Prob: Music C++: Music((length . #<Mom 1/4>) (elements) (duration . #<Duration 4 >) (pitch . #<Pitch c' >) (origin . #<location /home/neil/Documents/test.ly:254:5>))((display-methods #<procedure #f (note parser)>) (name . NoteEvent) (types general-music event note-event rhythmic-event melodic-event)) > ) (length . #<Mom 1/4>) (elements) (duration . #<Duration 4 >) (pitch . #<Pitch c' >) (origin . #<location /home/neil/Documents/test.ly:254:5>))((class . note-event)) > >From the event, you can get the pitch using ly:event-property event 'pitch. Putting it all together: #(define (glissando::calc-extra-dy grob) (let* ((original (ly:grob-original grob)) (left-bound (ly:spanner-bound original LEFT)) (right-bound (ly:spanner-bound original RIGHT)) (left-pitch (ly:event-property (event-cause left-bound) 'pitch)) (right-pitch (ly:event-property (event-cause right-bound) 'pitch))) ;; work out return value based on pitches here 0)) Regards, Neil _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user