\version "2.10.10"

\include "english.ly"
\include "../mrlUtil.ly"
\include "../mrlSwash.ly"

#(ly:set-option 'point-and-click #f)

#(set-global-staff-size 20)

\paper {
  #(set-paper-size "letter")
  top-margin = .5\in
  bottom-margin = .5\in
  left-margin = .75\in
  line-width = 7\in
  between-system-padding = 0.05\in
  page-top-space = 0\in
  %ragged-last-bottom = ##t
  
  myStaffSize = #20
  #(define fonts
    (make-pango-font-tree "Adobe Garamond Pro"
                          "Sans"
                          "Mono"
                           (/ myStaffSize 20)))
}

%smallCapsACode = #smallCapsACodeLL
%oldStyleZeroCode = #oldStyleZeroCodeLL

engravedLine = #(string-append "Engraved by LilyPond " (lilypond-version))

\header {
	composer = \markup { \realCaps "William Byrd" \oldStyleNum "(c. 1540–1623)" }
    %subtitle = ""
    %poet = ""
    opus = \markup { \italic "Parthenia" \oldStyleNum "(1612/13)," "vi" }
	title = \markup { \medium \italic \makeSwashMarkupG "Pavana The Earle of Salisbury" }
    tagline = ""
    copyright = \markup { \smaller \center-align {
        "Edition copyright © 2007 by Michael Lauer."
        "This edition may be freely distributed, duplicated, performed, or recorded." 
        \engravedLine } } 

}

