%% Generated by lilypond-book
%% Options: [exampleindent=10.16\mm,indent=0\mm,line-width=160\mm,paper-height=845.047\pt,paper-width=597.508\pt,papersize='(cons (* 597.508 pt) (* 845.047 pt))]
\include "lilypond-book-preamble.ly"


% ****************************************************************
% Start cut-&-pastable-section
% ****************************************************************

#(ly:set-option 'eps-box-padding 3.000000)



\paper {
  #(set-paper-size '(cons (* 597.508 pt) (* 845.047 pt)))
  indent = 0\mm
  line-width = 160\mm
  % offset the left padding, also add 1mm as lilypond creates cropped
  % images with a little space on the right
  line-width = #(- line-width (* mm  3.000000) (* mm 1))
}

\layout {
  
}




% ****************************************************************
% ly snippet:
% ****************************************************************
\sourcefilename "snippets/adding-indicators-to-staves-which-get-split-after-a-break.ly"
\sourcefileline 0
%% DO NOT EDIT this file manually; it was automatically
%% generated from the LilyPond Wiki
%% (https://wiki.lilypond.community).
%%
%% Make any changes in the Wiki itself, or in
%% `Documentation/snippets/new/`, then run
%% `scripts/auxiliar/makelsr.pl`.
%%
%% This file is in the public domain.

\version "2.24.0"

\header {
%% Translation of GIT committish: a8a85e19654e46d725563e6deba44083ef137a2c
  texidocja = "
このスニペットは @code{\\splitStaffBarLine}, @code{\\convUpStaffBarLine},
@code{\\convDownStaffBarLine} コマンドを追加します。@c
これらは小節線に矢印を追加し、譜を共有するボイスが次のシステムで@c
譜を分ける場合、あるいは再度合流する場合の指示を表示します。
"
  doctitleja = "改行後に分かれる譜について、指示を表示する"

%% Translation of GIT committish: c043783aac6c35926d633aa2daf60ed4f2e7ca7a
  texidocfr = "
Dans cet extrait sont définies les commandes @code{\\splitStaffBarLine},
@code{\\convUpStaffBarLine} et @code{\\convDownStaffBarLine}. Ces commandes
ajoutent une double flèche après la dernière barre de mesure d'une portée,
indiquant par là que ses différentes voix disposeront de leur propre
portée à la ligne suivante, ou bien se regrouperont.

Il est à noter que, dans l'implémentations ici proposée, sont dessinées
des flêches sans dimension dans la marge droite. Ceci ne devrait pas
poser de problème pour une impression normale. Il sera cependant
nécessaire d'agrandir horizontalement la boîte englobante, comme indiqué
ci-après, afin d'éviter le rognage lors d'une sortie sous forme d'image.
"

  doctitlefr = "Ajout d'indicateurs à une portée dédoublée après un saut de ligne"

%% Translation of GIT committish: beda50f64452870aee2823454a6cbd75b93f4825
  texidoces = "
Este fragmento de código define las instrucciones
@code{\\splitStaffBarLine}, @code{\\convUpStaffBarLine} y
@code{\\convDownStaffBarLine}, que añaden flechas en las sobre una
línea divisoria para denotar que cada una de las voces que
comparten un pentagrama continúan en su propio pentagrama en el
siguiente sistema, o que las voces así divididas se recombinan.

Observe que la implementación de este fragmento de código traza
unas flechas sin dimensiones en el margen derecho.  Para la
impresión formal, esto no produce ningún problema.  Sin embargo,
es necesario aumentar las dimensiones de la caja circundante en el
sentido horizontal si se procesa el código como imagen para evitar
el recorte, como se muestra abajo.

"
  doctitlees = "Añadir indicadores a los pentagramas que se dividen después de un salto de línea"

%% Translation of GIT committish: 0bed3bc9d8ad506e51c02faf95715e584e4bc335
  texidocca = "
Aquest fragment de codi defineix les ordres
@code{\\splitStaffBarLine}, @code{convUpStaffBarLine} i
@code{convDownStaffBarLine}, que afegeix una fletxa doble a
l'últim compàs d'un pentagrama, indicant que les diverses veus
disposaran d'un pentagrama propi a la línia següent.

"
  doctitleca = "Afegir indicadors als pentagrames que es divideixen després d'un salt de línia"

  categories = "Scheme, Staff notation, Symbols and glyphs, Vocal
                music"

  texidoc = "
This snippet defines the commands @code{\\splitStaffBarLine},
@code{\\convUpStaffBarLine}, and @code{\\convDownStaffBarLine}. These
add arrows at a bar line to denote that several voices sharing a staff
will each continue on a staff of their own in the next system, or that
voices split in this way recombine.

Note that the implementation in this snippet draws dimensionless arrows
into the right margin. For normal printing, this doesn't cause
problems. However, it is necessary to increase the bounding box
horizontally if you render the code as an image to avoid cropping, as
demonstrated below.
"

  doctitle = "Adding indicators to staves which get split after a break"
} % begin verbatim


#(define-markup-command (arrow-at-angle layout props angle-deg length fill)
   (number? number? boolean?)
   (let* ((PI-OVER-180 (/ (atan 1 1) 34))
          (degrees->radians (lambda (degrees) (* degrees PI-OVER-180)))
          (angle-rad (degrees->radians angle-deg))
          (target-x (* length (cos angle-rad)))
          (target-y (* length (sin angle-rad))))
     (interpret-markup layout props
       (markup
        #:translate (cons (/ target-x 2) (/ target-y 2))
        #:rotate angle-deg
        #:translate (cons (/ length -2) 0)
        #:concat (#:draw-line (cons length 0)
                   #:arrow-head X RIGHT fill)))))

splitStaffBarLineMarkup = \markup \with-dimensions #'(0 . 0) #'(0 . 0) {
  \combine
  \arrow-at-angle #45 #(sqrt 8) ##t
  \arrow-at-angle #-45 #(sqrt 8) ##t
}

splitStaffBarLine = {
  \once \override Staff.BarLine.stencil =
  #(lambda (grob)
     (ly:stencil-combine-at-edge
      (ly:bar-line::print grob)
      X RIGHT
      (grob-interpret-markup grob splitStaffBarLineMarkup)
      0))
  \break
}

convDownStaffBarLine = {
  \once \override Staff.BarLine.stencil =
  #(lambda (grob)
     (ly:stencil-combine-at-edge
      (ly:bar-line::print grob)
      X RIGHT
      (grob-interpret-markup grob #{
        \markup\with-dimensions #'(0 . 0) #'(0 . 0) {
          \translate #'(0 . -.13)\arrow-at-angle #-45 #(sqrt 8) ##t
        }#})
      0))
  \break
}

convUpStaffBarLine = {
  \once \override Staff.BarLine.stencil =
  #(lambda (grob)
     (ly:stencil-combine-at-edge
      (ly:bar-line::print grob)
      X RIGHT
      (grob-interpret-markup grob #{
        \markup\with-dimensions #'(0 . 0) #'(0 . 0) {
          \translate #'(0 . .14)\arrow-at-angle #45 #(sqrt 8) ##t
        }#})
      0))
  \break
}

\paper {
  indent = 10\mm
  short-indent = 10\mm
  line-width = 8\cm
}

separateSopranos = {
  \set Staff.instrumentName = "AI AII"
  \set Staff.shortInstrumentName = "AI AII"
  \splitStaffBarLine
  \change Staff = "up"
}
convSopranos = {
  \convDownStaffBarLine
  \change Staff = "shared"
  \set Staff.instrumentName = "S A"
  \set Staff.shortInstrumentName = "S A"
}

sI = {
  \voiceOne
  \repeat unfold 4 f''2
  \separateSopranos
  \repeat unfold 4 g''2
  \convSopranos
  \repeat unfold 4 c''2
}
sII = {
  s1*2
  \voiceTwo
  \change Staff = "up"
  \repeat unfold 4 d''2
}
aI = {
  \voiceTwo
  \repeat unfold 4 a'2
  \voiceOne
  \repeat unfold 4 b'2
  \convUpStaffBarLine
  \voiceTwo
  \repeat unfold 4 g'2
}
aII = {
  s1*2
  \voiceTwo
  \repeat unfold 4 g'2
}
ten = {
  \voiceOne
  \repeat unfold 4 c'2
  \repeat unfold 4 d'2
  \repeat unfold 4 c'2
}
bas = {
  \voiceTwo
  \repeat unfold 4 f2
  \repeat unfold 4 g2
  \repeat unfold 4 c2
}

\markup \pad-x #3  % avoid cropping
  \score {
    <<
      \new ChoirStaff <<
        \new Staff = up \with {
          instrumentName = "SI SII"
          shortInstrumentName = "SI SII"
        } {
          s1*4
        }

        \new Staff = shared \with {
          instrumentName = "S A"
          shortInstrumentName = "S A"
        } <<
          \new Voice = sopI \sI
          \new Voice = sopII \sII
          \new Voice = altI \aI
          \new Voice = altII \aII
        >>
        \new Lyrics \with {
          alignBelowContext = up
        }
        \lyricsto sopII { e f g h }
        \new Lyrics \lyricsto altI { a b c d e f g h i j k l }

        \new Staff = men \with {
          instrumentName = "T B"
          shortInstrumentName = "T B"
        } <<
          \clef F
          \new Voice = ten \ten
          \new Voice = bas \bas
        >>
        \new Lyrics \lyricsto bas { a b c d e f g h i j k l }
      >>
    >>

    \layout {
      \context {
        \Staff \RemoveEmptyStaves
        \override VerticalAxisGroup.remove-first = ##t
      }
    }
}



% ****************************************************************
% end ly snippet
% ****************************************************************
