%% 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 "/lilypond-2.26.0/input/regression/musicxml/13e-KeySignatures-Cancel.xml"
\sourcefileline 0
\version "2.26.0"
% automatically converted by musicxml2ly from -
\pointAndClickOff

%% additional definitions required by the score:
cancelAfterKey = {
  \once \set Staff.printKeyCancellation = ##t
  \once \override Score.BreakAlignment.break-align-orders =
  #(grob-transformer
    'break-align-orders
    (lambda (grob orig)
      (let* ((middle (vector-ref orig 1))
             (middle (delq 'key-signature middle))
             (middle (insert-before 'key-cancellation 'key-signature middle)))
        (vector
         (vector-ref orig 0)
         middle
         (vector-ref orig 2)))))
}

cancelBeforeBarline = {
  \once \set Staff.printKeyCancellation = ##t
  \once \override Score.BreakAlignment.break-align-orders =
  #(grob-transformer
    'break-align-orders
    (lambda (grob orig)
      (let* ((middle (vector-ref orig 1))
             (middle (delq 'key-cancellation middle))
             (middle (insert-before 'staff-bar 'key-cancellation middle)))
        (vector
         (vector-ref orig 0)
         middle
         (vector-ref orig 2)))))
}

#(define (insert-before where what lst)
   (cond ((null? lst)
          (list what))
         ((eq? where (car lst))
          (cons what lst))
         (else
          (cons (car lst) (insert-before where what (cdr lst))))))


\header {
  texidoc = "Tests of key signature cancellation: in measure 2 it is positioned
    at the default location (which usually means that the cancellation comes
    immediately after the bar line), in measure 3 it uses the attribute
    ‘location=\"right\"’ (i.e., the cancellation comes after the new key
    signature), in measure 4 it uses ‘location=\"before-barline\"’, and in
    measure 5 it uses the attribute ‘location=\"left\"’ (the cancellation comes
    before the new key signature).

    The <cancel> element's value (4) in the last measure intentionally doesn't
    correspond to the value of the previous <fifths> value (2) for testing
    purposes."
}
\layout {
  \context {
    \Staff
    printKeyCancellation = ##f
  }
  \context {
    \Score
    autoBeaming = ##f
  }
}
PartPOneVoiceOne = \relative c' {
  \clef "treble" \time 2/4 \key a \major c2 | % 1
  \once \set Staff.printKeyCancellation = ##t \key des \major c2 | % 2
  \cancelAfterKey \key es \major c2 | % 3
  \cancelBeforeBarline \key d \major c2 | % 4
  \once \set Staff.printKeyCancellation = ##t \key bes \major c2 \bar "|."
}


% The score definition
\score {
  <<
    \new Staff = "P1" <<
      \context Staff <<
        \override Staff.BarLine.allow-span-bar = ##f
        \mergeDifferentlyDottedOn
        \mergeDifferentlyHeadedOn
        \context Voice = "PartPOneVoiceOne" {
          \PartPOneVoiceOne
        }
      >>
    >>
  >>
  \layout {}
  % To create MIDI output, uncomment the following line:
  % \midi { \tempo 4 = 100 }
}




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