\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 }