#(define-markup-command (fcol layout props markups) (markup-list?)
  "Print a column of fingering indications--use a reasonable baseline-skip."
  (interpret-markup layout props
    (markup
        (#:left-align
        (#:override '(baseline-skip . 1.5)
            (#:finger (make-center-align-markup markups) ))))))

global = {
  % main
  %\set Staff.forceClef = ##t
  %\set Staff.forceTime = ##f
  %\set Timing.defaultBarType = ""

  \set Staff.midiInstrument = "harpsichord"
  
  \override Staff.VerticalAxisGroup #'minimum-Y-extent = #'(-1 . 1)

  \set followVoice = ##t
  
  %\override NoteHead #'style = #'baroque
  
  \key a \minor
  
  \time 4/2
  \repeat volta 2 {
      \skip 2*16
  }
  \repeat volta 2 {
      \skip 2*4
      \tag #'lower { \clef treble }
      \skip 2*4
      \tag #'lower { \clef bass }
      \skip 2*4
  } \alternative {
      { \skip 2*4 }
      { \skip 2*4 }
  }
  \bar "|."

}

up = \tag #'scoreOnly { \change Staff = treble }
down = \tag #'scoreOnly { \change Staff = bass }

voiceI = 
    \relative a' {
        \context Voice = "I"
        \voiceOne
        \set fingeringOrientations = #'(up)
        \repeat volta 2
        {
            r4 a2-4 c4:16 b2.^\markup \fcol { 5 2 1 } e,4 |
            fs8.:32^\markup \fcol { 3 1 } g16 a2 gs4:16-4 a2 r4 a4-4 |
            c2:16 r8 c8 b:32 a b2 r8 b8 a:32 g |
            a2.-5 a4 gs1:16^\markup \fcol { 4 2 } |
        }
        \repeat volta 2
        {
            c,2:16-2 d-3 e4.:16-4 d8 \down c4 \up g'^\markup \fcol { 2 1 } |
            c2:16-4 d-5 e4.:16^\markup \fcol { 4 2 } 
                d8 c4 e4~ ^\markup \fcol { 5 3 } |
            e4 d4.:16 e8 c4^\markup \fcol { 3 1} b4.:16^\markup \fcol { 4 2 } 
                a8 gs:32 a b c |
        } \alternative {
            { b8:32-4 a-3 a2-5 gs4:16-4 a1^\markup \fcol { 5 2 } | }
            { b8:32-4 a-3 a2-5 gs4:16-4 a1\fermata^\markup \fcol { 5 2 } | }
        }
    }
    
voiceII =
    \relative c' {
        \context Voice = "II"
        \voiceTwo
        \set fingeringOrientations = #'(up)
        \repeat volta 2
        {
            <c e>1:16 <b e>2. s4 |
            r2 <d-2>2 cs1:16 |
            s2*4 |
            r8 <e-3>8 d8:32 c d2^\markup \fcol { "2-1" } e2. b4 |
        }
        \repeat volta 2
        {
            s4 <a-1>2 <b-1>4 s2. e4~ |
            e4 <a-2>2 <b-1>4 c4. s4. c4:16 |
            b2:16 s4 a4 gs s2. |
        } \alternative {
            { s2 <e-2>4. d8 cs2.:16 b4 | }
            { s2 <e-2>4. d8 cs1:16 | }
        }
    }
    
voiceIII =
    \relative a {
        \context Voice = "III"
        \voiceOne
        \set fingeringOrientations = #'(down)
        \repeat volta 2
        {
            a4. a8 e4 a2 gs8:32-2 fs gs a b-2 c-1 |
            <a d>4_\markup \fcol { 1 1 3} a b2 
                e,4._\markup \fcol { 2 5 } a8 e2:16 |
            r4 e'4-2 f2:16-1 r8 f8 e:32 d <b e>2_\markup \fcol { 1 4 } |
            c2:16_\markup \fcol { 2 5 } r8 c8-2 b:32-1 a-2 b2 s2 |
        }
        \repeat volta 2
        {
            s1 c1 |
            r8 c8-1 f4.:16-2  d8-4 g4-1 g2^\markup \fcol { 1 4 } a2 |
            e1_\markup \fcol { "2-1" 5 } r4 e2 d4~:16-2 |
        } \alternative {
            { d8 e8 c4:16 b2_\markup \fcol { 1 "5-2" } a2. s4 | }
            { d8 e8 c4:16 b2_\markup \fcol { 1 "5-2" } a1\fermata | }
        }
    }

voiceIV =
    \relative a, {
        \context Voice = "IV"
        \voiceTwo
        \set fingeringOrientations = #'(down)
        \repeat volta 2
        {
            <a e'>1 e'2_\markup \fcol { "2-4" } e2 |
            d4. c8 b2 a1 |
            a'1_\markup \fcol { "1-5" } g |
            f1 e4._\markup \fcol { 1 "4-2" } b8-3 e,4-5 e'~ |
        }
        \repeat volta 2
        {
            e8-3 c-5 f4.:16-2 b8-1 g4-2 <c, g'>1 |
            s1 c'2 <a e'>2 |
            gs2. a4-3 e1 |
        } \alternative {
            { e2 e <a, e'>2. e'4 | }
            { e2 e <a, e'>1\fermata | }
        }
    }
    
    
theMusic =  
\context PianoStaff <<
	\context Staff = "treble" <<
	    \removeWithTag #'lower \global 
	    \clef treble
	    \voiceI
	    \voiceII 
	>>
	\context Staff = "bass" <<
	    \global
	    \clef bass
        \voiceIII
        \voiceIV
	>>
    >>
    
% a different staff for each voice
midiMusic =  
\context StaffGroup <<
	\context Staff = "treble" <<
	    \removeWithTag #'lower \global 
	    \clef treble
	    \voiceI
	>>
	\context Staff = "treble II" <<
	    \removeWithTag #'lower \global 
	    \clef treble
	    \voiceII 
	>>
	\context Staff = "bass" <<
	    \global
	    \clef bass
        \voiceIII
	>>
	\context Staff = "bass  II" <<
	    \global
	    \clef bass
        \voiceIV
	>>
    >>
    
\score {
  %\removeWithTag #'incipit \theMusic
  \theMusic
  \layout {
    \context {
      \Score
      \override MetronomeMark #'transparent = ##t
      \override BarNumber #'padding = #2
      %\override BarLine #'transparent = ##t
      %\remove "System_start_delimiter_engraver"
    }
    \context {
      \Voice
      \override StemTremolo #'beam-thickness = #.3
      %\override NoteHead #'style = #'baroque
    }
    \context {
      \Staff
      %\remove "Time_signature_engraver"
    }
  }
}

\score {
  \unfoldRepeats \keepWithTag #'midiOnly \midiMusic
  
  \midi {
    \context {
      \Score
      tempoWholesPerMinute = #(ly:make-moment 40 2)
      }
    }



 }