\version "2.12.1"
\header {
  title = 
		\markup 
			\fill-line { 
                          %     		\general-align #Y #0 \epsfile #X #10 #"logo_bcs.eps"
      	"Wenn die Sonn am Himmel lacht"
      	\null
				}
  composer = "Satz: Kurt Kämpfe"
%   tagline = \markup { \tiny "- Bergsteigerchor Sebnitz -"}
%   copyright = \markup {  \tiny "MH09" \char ##x00A9  \tiny "LilyPond" }
  tagline = #f
  copyright = \markup {
		\center-column {
			\null
			\line {
				\override #'(thickness . 2)
				\draw-line #'(-90 . 0)
				}			\null
			\line { \tiny "MH09" \char ##x00A9 \tiny "LilyPond" }
			\line {\tiny "- Bergsteigerchor Sebnitz -"}

			}
		}
	}
#(set-global-staff-size 17)

#(define (rest-score r)
  (let ((score 0)
	(yoff (ly:grob-property-data r 'Y-offset))
	(sp (ly:grob-property-data r 'staff-position)))
    (if (number? yoff)
	(set! score (+ score 2))
	(if (eq? yoff 'calculation-in-progress)
	    (set! score (- score 3))))
    (and (number? sp)
	 (<= 0 2 sp)
	 (set! score (+ score 2))
	 (set! score (- score (abs (- 1 sp)))))
    score))

#(define (merge-rests-on-positioning grob)
  (let* ((can-merge #f)
	 (elts (ly:grob-object grob 'elements))
	 (num-elts (and (ly:grob-array? elts)
			(ly:grob-array-length elts)))
	 (two-voice? (= num-elts 2)))
    (if two-voice?
	(let* ((v1-grob (ly:grob-array-ref elts 0))
	       (v2-grob (ly:grob-array-ref elts 1))
	       (v1-rest (ly:grob-object v1-grob 'rest))
	       (v2-rest (ly:grob-object v2-grob 'rest)))
	  (and
	   (ly:grob? v1-rest)
	   (ly:grob? v2-rest)	     	   
	   (let* ((v1-duration-log (ly:grob-property v1-rest 'duration-log))
		  (v2-duration-log (ly:grob-property v2-rest 'duration-log))
		  (v1-dot (ly:grob-object v1-rest 'dot))
		  (v2-dot (ly:grob-object v2-rest 'dot))
		  (v1-dot-count (and (ly:grob? v1-dot)
				     (ly:grob-property v1-dot 'dot-count -1)))
		  (v2-dot-count (and (ly:grob? v2-dot)
				     (ly:grob-property v2-dot 'dot-count -1))))
	     (set! can-merge
		   (and 
		    (number? v1-duration-log)
		    (number? v2-duration-log)
		    (= v1-duration-log v2-duration-log)
		    (eq? v1-dot-count v2-dot-count)))
	     (if can-merge
		 ;; keep the rest that looks best:
		 (let* ((keep-v1? (>= (rest-score v1-rest)
				      (rest-score v2-rest)))
			(rest-to-keep (if keep-v1? v1-rest v2-rest))
			(dot-to-kill (if keep-v1? v2-dot v1-dot)))
		   ;; uncomment if you're curious of which rest was chosen:
		   ;;(ly:grob-set-property! v1-rest 'color green)
		   ;;(ly:grob-set-property! v2-rest 'color blue)
		   (ly:grob-suicide! (if keep-v1? v2-rest v1-rest))
		   (if (ly:grob? dot-to-kill)
		       (ly:grob-suicide! dot-to-kill))
		   (ly:grob-set-property! rest-to-keep 'direction 0)
		   (ly:rest::y-offset-callback rest-to-keep)))))))
    (if can-merge
	#t
	(ly:rest-collision::calc-positioning-done grob))))
	
global = { \key c \major \time 4/4 }
globalTenorEins= {	
	\set midiInstrument = #"voice oohs" 
	\voiceOne
	}
globalTenorZwei= {	
	\set midiInstrument = #"choir aahs" 
	\voiceTwo
	}
globalBassEins= {	
	\set midiInstrument = #"choir aahs" 
	\voiceOne
	}
globalBassZwei= {	
	\set midiInstrument = #"choir aahs" 
	\voiceTwo
	}
TenEinsNotenAa =   	{
			g4. e8 g4 a | g c c2 \breathe | c4. e8 e4 e | e f f2\( |
			e4.\) c8 d4 b | c2. 
			} 
TenEinsNotenA = \relative c' {
	\context Voice="TENA" { 
		\globalTenorEins
		\TenEinsNotenAa
		s4
		\TenEinsNotenAa
	} }
TenEinsNotenB = \relative c' {
	\context Voice="TENB" {
		\globalTenorEins
		\breathe g4 | g'2 f4 e | e2 d4\( f\) | a2 g4 f | e2. \breathe c4 |
		a2 f'4. f8 | e2 c4.\( c8\) | d2 c4 d | e2. \breathe c4 |
		a2 f'4. f8 | e2 c4.\( c8\) | d2 c4 b | c2. r4 |
	} }
TenEinsNoten= {
	\TenEinsNotenA
	\TenEinsNotenB
	\bar "|."
	}
TenZweiNotenA = \relative c' {
	\context Voice="TZNA" {
		\globalTenorZwei 
		g4. e8 g4 a | g g g2 | g4. c8 c4 c | c c c2\( |
		c4.\) g8 a4 g | g2. 
		} }
TenZweiNotenB = \relative c' {
	\context Voice="TZNB" { 
		\globalTenorZwei
		g4 | c( e) d c | c2 b4 d | f2 e4 d | c2. c4 |
		a2 d4. d8 | c2 c4. a8 | a2 g4 b | c2. c4 |
		a2 d4. d8 | c2 c4. a8 | a2 g4 g | g2. r4
		} }
BassEinsNotenA =  \relative c {
	\context Voice="BENA" {
		\globalBassEins
		e4. c8 e4 f | e e e2 \breathe | e4. g8 g4 g | g a a2\( |
		g4.\) e8 f4 f | e2.
		} }
BassEinsNotenB =  \relative c {
	\context Voice="BENB" {
		\globalBassEins
		g'4 | g2 g4 g | g2 g4\( b\) | b2 g4 g | g2. g4 | 
		f2 a4. a8 | g4( gis) a g | f2 e4 g | g2. g4 |
		f2 a4. a8 | g4( gis) a g | f2 e4 f | e2. r4
		} }
BassZweiNotenA = \relative c {
	\context Voice="BZNA" {
		\globalBassZwei
		c4 g c g | c g c( g) | c g c g | c c f,\( a8 b |
		c4\) e f g | 
		} }
BassZweiNotenAa = \relative c  {
	\context Voice="BZNAa"  {
		\globalBassZwei
		 c4 g c s
		 } }
BassZweiNotenAb = \relative c {
	\context Voice="BZNAb" {
		\globalBassZwei
		c4 g c \breathe g'
		} }

BassZweiNotenBa = \relative c {
	\context Voice="BZNBa" {
		\globalBassZwei
		e4( c) b c | g( g') g g | g( g,) a b | c 
		} }
BassZweiNotenBb = \relative c {
	\context Voice="BZNBb" {
		\globalBassZwei
		c' g \breathe
		} }
BassZweiNotenBc = \relative c {
	\context Voice="BZNBc" {
		\globalBassZwei
		 e |f( e) d f | g( gis) a g | f( g,) g g | c
		} }
BassZweiNotenBd = \relative c {
	\context Voice="BZNBd" {
		\globalBassZwei
		c' g \breathe
		} }
BassZweiNotenBe = \relative c {
	\context Voice="BZNBe" {
		\globalBassZwei
		 e |f( e) d f | g( gis) a g | f( f,) g g | c2. r4
		} }

VersEins = \lyricmode { \set stanza = #"1."
Wenn die Sonn am Him -- mel lacht, ziehn wir zu der Ber -- ge Pracht, zu den Fel -- sen hin. Von den lich -- ten Fir -- nen -- höh'n woll'n wir uns -- re Ber -- ge sehn, wei -- ße Wol -- ken ziehn. }
VersDrei = \lyricmode { \set stanza = #"2."
Wenn im Tal auch Zwie -- tracht blüht, Hass und Neid im Men -- schen glüht, herz -- los, kalt und roh, wir, die in die Ber -- ge gehn, wol -- len fest zu -- sam -- men -- stehn, stark und frei und froh. }
VersZwei = \lyricmode { \set stanza = #"3."
Wenn wir auf dem Gi -- pfel steh'n, und ins Tal her -- nie -- der -- sehn, leu -- chtet un -- ser Blick. Je -- der denkt für sich al -- lein: Was kann denn wohl schö -- ner sein als dies Gi -- pfel -- glück. }
Refrain = \lyricmode { So las -- set euch sa -- gen: In Sturm und in Not den Ber -- gen die Treu -- e ist un -- ser Ge -- bot, den Ber -- gen die Treu -- e ist un -- ser Ge -- bot. }

\score {
	\new ChoirStaff \with { 
		\override RestCollision #'positioning-done = #merge-rests-on-positioning
		}
	{
	  <<
	    \context Staff="Tenöre"  { \set Staff.instrumentName = #"Tenor"

		  \global
			\clef "treble_8"
		  <<
				{ \TenEinsNoten}
				{ \TenZweiNotenA r4 \TenZweiNotenA \TenZweiNotenB}
		  >>
				    }
	    \context Lyrics ="lyricseins" \lyricsto "TENA" { \VersEins }
	    \context Lyrics ="lyricszwei" \lyricsto "TENA" { \VersZwei }
	    \context Lyrics ="lyricsrefr" \lyricsto "TENB" { \Refrain }
	    \context Lyrics ="lyricsdrei" \lyricsto "TENA" { \VersDrei }
	    \context Staff="Bass"  { \set Staff.instrumentName = #"Bass"
			  \global
				\clef "bass"
		  	<<
					{ \BassEinsNotenA r \BassEinsNotenA \BassEinsNotenB}
					{ \BassZweiNotenA \BassZweiNotenAa \BassZweiNotenA \BassZweiNotenAb
				    \BassZweiNotenBa \BassZweiNotenBb \BassZweiNotenBc \BassZweiNotenBd \BassZweiNotenBe}
				  >>
				}
	    \context Lyrics ="lyricsbasseinsAa" \lyricsto "BZNAa" { \set stanza = #"1." hin, ja hin. }
	    \context Lyrics ="lyricsbasseinsBa" \lyricsto "BZNBb" { in Not }
	    \context Lyrics ="lyricsbasszweiBb" \lyricsto "BZNBd" { Ge -- bot }        
	    \context Lyrics ="lyricsbasszweiAa" \lyricsto "BZNAa" { \set stanza = #"2." Blick, ja Blick. }  
	    \context Lyrics ="lyricsbassdreiAa" \lyricsto "BZNAa" { \set stanza = #"3." roh, ja roh. }
	    \context Lyrics ="lyricsbasseinsAb" \lyricsto "BZNAb" { \set stanza = #"1." ziehn, ja ziehn. }      
	    \context Lyrics ="lyricsbasszweiAb" \lyricsto "BZNAb" { \set stanza = #"2." -glück, ja Glück }
	    \context Lyrics ="lyricsbassdreiAb" \lyricsto "BZNAb" { \set stanza = #"3." froh, ja froh. }
	  >>
	}
	\layout { 
		\context {
			\Lyrics
			fontSize = #-2
 			\override VerticalAxisGroup  #'minimum-Y-extent = #'(-0 . 0)
		  }
		}
% 	\midi {
% 	\context {
% 	    \Voice
% 		\remove "Staff_performer"
% 		 }
%  	\context {
%       	    \Voice
%       		\consists "Staff_performer"      
% 		 }
% 	\context {
%       	    \Score
%       		tempoWholesPerMinute = #(ly:make-moment 120 4)
% 		 }
% 	}
	}
\paper 	{
%	indent = 5.0\cm
  ragged-last-bottom = ##f
 	page-count = 1
 	system-count = 5
	}
