git.fiddlerwoaroof.com
tomorrowmydancingday/tomorrowmydancingday.ly
70229ade
 \language "english"
 
 #(set-global-staff-size 14)
 #(set! paper-alist (cons '("my size" . (cons (* 4.5 in) (* 6.25 in))) paper-alist))
 
 #(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))))
 
 \paper {
   #(set-paper-size "my size")
 }
 
 
 
 
 
 \parallelMusic #'(soprano alto tenor bass) {
   \partial 4*1      c,4       | \partial 4*1 c4            | \partial 4*1 r4            | \partial 4*1 r4              |
   f4       f        g8(   a)  | f4 f g8( a)                | r2.                        | r2.                          |
   f4       f        a8(   bf) | f4 f f8( g)                | r2.                        | r2.                          |
   c4       c        d         | a4. g8 f4                  | r2.                        | r2.                          |
   bf2 \bar "||"     g8(   a)  | g2 \bar "||" d4            | r4 r4 \bar "||" bf,8( a)   | r4 r4 \bar "||"
   \break         g8(   f)  |
 
 
 
   bf4      bf       c        | g4.         f8    g4        | g4       g        c         | e4       e        e         |
   a4       a        f8(   a) | f4       f4       f4        | c4       c        d8( c)    | f4.         e8    d4        |
   g4       d        f        | d4.         c8    d4        | b4       a        b4        | g4       g        g         |
   e2 \bar "||"
   \break         c4       | c2 \bar "||"      c4        | c2 \bar "||"      r4        | c,2 \bar "||"     r4        |
 
 
 
   f4       f        g8(   a) | f4       f        g8( a)    | r2.                         | r2.                         |
   f4 f a8( bf)               | f4 f f8( g)                 | r2.                         | r2.                         |
   c4 c d                     | a4. g8 f4                   | r2.                         | r2.                         |
   bf2 \bar "||"     g8(   a) | g2 \bar "||"      d4        | r4 r4 \bar "||"   bf8( a)   | r4 r4 \bar "||"\break g'8 f |
 
 
 
   bf4      bf       c        | g4.         f8    g4        | g4       g        c         | e4.         d8    e4        |
   a4       a        f8(   a) | f4       f        f8( e)    | c4       c        c         | f4       f        a,        |
   g4       d        e        | d4       d4       c8(   bf) | bf8([d)] c([  bf)]a([   g)] | bf4      g        c         |
   f2 \bar "||"               | a2 \bar "||"                | f2 \bar "||"                | f,2 \bar "||"               |
 }
 
 \score {
   \header{
   }
 
   \new ChoirStaff  \with {
     \override RestCollision.positioning-done = #merge-rests-on-positioning
   }     <<
     \new Staff = "female" {
       \time 3/4
       \key f \major
       \new Voice = "women" <<
         \relative c'' {
           {\voiceOne \soprano}
         }
         \new Voice = "altos" {\relative c' { \voiceTwo \alto }}
       >>
     }
     \new Lyrics {
       \lyricsto "women" {
         \set stanza = #"1. "
         A -- way in a man -- ger, No crib for a bed,
         The lit -- tle Lord Je -- sus Laid down his sweet head.
         The stars in the bright sky Look'd down where he lay,
         The little Lord Je -- sus A -- sleep on the hay.
       }
     }
     \new Lyrics {
       \lyricsto "women" {
         \set stanza = #"2. "
         The cat -- tle are low -- ing, The ba -- by a -- wakes,
         But lit -- tle Lord Je -- sus No cry -- ing he makes.
         I love thee, Lord Je -- sus! Look down from the sky,
         And stay by my cra -- dle Till morn -- ing  is nigh.
       }
     }
     \new Lyrics {
       \lyricsto "women" {
         \set stanza = #"3. "
         Be near me, Lord Je -- sus; I ask thee to stay
         Close by me for -- ev -- er, And love me, I pray.
         Bless all the dear chil -- dren In thy ten -- der care,
         And fit us for hea -- ven, To live with thee there.
       }
     }
     \new Staff = "male" {
       \time 3/4
       \clef bass
       \key f \major
       \new Voice = "men" <<
         \relative c'' {
           {\voiceOne \tenor}
         }
         \new Voice = "basses" {\relative c' { \voiceTwo \bass }}
       >>
     }
   >>
 
 
   \layout {
     indent = 0.0\cm
     \context {
       \Lyrics
       \override LyricText #'font-size = #-2
     }
   }
   \midi { }
 }
 
 \version "2.18.2"  % necessary for upgrading to future LilyPond versions.