lilypond-user
[Top][All Lists]
Advanced

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

Re: Get the positions of a beam (or other grob with positions)


From: Thomas Morley
Subject: Re: Get the positions of a beam (or other grob with positions)
Date: Wed, 23 May 2012 13:43:05 +0200

2012/5/23 Janek Warchoł <address@hidden>:
> On Wed, May 23, 2012 at 1:02 PM, David Kastrup <address@hidden> wrote:
>> Janek Warchoł <address@hidden> writes:
>>
>>> I wish it was possible to add context to grob name in a more
>>> LilyPondish way (i.e. with a dot)
>>
>> It is conceivable as a parser extension,
>
> That's good news!
>
>> like 3/4 is nowadays generally read as '(3 . 4).
>
> I'm very happy that this is the case.  It's one of the small things
> that make Lily more user-friendly.
>
>> One would turn aa.bb.cc (no spaces!) to #'(aa bb cc)
>> in the lexer.  It would likely be somewhat tricky to make sure that one
>> does not get surprises in lyrics and so on.
>>
>> Since aa is rendered as a _string_, it might be more consistent to just
>> read aa.bb.cc as one string and leave splitting to the music function.
>>
>> I have not found a choice that would really be convincingly consistent,
>> so I have not done anything of the sort yet.
>
> I'm not sure which one is better, either.
> Maybe GLISS will introduce some changes that will make the descision easier.
>
> best,
> Janek

Hi,

I tried it similar to `overrideProperty' from `music-functions-init.ly'
But I didn't manage to get rid of the ""-signs, when specifying the
coctext. Is this possible?

\version "2.15.38"

offsetPositions =
#(define-music-function (parser location name offsets) (string? pair?)

   (let ((name-components (string-split name #\.))
         (context-name "Voice")
         (grob-name #f))

     (if (> 2 (length name-components))
         (set! grob-name (car name-components))
         (begin
           (set! grob-name (list-ref name-components 1))
           (set! context-name (list-ref name-components 0))))
 #{
    \override $context-name . $grob-name #'positions = #(lambda (grob)
      (let* ((func (assoc-get 'positions
                (reverse(ly:grob-basic-properties grob))))
             (pos (func grob)))
         (coord-translate pos offsets)))
 #}))

% example of use:

\layout {
 \offsetPositions Arpeggio #'(-1 . 1)
 \offsetPositions "PianoStaff.Arpeggio" #'(-3 . 2)
}

\relative c'   {
 <c e g c>2\arpeggio
}

\new PianoStaff \relative c' <<
 \set PianoStaff.connectArpeggios = ##t
   \new Staff {
   <e g>2\arpeggio
 }
 \new Staff {
   \clef bass
   <c, e>2\arpeggio
 }
>>

-Harm



reply via email to

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