lilypond-user
[Top][All Lists]
Advanced

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

Re: Dividing a measure with a dotted bar line


From: Thomas Morley
Subject: Re: Dividing a measure with a dotted bar line
Date: Sat, 17 Jan 2015 20:21:13 +0100

2015-01-17 18:32 GMT+01:00 Knute Snortum <address@hidden>:
> Thanks to everyone.  I think I have all the pieces now.
>
>
> Knute Snortum
> (via Gmail)



Hi,

I'm a little late to the party, though, below you'll find a more
generic suggestion to set intermediate BarLines.
Line-breaks are forbidden with this additional BarLine. It can be done
selective. The glyph for the bar can be chosen freely, as well as the
musical moment.

Limitations:
It has to be set for the current context.
Longer notes, continuing over the added bar will preserve printing the
additional BarLine.


\version "2.18.2"

#(define (define-translator-property symbol type? description)
  (if (not (and (symbol? symbol)
    (procedure? type?)
    (string? description)))
      (ly:error "error in call of define-translator-property"))
  (if (not (equal? (object-property symbol 'translation-doc) #f))
      (ly:error (_ "symbol ~S redefined") symbol))
  (set-object-property! symbol 'translation-type? type?)
  (set-object-property! symbol 'translation-doc description)
  symbol)

#(for-each
  (lambda (x)
    (apply define-translator-property x))
      `(
        (intermediate-bar-line
          ,boolean?
          "Should an intermediate bar-line be printed?")))

#(define*
  ((intermediate-bar-line-engraver moment #:optional (glyph "!")) context)
  "
   inserts additional BarLines at @var{moment}
   a line-break there is forbidden
   the bar-line-glyph to insert @var{glyph} is made optional, default is \"!\"
   limitation: no intermediate BarLine is printed, if a longer note continues
  "
   `(
     ;; Not sure if the following 'acknowledgers' is needed at all
     (acknowledgers
      (paper-column-interface
       . ,(lambda (engraver grob source-engraver)
            (let ((internal-bar
                    (ly:context-property context 'internalBarNumber))
                  (measurepos
                    (ly:context-property context 'measurePosition)))
            (if (eq? moment (ly:moment-main measurepos))
                (set! (ly:grob-property grob 'line-break-permission) '()))))))

     (process-music
      . ,(lambda (engraver)
           (let ((measurepos
                   (ly:context-property context 'measurePosition))
                 (intermediate-bar-line?
                   (ly:context-property context 'intermediate-bar-line)))
             (if (and (= moment (ly:moment-main measurepos))
                      intermediate-bar-line?)
                 (let* ((event '())
                        (newgrob
                          (ly:engraver-make-grob engraver 'BarLine event)))
                   (set! (ly:grob-property newgrob 'glyph) glyph))))))))

#(define* (intermediateBars moment #:optional (glyph "!"))
"
 shortcut to insert the @code{intermediate-bar-line-engraver} into layout
"
  #{
    \layout {
      \context {
        \Staff
        \consists #(intermediate-bar-line-engraver moment glyph)
      }
    }
  #})

intermediateBarLineOff = \set Score.intermediate-bar-line = ##f
intermediateBarLineOn = \unset Score.intermediate-bar-line

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  EXAMPLES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\paper { ragged-last-bottom = ##f }

\header {
  title = \markup \column { "intermediate-bar-line-engraver" \vspace #2 }
}

\layout { \override TextScript.font-size = #-2 }

Noten = { \repeat unfold #7 { c2 c4 \break b b as g } }

annotation =
<>^\markup
    \override #'(baseline-skip . 2)
    \rounded-box
    \column { "Intermediate BarLine" "is unset in this bar." }

staff =
  \new Staff {
    \compoundMeter #'((4 4) (3 4))
    \set Timing.beamExceptions = #'()
    \set Timing.beatStructure = #'(2 2 3)
    \relative c'' {
      \Noten
      \intermediateBarLineOff
      \annotation
      \repeat unfold 14 c8
      \intermediateBarLineOn
      \Noten
      }
    }

\score {
  \staff
  \layout { $(intermediateBars 4/4) }
  %% omitting \layout would work as well
  %$(intermediateBars 4/4)
  \header {
    piece =
      \markup \bold
      "Example 1, dashed BarLine after 4th quarter"
  }
}

\score {
  \staff
  \layout { $(intermediateBars 3/4) }
  \header {
    piece =
      \markup \bold
      "Example 2, dashed BarLine after 3rd quarter"
  }
}

\score {
  \staff
  \layout { $(intermediateBars 4/4 "||") }
  \header {
    piece =
      \markup \bold
      "Example 3, double BarLine after 4th quarter"
  }
}

\score {
  \new Staff { \compoundMeter #'((4 4) (3 4)) c2.~ c1 c2.~ c1 }
  \layout { $(intermediateBars 4/4 "||") }
  \header {
    piece =
      \markup \bold
      "Example 4, Limitation: no intermediate BarLine is printed,
if a longer note continues."
  }
}


HTH,
  Harm



reply via email to

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