Hello Gilberto,

On 30.10.2015 18:49, Gilberto Agostinho wrote:
H. S. Teoh wrote
Very nice!  But shouldn't this be fixed in Lilypond itself, not just as
an external function?
Thanks! And sure, if people want to implement this idea in LilyPond itself
that would be ideal.

Thank you for this work! FWIW, I made a new version which basically sticks with the functionality and design you provided (except for extending it to 22da and, for the fun of it, 29na), but removes the code duplication, so it is easier to adapt.

I’ll add comments in the respective issues 3865 and 3866 also.

Yours, Simon
\version "2.19.28"

#(define-markup-command
  (format-ottava layout props dir interval)
  (integer? integer?)
  "Output a markup for use in { \\set Staff.ottavation }.
Takes as input the direction of ottavation (-1 or 1)
 and the interval (one of the numbers 8, 15, 22, 29)"
  (let* ((upward? (positive? dir))
         (number (number->string interval))
         (text (case interval
                 ((8) "va")
                 ((15) "ma")
                 ((22) "da")
                 ((29) "na")))
         (text (markup #:small text)))
    (interpret-markup layout props
      (markup
       #:concat (
                  number
                  #:raise (if upward? 0.6 0) text
                  )))))

ottavation =
#(define-music-function (number) (integer?)
   (let* ((direction (if (positive? number) UP DOWN))
          (right-text (make-draw-line-markup (cons 0 (if (> number 0) -.8 .8))))
          (interval (+ 1 (* 7 (abs number))))
          (ottavation-markup (make-format-ottava-markup direction interval)))
     (if
      (= number 0)
      #{
        \ottava #0
      #}
      #{
        \override Staff.OttavaBracket.stencil = #ly:line-spanner::print
        \override Staff.OttavaBracket.bound-details =
        #`((left . ((Y . 0.0)
                    (attach-dir . ,LEFT)
                    (padding . 0)
                    (stencil-align-dir-y . ,direction)))
           (right . ((Y . 0.0) ; Change the integer here
                      (padding . 0)
                      (attach-dir . ,RIGHT)
                      (text . ,right-text))))
        \override Staff.OttavaBracket.left-bound-info =
        #ly:line-spanner::calc-left-bound-info-and-text
        \override Staff.OttavaBracket.right-bound-info =
        #ly:line-spanner::calc-right-bound-info
        \ottava $number
        \set Staff.ottavation = $ottavation-markup
      #}
      )))

\relative c' {
  \ottavation #1
  c'4 c c c
  \ottavation #2
  c'4 c c c
  \ottavation #4
  c''4 c c c
  \ottavation #-1
  c,,,,,4 c c c
  \ottavation #-3
  c,,4 c c c
  \ottavation #0
  R1
}
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to