lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Repeat volta not at beginning of piece doesn't get initial repeat ba


From: Thomas Morley
Subject: Re: Repeat volta not at beginning of piece doesn't get initial repeat bar line
Date: Sun, 27 Jul 2014 00:11:12 +0200

2014-07-19 14:59 GMT+02:00 John McWilliam <address@hidden>:
> That works for me too. Thanks!
> One last detail - I hope - when the difference between the first and
>
> second time involves a whole bar the spanners cannot be seperated by a
>
> transparent bar. In such cases is the following snippet acceptable or is
>
> there another tweak which can be used to seperate them?
> ................................
>
> \version "2.18.0"
>
> #(allow-volta-hook "|")
>
> music = \relative c''' {
>         \key c \major
>         \time 2/4
>         \bar ".|:"
>
>         \repeat volta 2 {
>           \partial 8 g8
>           a16. [g32 a16. f32] e8 [c32 a16.]
>           \set Score.repeatCommands = #'((volta "1."))
>           a8 a'16. [e32 f16. e32] c32 a16.
>           \set Score.repeatCommands = #'((volta #f)(volta "2."))
>           a'16. [g32 a16. e32] c32 [e16. a,16. e'32]
>           \set Score.repeatCommands = #'((volta #f))
>           c8 b b[ g']
>           \break
>           \set Score.measureLength = #(ly:make-moment 5 8)
>           a16. g32 a16. f32 e8
>           \set Score.repeatCommands = #'((volta "1."))
>           c32 [ a16.]
>           \once \hide Score.BarLine
>           \once \hide Score.SpanBar
>           \set Score.repeatCommands = #'((volta #f)(volta "2.") end-
>
> repeat)
>           c32 [e16.]
>           \set Score.repeatCommands = #'((volta #f))
>
>           \set Score.measureLength = #(ly:make-moment 4/8)
>           a,8 a'16. e32 f16. e32 c32 a16.
>           b16.[ c32 d16. e32] f32 [ a16. e16. b32]
>           c8 [a] a
>         }
>         \break
> } % end relative
>
> \score {
>    \new Staff \music
> }

Well, there's a reason why a closing volta-bracket isn't allowed per
default for bar-type "|", if two subsequent brackets are printed, a
horizontal gap will hardly appear.
(The value for the gap is calculated from the span-bar extent, if a
span-bar is present or not.)

You have two possibilities to get this gap.

(1) use 'shorten-pair to adjust the volta-brackets, with the
disadvantage of trial and error for the values.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\version "2.18.0"

#(allow-volta-hook "|")

music = \relative c''' {
        \key c \major
        \time 2/4
        \bar ".|:"

        \repeat volta 2 {
          \partial 8 g8
          a16. [g32 a16. f32] e8 [c32 a16.]
          \once \override Score.VoltaBracket.shorten-pair = #'(0 . 0.3)
          \set Score.repeatCommands = #'((volta "1."))
          a8 a'16. [e32 f16. e32] c32 a16.
          \once \override Score.VoltaBracket.shorten-pair = #'(0.5 . 0)
          \set Score.repeatCommands = #'((volta #f)(volta "2."))
          a'16. [g32 a16. e32] c32 [e16. a,16. e'32]
          \set Score.repeatCommands = #'((volta #f))
          c8 b b[ g']
          \break
          \set Score.measureLength = #(ly:make-moment 5 8)
          a16. g32 a16. f32 e8
          \set Score.repeatCommands = #'((volta "1."))
          c32 [ a16.]
          \once \hide Score.BarLine
          \once \hide Score.SpanBar
          \set Score.repeatCommands = #'((volta #f)(volta "2.") end-repeat)
          c32 [e16.]
          \set Score.repeatCommands = #'((volta #f))

          \set Score.measureLength = #(ly:make-moment 4/8)
          a,8 a'16. e32 f16. e32 c32 a16.
          b16.[ c32 d16. e32] f32 [ a16. e16. b32]
          c8 [a] a
        }
        \break
} % end relative

\score {
   \new Staff \music
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%

(2) define a new bar-line which mimics "|" but has more horizontal
extent. Much more involved coding, though very easy to use.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\version "2.18.0"

%% next two definitions are unchanged c/p from bar-line.scm
#(define (calc-blot thickness extent grob)
  "Calculate the blot diameter by taking @code{'rounded}
and the dimensions of the extent into account."
  (let* ((rounded (ly:grob-property grob 'rounded #f))
         (blot (if rounded
                   (let ((blot-diameter (layout-blot-diameter grob))
                         (height (interval-length extent)))

                     (cond ((< thickness blot-diameter) thickness)
                           ((< height blot-diameter) height)
                           (else blot-diameter)))
                   0)))

    blot))

#(define (make-simple-bar-line grob extent)
  "Draw a simple bar line."
  (let* ((line-thickness (layout-line-thickness grob))
         (thickness (* (ly:grob-property grob 'hair-thickness 1)
                       line-thickness))
         (blot (calc-blot thickness extent grob))
         (extent (bar-line::widen-bar-extent-on-span grob extent)))

    (ly:round-filled-box (cons 0 thickness)
                         extent
                         blot)))

#(define (make-thickier-thin-bar-line grob extent)
  "Draw a thin-bar line with more X-extent."
  (let* ((thin-stil (make-simple-bar-line grob extent))
         (line-thickness (layout-line-thickness grob))
         (thickness (* (ly:grob-property grob 'hair-thickness 1)
                       line-thickness))
         (kern (* (ly:grob-property grob 'kern 1) line-thickness))
         (x-width (cons 0 (* 4 kern)))
         (thickier-stil
           (ly:make-stencil
             ""
             x-width
             extent)))
             (display x-width)
    (ly:stencil-add
       thickier-stil
       (ly:stencil-translate-axis
         thin-stil
         (+ (/ (cdr x-width) 2) (* -0.5 thickness))
         X))))

#(add-bar-glyph-print-procedure "t" make-thickier-thin-bar-line)

#(define-bar-line "t" "t" #f "t")

#(allow-volta-hook "t")

musicI = \relative c''' {
        \key c \major
        \time 2/4
        \bar ".|:"

        \repeat volta 2 {
          \partial 8 g8
          a16. [g32 a16. f32] e8 [c32 a16.]
          \set Score.repeatCommands = #'((volta "1."))
          a8 a'16. [e32 f16. e32] c32 a16.
          \set Score.repeatCommands = #'((volta #f)(volta "2."))
          \bar "t"
          a'16. [g32 a16. e32] c32 [e16. a,16. e'32]
          \set Score.repeatCommands = #'((volta #f))
          c8 b b[ g']
          \break
          \set Score.measureLength = #(ly:make-moment 5 8)
          a16. g32 a16. f32 e8
          \set Score.repeatCommands = #'((volta "1."))
          c32 [ a16.]
          \once \hide Score.BarLine
          \once \hide Score.SpanBar
          \set Score.repeatCommands = #'((volta #f)(volta "2.") end-repeat)
          c32 [e16.]
          \set Score.repeatCommands = #'((volta #f))
          \set Score.measureLength = #(ly:make-moment 4/8)
          a,8 a'16. e32 f16. e32 c32 a16.
          b16.[ c32 d16. e32] f32 [ a16. e16. b32]
          c8 [a] a
        }
        \break
} % end relative

\score {
   \new Staff \musicI
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

HTH,
  Harm



reply via email to

[Prev in Thread] Current Thread [Next in Thread]