On 30.10.2015 22:01, Gilberto Agostinho wrote:
Hi Simon, thanks for the improvements, I knew my function was utterly
inefficient but I have a hard time with Scheme.

I’ve had that too, but it gets better :-)

  Just two things about this
all:

Which modifications to your function should I do if I want to have only a
"8" text, without the "va"? Maybe we could create a \ottavation-no-text for
that.

Simply comment out (i.e. prefix with a ‘;’) the line
‘#:raise (if upward? 0.6 0) text’
(should be line 22).
Or use the attached version, where you can adjust the ‘display-ottavation-suffix’ variable at the beginning.

Second thing, try this code:

\relative c'' {
   R1*7
   \ottavation #1 c8 \ottavation #0 d, d d d d d d
}

It will output only "8va" without the vertical line. I believe that,
according to Gould, we always need to have the vertical "hook" in the end of
an 8va,

That has been extensively discussed already; I think there is a tracker issue also. Personally, I disagree with Gould here.
Anyway, it is only marginally related.

Yours, Simon
\version "2.19.28"
\paper { #(set-paper-size "a8landscape") indent = 0 }
#(ly:set-option 'point-and-click #f)
\header { tagline = ##f }

display-ottavation-suffix = ##f

#(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 (if display-ottavation-suffix
                   (case interval
                     ((8) "va")
                     ((15 22 29) "ma"))
                   ""))
         (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