\shape generell festlegen

Begonnen von rgree, Dienstag, 30. April 2024, 09:05

« vorheriges - nächstes »

rgree

Hallo,

im Beispiel unten kann man sehen, wie man mit \shape die Bindebögen beeinflussen kann.
In der 1. Zeile sind die Bindebögen, wie Lilypond sie per Default appliziert,
un der 2. Zeile sind die Bögen etwas höher über den Noten angebracht.

\version "2.20.0"
x = \shape #'((0 . 0.5) (0 . 1) (0 . 1) (0 . 0.5)) Slur
{
  \time 3/4
  \key bes \major
  % neutral
  d'16( b' g'' b') g''( b' g'' b') d'( b' g'' b')
  d'16( b' g'' b') g''( b' g'' b') d'( b' g'' b')
  d'16( b' g'' b') g''( b' g'' b') d'( b' g'' b')
  \break
  % Bindebögen etwas höher
  \x d'16( b' g'' b') \x g''( b' g'' b') \x d'( b' g'' b')
  \x d'16( b' g'' b') \x g''( b' g'' b') \x d'( b' g'' b')
  \x d'16( b' g'' b') \x g''( b' g'' b') \x d'( b' g'' b')
  \bar "||"
  \break
}

Man sieht, dass vor jeder Note mit einem folgenden "(" mit dem Kürzel \x der \shape-Befehl aufgerufen wird,
was aber nicht sonderlich elegant ist.
Meine Frage nun: kann man durch ein geeignetes \override ein generelles "Shaping" festlegen ?!
Man könnte dann (im Original ist diese Arpeggienstelle weitaus länger) vor
der Stelle ein \override angeben und die Festlegung nach der Stelle mit \revert aufheben .
In der Doku konnte ich nichts finden ..

Hat jemand eine Idee ?

Gruß,
Reinhard


harm6

In \shape ist \once hardcoded.
Ob es sinvoll sein kann das zu ändern sei mal dahingestellt. Möglich ist es so:
generalShape =
#(define-music-function (offsets item) (list? key-list-or-music?)
   (_i "Offset control points of @var{item} by @var{offsets}.

@var{offsets} is a list of number pairs @code{(@var{x} . @var{y})} or a list of
such lists.  Each pair represents an offset to a control point.  The @samp{y}
value of each pair is scaled by staff space.

If @var{item} is a string, the result is @code{\\once@/\\override} for the
specified grob type.  If @var{item} is a music expression, the result is the
same music expression with an appropriate tweak applied.")
   (define (shape-curve grob coords)
     (let* ((orig (ly:grob-original grob))
            (siblings (if (ly:spanner? grob)
                          (ly:spanner-broken-into orig) '()))
            (total-found (length siblings))
            (staff-space (ly:staff-symbol-staff-space grob))
            (scaled-offsets
              (map
                (lambda (offset)
                  (if (number-pair? offset)
                      (cons (car offset) (* (cdr offset) staff-space))
                      offset))
                offsets)))

       (define (offset-control-points offsets)
         (if (null? offsets)
             coords
             (map coord-translate coords offsets)))

       (define (helper sibs offs)
         (if (pair? offs)
             (if (eq? (car sibs) grob)
                 (offset-control-points (car offs))
                 (helper (cdr sibs) (cdr offs)))
             coords))

       ;; we work with lists of lists
       (if (or (null? scaled-offsets)
               (not (list? (car scaled-offsets))))
           (set! scaled-offsets (list scaled-offsets)))

       (if (>= total-found 2)
           (helper siblings scaled-offsets)
           (offset-control-points (car scaled-offsets)))))

   (propertyTweak 'control-points
                  (grob-transformer 'control-points shape-curve)
                  item))
Und dann:
x = \generalShape #'((0 . 0.5) (0 . 1) (0 . 1) (0 . 0.5)) Slurbzw
\undo \x
Möglich ist auch eine Schmalspur Version:
  \temporary \override Slur.control-points =
  #(grob-transformer 'control-points
    (lambda (grob orig)
      (map
        (lambda (coord pair) (offset-add coord pair))
        orig
        '((0 . 0.5) (0 . 1) (0 . 1) (0 . 0.5)))))
mit \revert hinterher.

HTH,
  Harm

rgree