Autor Thema: Wiederholungszeichen über der Notenlinie  (Gelesen 1593 mal)

chf

  • Member
Wiederholungszeichen über der Notenlinie
« am: Dienstag, 8. September 2015, 18:38 »
Liebe Freunde,

ist es möglich, Wiederholungszeichen (so wie Text) über die Notenlinie zu setzen?
Ich möchte Motive so für "ad lib"-Wiederholen kennzeichnen...
Ich würde probieren, weiß aber nicht, wie ich das Zeichen ansprechen soll.

Gruß
chf

harm6

  • Member
Re: Wiederholungszeichen über der Notenlinie
« Antwort #1 am: Mittwoch, 9. September 2015, 02:38 »
Mit einem markup-command würde es gehen.
Ich hab vor längerem mal eins geschrieben, es aber nie zu Ende gebracht.

Nichtsdestotrotz hier was ich habe:

\version "2.16.1"
%\version "2.17.10"
                         
#(define-markup-command (bar-line layout props strg)(string?)
  #:properties ((font-size 0)
                (add-height 0))
             
  (define (string->string-list str)
    "Convert a string into a list of strings with length 1.
  @code{"aBc"} will be converted to @code{("a" "B" "c")}.
  An empty string will be converted to a list containing @code{""}."
    (if (and (string? str)
             (not (zero? (string-length str))))
        (map (lambda (s)
                     (string s))
             (string->list str))
        (list "")))
             
  (define (make-bar-line thickness height fontsize blot-diameter)
    "Draw a simple bar line."
    (ly:round-filled-box
      (cons 0 (* (magstep font-size) thickness))
      (interval-widen (cons 0 (+ add-height height)) (magstep font-size))
      blot-diameter))
                           
  (define (make-colon-bar-line height fontsize)
    (let* ((font
             (ly:paper-get-font layout
               (cons '((font-encoding . fetaMusic)) props)))
           (dot (ly:font-get-glyph font "dots.dot")))
    (ly:stencil-add
        dot
        (ly:stencil-translate-axis
          dot
          (magstep (+ (/ add-height 2) font-size))
          Y))))
             
  (define (make-bracket-bar-line height fontsize dir thick-bar )
    "Draw a bracket-style bar line. If @var{dir} is set to @code{LEFT}, the
     opening bracket will be drawn, for @code{RIGHT} we get the
     closing bracket."
    (let* ((font
              (ly:paper-get-font layout
                (cons '((font-encoding . fetaMusic)) props)))
           (brackettips-up (ly:font-get-glyph font "brackettips.up"))
           (brackettips-down (ly:font-get-glyph font "brackettips.down"))
           ;; the x-extent of the brackettips must not be taken into account
           ;; for bar line constructs like "[|:", so we set new bounds:
           (tip-up-stil
             (ly:make-stencil
               (ly:stencil-expr brackettips-up)
               (cons 0 0)
               (ly:stencil-extent brackettips-up Y)))
           (tip-down-stil
             (ly:make-stencil
               (ly:stencil-expr brackettips-down)
               (cons 0 0)
               (ly:stencil-extent brackettips-down Y)))
           (stencil
             (ly:stencil-add
               thick-bar
               (ly:stencil-translate-axis
                 tip-up-stil
                 (+ (/ (+ add-height height) 2) (magstep fontsize)  )
                 Y)
               (ly:stencil-translate-axis
                 tip-down-stil
                 (* -1 (+ (/ (+ add-height height) 2) (magstep fontsize) ))
                 Y))))
        (if (eq? dir LEFT)
            stencil
            (ly:stencil-scale stencil -1 1))))
           
  (define (make-brace-bar-line height fontsize)
    (let* ((new-height (max (* add-height height) 12))
           (font
             (ly:paper-get-font layout
               (cons '((font-encoding . fetaBraces)
                       (font-name . #f))
                     props)))
           (glyph-count (1- (ly:otf-glyph-count font)))
           (scale (ly:output-def-lookup layout 'output-scale))
           (scaled-size (+ add-height (magstep fontsize) (/ (ly:pt new-height) scale)))
           (glyph
             (lambda (n)
               (ly:font-get-glyph
                 font
                 (string-append "brace" (number->string n)))))
           (get-y-from-brace
             (lambda (brace)
               (interval-length
                (ly:stencil-extent (glyph brace) Y))))
           (find-brace
             (binary-search 0 glyph-count get-y-from-brace scaled-size))
           (glyph-found (glyph find-brace)))

    (if (or (null? (ly:stencil-expr glyph-found))
            (< scaled-size
               (interval-length (ly:stencil-extent (glyph 0) Y)))
            (> scaled-size
               (interval-length (ly:stencil-extent (glyph glyph-count) Y))))
        (begin
          (ly:warning (_ "no brace found for point size ~S ") new-height)
          (ly:warning (_ "defaulting to ~S pt")
          (/ (* scale (interval-length (ly:stencil-extent glyph-found Y)))
             (ly:pt 10)))))
    glyph-found))
             
    (let* ((line-thickness (ly:output-def-lookup layout 'line-thickness))
           (size (ly:output-def-lookup layout 'text-font-size 12))
           ;; Numerical values taken from the IR
           (thin-thickness (* line-thickness 1.9))
           (kern (* line-thickness 3.0))
           (thick-thickness (* line-thickness 6.0))
           (blot (ly:output-def-lookup layout 'blot-diameter))
           ;; Not sure about the numerical value, found it by try and error.
           (thin-bar-line
             (ly:stencil-aligned-to
               (make-bar-line thin-thickness (/ size 9) font-size blot)
               Y CENTER))
           (thick-bar-line
             (ly:stencil-aligned-to
               (make-bar-line thick-thickness (/ size 9) font-size blot)
               Y CENTER))
           (colon-bar-line
             (ly:stencil-aligned-to
               (make-colon-bar-line (/ size 9) font-size)
               Y CENTER))
           (bracket-left-bar-line
             (ly:stencil-aligned-to
               (make-bracket-bar-line (/ size 9) font-size -1 thick-bar-line)
               Y CENTER))
           (bracket-right-bar-line
             (ly:stencil-aligned-to
               (make-bracket-bar-line (/ size 9) font-size 1 thick-bar-line)
               Y CENTER))
           (brace-left-bar-line
             (ly:stencil-aligned-to
               (make-brace-bar-line (/ size 9) font-size)
               Y CENTER))
           (strg-list (string->string-list strg))
           (find-bar-line-proc
              (lambda (x) (cond ((string=? ":" x) colon-bar-line)
                                ((string=? "|" x) thin-bar-line)
                                ((string=? "." x) thick-bar-line)
                                ((string=? "[" x) bracket-left-bar-line)
                                ((string=? "]" x) bracket-right-bar-line)
                                ((string=? "{" x) brace-left-bar-line)
                                (else empty-stencil))))
           (bar-line-stils
             (remove ly:stencil-empty? (map find-bar-line-proc strg-list)))
           (stil
             (stack-stencils X
                             RIGHT
                             (* (magstep font-size) kern)
                             bar-line-stils))
           (stil-y-length (interval-length (ly:stencil-extent stil Y))))
      ;; Hm, should the stencil-translate be hard-coded?
      (ly:stencil-translate-axis
        stil
        (/ stil-y-length 4)
        Y)))

\markup
  \fontsize #2
  \column
  \override #'(box-padding . 0.5)
{
    \line {
            "This is a starting-repeat-bar:"
            \hspace #1
              %\box
              \fontsize #-4
              \bar-line #".|:" 
          }
    \line {
            "This is a ending-repeat-bar."
            \hspace #1
            %\box
              \fontsize #-4
                \bar-line #":|."
    }
    \line {
            "These are simple bar-lines."
            \tiny "(colon, thin, thick)"
            \hspace #1
            %\box
              \fontsize #-4
              \bar-line #":"
            \hspace #1
            %\box
              \fontsize #-4
              \bar-line #"|"
            \hspace #1
            %\box
              \fontsize #-4
              \bar-line #"."
            \hspace #1
            %\box
              \fontsize #-4
              \bar-line #"["
            \hspace #2
            %\box
              \override #'(add-height . 5)
              \fontsize #-4
              \bar-line #"]"
           \hspace #2
           %\box
             \override #'(add-height . 5)
             \fontsize #-14
             \bar-line #"{"
    }
   
    \line {
            "Others."
            \hspace #1
            %\box
              \fontsize #-4
              \bar-line #":..:"
            \hspace #1
            %\box
              \fontsize #-4
              \bar-line #":|.|:"
            \hspace #1
            %\box
              \override #'(add-height . 15)
              \fontsize #-4
              \bar-line #":|..|:"
            \hspace #1
            %\box
              \override #'(add-height . 15)
              \fontsize #4
              \bar-line #":|]"
            \hspace #3
            %\box
              \override #'(add-height . 45)
              \fontsize #4
              \bar-line #"{|:"
    }
  }

Gruß,
  Harm

chf

  • Member
Re: Wiederholungszeichen über der Notenlinie
« Antwort #2 am: Mittwoch, 9. September 2015, 18:40 »
Hallo Harm,

besten Dank - wie immer!

Christa