lilypond-devel
[Top][All Lists]
Advanced

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

scheme function to extract a specific grob property from a music event?


From: josé henrique padovani
Subject: scheme function to extract a specific grob property from a music event?
Date: Sun, 06 Jun 2010 11:40:18 -0300
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; pt-BR; rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4

Hi,

I have tried to find in the manual and in the sources a scheme function that let me extract a specific grob from a music object... I want to be able to know which is the 'staff-position (or should it be Y-offset?) grob-property of the notehead I am creating and use it to set the Y-offset of my markup.


As my last attempt storing and resetting scheme variables didn't worked, I'm following Mike Solomon suggestion and I have created a scheme function which writes everything I need...

Here is what I have until now....
The function has four entries: event-chord(music?) txt(markup?) numx(number?) numy(number?) What I want to do is to eliminate the last argument by setting it to be equal to the same 'Y-offset (or 'staff-position, it is not clear to me yet) of the notehead....


%%%% CODE BEGIN
myfunction = #(define-music-function (parser location event-chord txt numx numy)
           (ly:music? markup? number? number?)
           (let ((result-event-chord (ly:music-deep-copy event-chord))
(tscript-outside-staff-priority (make-music ;;\override TextScript #'outside-staff-priority = ##f
                              'ContextSpeccedMusic
                              'context-type
                              'Bottom
                              'element (make-music
                                'OverrideProperty
                                'pop-first
                                #t
                                'grob-property-path
                                (list (quote outside-staff-priority))
                                'grob-value
                                #f
                                'symbol
                                'TextScript)))
(tscript-xoffset (make-music ;;;;;; \override TextScript #'X-offset = numx
                       'ContextSpeccedMusic
                       'context-type
                       'Bottom
                       'element
                       (make-music
                    'OverrideProperty
                    'pop-first
                    #t
                    'grob-property-path
                    (list (quote X-offset))
                    'grob-value
                    numx
                    'symbol
                    'TextScript)))
(tscript-yoffset (make-music ;;;;; \override TextScript #'Y-offset = numy
                       'ContextSpeccedMusic
                       'context-type
                       'Bottom
                       'element
                       (make-music 'OverrideProperty
                    'pop-first
                    #t
                    'grob-property-path
                    (list (quote Y-offset))
                    'grob-value
                    numy
                    'symbol
                    'TextScript))))
        (set! (ly:music-property result-event-chord 'elements)
(cons (make-music 'TextScriptEvent 'text (markup txt)) ;;;my markup
          (ly:music-property result-event-chord 'elements)))
(make-music 'SequentialMusic 'elements (list tscript-outside-staff-priority tscript-xoffset tscript-yoffset result-event-chord))))

\score{
\relative c'{
%{
%\displayMusic
{
 \override TextScript #'outside-staff-priority = ##f
 \override TextScript #'X-offset = #2
 \override TextScript #'Y-offset = #0
 g'1-\markup{"<-"}
}
%}

\myfunction g'1 \markup{\sans "<-"} #2 #0
}
}

%%% CODE END


--
http://zepadovani.info




reply via email to

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