lilypond-user
[Top][All Lists]
Advanced

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

Put the property of a grob in the output-attributes list


From: Paolo Prete
Subject: Put the property of a grob in the output-attributes list
Date: Sun, 22 Dec 2019 11:56:59 +0100

Hello all.

the following function (thanks to Stefano!) inserts the beam-thickness property of a Beam in the list of output-attributes of the corresponding SVG item. It does its job if I place the function soon before a beam symbol "[".  But it doesn't work (no errors, but the output-attributes property is not set) if  place it before a notename. How can I fix that? Should I map-some-music() and iterate until I find the BeamEvent? I tried that too, but without success.
Thanks.

token = #(let* ((ctr 0)
                (ctr! (lambda ()
                        (set! ctr (1+ ctr))
                        ctr)))
   (define-music-function (mus) (ly:music?)
     (let* ((id (format #f "foobar_~a" (ctr!)))
            (mexp #{ \tweak output-attributes.id #id #mus #} )
            (type (ly:music-property mus 'name))
            (mexp (case type
                    ('BeamEvent
                      #{ \tweak Beam.after-line-breaking #(lambda (grob)
                           (let* ((outprop (ly:grob-property grob 'output-attributes))
                                  (beam-thickness (ly:grob-property grob 'beam-thickness))
                                  (outprop (append outprop `((beam-thickness . ,beam-thickness)))))
                             (begin
                                  (ly:grob-set-property! grob 'output-attributes outprop)
                                  (display "\n****\n")
                                  (display beam-thickness)
                                  (display "\n****\n"))))
                      #mexp #} )
                    (else mexp))))
       mexp)))

\relative { c'4 d8-\token [ e ] \token f[ g ] c,4 }

reply via email to

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