Hi Urs, On Sat, Apr 11, 2015 at 3:31 AM, Urs Liska <u...@openlilylib.org> wrote:
> Hi, > > this is related to my previous thread and particularly to the file > attached to > http://lists.gnu.org/archive/html/lilypond-user/2015-04/msg00263.html > > If I have a Scheme engraver listening to TextScript-s I can get a list of > entries at the same timestep and then compare them for equality. > This even works without changes for DynamicText because that also has a > 'text property. But if i have spanners such as hairpins it's not that > simple anymore. So I'm asking myself if I can access the starting and > ending timesteps of hairpins that are present in such a list. Of course I > can collect hairpins in a list like I can collect TextScripts (currently > I'm listening for line-interface). But is it possible to retrieve the start > *and* end position of such items? > > The goal is to iterate over the list and find matching hairpins to remove > duplicate ones. > > A simple way to determine when a hairpin starts and ends is by using an acknowledger and an end-acknowledger: myEngraver = #(lambda (context) (make-engraver (acknowledgers ((hairpin-interface engraver grob source-engraver) (format #t "My start is at ~a~%" (ly:context-current-moment context)))) (end-acknowledgers ((hairpin-interface engraver grob source-engraver) (format #t "My end is at ~a~%" (ly:context-current-moment context)))) )) \layout { \context { \Score \consists \myEngraver } } { c''1~\< c''1\! c''2.\< c''4\! c''1~\> \break c''2~ c''\! } If you're collecting the hairpins for processing later, you could find the timings of beginnings and endings through the columns at their bounds: myEngraver = #(lambda (context) (let ((hairpins '())) (make-engraver (acknowledgers ((hairpin-interface engraver grob source-engraver) (set! hairpins (cons grob hairpins)))) ((finalize trans) (for-each (lambda (hp) (format #t "BEGINNING ~a END: ~a~%" (grob::when (ly:item-get-column (ly:spanner-bound hp LEFT))) (grob::when (ly:item-get-column (ly:spanner-bound hp RIGHT))))) hairpins)) ))) \layout { \context { \Score \consists \myEngraver } } { c''1~\< c''1\! c''2.\< c''4\! c''1~\> \break c''2~ c''\! } (Unfortunately, the above method won't work within stop-translation-timestep as in the code you cite because the hairpin bounds haven't been assigned column yet, it seems.) Alternatively, couldn't you just compare bounds? If a hairpin has the same left and right bound as another, that hairpin is a duplicate? I would think this would be the easiest method to incorporate into your code. HTH, David
_______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user