WARNING: This server is unstable and will be retired in the next days. If you want to keep this forum available, please request immediately a migration on the Nabble Support forum. Forums that don't receive any migration request will be deleted forever.

 « Return to Thread: Get the positions of a beam (or other grob with positions)

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

by Janek WarchoĊ‚-2 :: Rate this Message:

| View in Thread

Hi David,

i'm writing just to let you know that the function changing arpeggio length:

offsetArpeggioPositions =
 #(define-music-function (parser location offsets) (pair?)
   #{
      \override Arpeggio #'positions = #(lambda (grob)
        (let* ((func (assoc-get 'positions (cdr
(ly:grob-basic-properties grob))))
               (pos (func grob)))
           (coord-translate pos offsets)))
   #})

suffered form exactly the same problem as the \shape functions (if it
was used before another override of the same object, LilyPond
crashed).  Fortunately, the same fix can be applied!  Here is a more
generic version of the funciton (takes context name and grob name as
argument) that doesn't have this bug:

offsetPositions =
#(define-music-function (parser location context-name grob-name
offsets) (string? string? pair?)
  #{
     \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 Staff 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
  }
>>

this is cool! :D
I wish it was possible to add context to grob name in a more
LilyPondish way (i.e. with a dot)

cheers,
Janek

_______________________________________________
lilypond-user mailing list
lilypond-user@...
https://lists.gnu.org/mailman/listinfo/lilypond-user

 « Return to Thread: Get the positions of a beam (or other grob with positions)