Jump to content

Maria durch ein Dornwald ging

From LilyPond wiki

German advent song with many features of Lilypond.

The setting is for playing on the organ on manual only.

\version "2.24"

\language "deutsch"
#(set-global-staff-size 21)
musicextrema =
#(define-music-function (mus)(ly:music?)
   (let*
    (
      (alle-pitches
       (let loop ((mus mus) (pitches '()))
         (let ((p  (ly:music-property mus 'pitch)))
           (if (ly:pitch? p)
               (cons p pitches)
               (let ((elt (ly:music-property mus 'element)))
                 (fold loop
                       (if (ly:music? elt)
                           (loop elt pitches)
                           pitches)
                       (ly:music-property mus 'elements)))))))
      (alle-sortiert (sort alle-pitches ly:pitch<?))
      (tief (car alle-sortiert))
      (hoch (car (reverse alle-sortiert)))
      )
    ;     (display tief )(display hoch)
    ;     (write-me "alle pitches----> " (list? alle-pitches))
    (make-music
     'SequentialMusic
     'elements
     (list
      (make-music
       'NoteEvent
       'duration
       (ly:make-duration 2)
       'pitch
       tief)
      (make-music
       'NoteEvent
       'pitch
       hoch
       'duration
       (ly:make-duration 2))))
    ))

dropLyrics =
#(define-scheme-function (l)(number?)
   #{
     \override LyricText.extra-offset = #`(0 . ,l)
     \override LyricHyphen.extra-offset = #`(0 . ,l)
     \override LyricExtender.extra-offset = #`(0 . ,l)
     \override StanzaNumber.extra-offset = #`(0 . ,l)
   #}
   )

raiseLyrics = {
  \revert LyricText.extra-offset
  \revert LyricHyphen.extra-offset
  \revert LyricExtender.extra-offset
  \revert StanzaNumber.extra-offset
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%% Akkordbezeichnungen und Contexte
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

#(define ((chord-name->german-markup-text-alteration B-instead-of-Bb) pitch lowercase?)
   (define (pitch-alteration-semitones pitch)
     (inexact->exact (round (* (ly:pitch-alteration pitch) 2))))

   (define (conditional-string-downcase str condition)
     (if condition
         (string-downcase str)
         str))
   (let* ((name (ly:pitch-notename pitch))
          (alt-semitones  (pitch-alteration-semitones pitch))
          (n-a (if (member (cons name alt-semitones) `((6 . -1) (6 . -1)))
                   (cons 7 (+ (if B-instead-of-Bb 1 1) alt-semitones))
                   (cons name alt-semitones))))
     (make-line-markup
      (list
       (make-simple-markup
        (conditional-string-downcase
         (vector-ref #("C" "D" "E" "F" "G" "A" "H" "B") (car n-a))
         lowercase?))
       (let ((alteration (/ (cdr n-a) 2)))
         (cond
          ((and (equal? lowercase? #f) (= alteration FLAT) (= (car n-a) 7)) (make-simple-markup ""))
          ((and (= alteration FLAT) (or (= (car n-a) 5) (= (car n-a) 2) )) (make-simple-markup "s"))
          ((= alteration FLAT) (make-simple-markup "es"))
          ((and (= alteration DOUBLE-FLAT) (or (= (car n-a) 5)(= (car n-a) 2) )) (make-simple-markup "ses"))
          ((= alteration DOUBLE-FLAT) (make-simple-markup "eses"))
          ((= alteration SHARP) (make-simple-markup "is"))
          ((= alteration DOUBLE-SHARP) (make-simple-markup "isis"))
          (else empty-markup)))))))

#(define (note-international->markup pitch lowercase?)
   "Return pitch markup for @var{pitch}."
   (define (accidental->markup alteration)
     "Return accidental markup for ALTERATION."
     (if (= alteration 0)
         (make-line-markup (list empty-markup))
         (conditional-kern-before
          (alteration->text-accidental-markup alteration)
          (= alteration FLAT) 0.094725)))
   (define (conditional-string-downcase str condition)
     (if condition
         (string-downcase str)
         str))
   (define (conditional-kern-before markup bool amount)
     "Add AMOUNT of space before MARKUP if BOOL is true."
     (if bool
         (make-line-markup
          (list (make-hspace-markup amount)
                markup))
         markup))
   (make-line-markup
    (list
     (make-simple-markup
      (conditional-string-downcase
       (vector-ref #("C" "D" "E" "F" "G" "A" "B") (ly:pitch-notename pitch))
       lowercase?))
     (accidental->markup (ly:pitch-alteration pitch)))))

mynote =
#(define-music-function (m)
   (ly:duration?)
   #{
     \override Score.RehearsalMark.break-align-symbols = #'(time-signature)
     \once \override Score.RehearsalMark.self-alignment-X = #-1
     \mark \markup \fontsize #-3.5 \note { $m } #UP
   #}
   )

\layout {
  \context {
    \Lyrics
     \override LyricText.font-size = #-2
    \override StanzaNumber.font-size = #-2
    \override LyricHyphen.whiteout = ##t
    \override LyricHyphen.layer = #10
    \override VerticalAxisGroup.staff-affinity = #0
    \override LyricText.self-alignment-X = #LEFT
   }

  \context {
    \ChordNames
    chordRootNamer = #note-international->markup
    noChordSymbol = ##f
    \override ChordName.self-alignment-X = #LEFT
    chordNameLowercaseMinor = ##f
    \override Rest.stencil = ##f
    chordChanges = ##f
    \override ChordName.font-size = #-1
  }
  \context {
    \ChordNames
    \name GermanChordNames
    \alias ChordNames
    chordRootNamer = #(chord-name->german-markup-text-alteration #f)
  }
  \context {
    \Score
    barNumberVisibility = #first-bar-number-invisible-and-no-parenthesized-bar-numbers
    \override BarNumber.after-line-breaking = ##f
    \override BarNumber.color = #(rgb-color 0.3 0.3 0.3)
    \override BarNumber.outside-staff-priority =##f
    \override BarNumber.padding = #0.5
    \override BarNumber.font-size = #-1.5
    \override BarNumber.layer = #-1
    \override BarNumber.self-alignment-X = #0
    \override BarNumber.break-visibility = #end-of-line-invisible
    \accepts GermanChordNames
  }
}

orgel =
%% Notensatz für Orgelnoten 4stimmig + Text + Harmonisierung + Umbrüche +
%% Stimme für Ambitus
#(define-music-function (sop alt ten bas amb akk stru lyr p nation)
   (ly:music? ly:music? ly:music? ly:music? ly:music?
              ly:music? ly:music? ly:music? ly:pitch? boolean?)
   (let*
    ((ober (if nation 'GermanChordNames 'ChordNames))
     )
    #{
      <<
        \new $ober \transpose c $p $akk
        \new PianoStaff
        <<
          \new Staff="up"
          <<
            \new Voice="Alt"
            {
              \voiceOne
              \transpose c $p $sop
            }
            \new NullVoice
            \with {
              \consists "Ambitus_engraver"
              \omit AmbitusAccidental
            }
            {
              \transpose c $p $amb
            }
            \new Voice { \voiceTwo \transpose c $p $alt }
          >>
          \new Lyrics \lyricsto Alt $lyr
          \new Staff="down"
          <<
            \new Voice {
              \voiceOne \transpose c $p $ten
            }
            \new Voice { \voiceTwo \transpose c $p $bas }
            \new NullVoice $stru
          >>
        >>
      >>
    #}
    ))

sop = \relative {
  \key g \major
  \tieDashed
  \autoBeamOff
  h4 e4 ~ e8 fis8 g4 h g fis8 e  fis4 ~ fis
  g4 8 8 a2 h r4 \bar "" \break
  g8[ a] h4. a8 h4 c8[ h]
  a4. g8 a4
  h8 a g4~ 8
  fis8 g8 g a8 g fis4~ 8 e8 fis4 fis \breathe
  \slurSolid
  e4. fis8 g4 h g8[ fis] e2
  \bar "|."
}

alt = \relative {
  h4
  h2 h2 h h h d
  d s4 d
  g4. fis8 g4 e
  fis4. e8 fis4
  d4
  e2 e
  dis4 dis8 cis dis2
  h2 e
  h4 h2
}

ten = \relative {
  \key g \major
  \clef bass
  g4
  g2 g g2 fis2
  g a g r4 h
  %g4. a8 g4 a8 g
  h2. a4
  a2. g4
  e2 g
  fis fis \breathe
  g g2
  g4 g2
}

bas = \relative {
  e4
  e2 e e dis
  e fis g, s4 g'
  % e4. d8
  e2. e4
  d2. g,4
  h2 h
  h h
  e e
  e4 e2
}

Akk=
\chordmode {
  e4:m q1 q4 a h2
  e2:m d g1
  g4. d8 g4 a:m
  d2. g4 e1:m h4. a8:7 h2
  e1:m
  e8:m h e2:m
}

lyr = \lyricmode {
  <<
    {
      \set stanza = #"1"
      Ma -- ri -- a durch ein Dorn -- wald _ ging.
    }
    \new Lyrics
    \with { alignAboveContext = down }
    {
      \set stanza = #"2"
      Was trug Ma -- ri -- a unter
      ih -- rem Herzen?
    }
    \new Lyrics
    \with { alignAboveContext = down }
    {
      \set stanza = #"3"
      Da ha_ben die Dor -- nen
      Ro -- sen ge -- tragen.
    }
  >>
  \dropLyrics #-2.9
  \set stanza = #"1-3:" Ky -- rie e -- lei -- son
  \raiseLyrics
  <<
    {
      \set stanza = #"1" Ma --  ri -- a durch ein Dorn -- wald ging,
      der _ hat in
      \set ignoreMelismata = ##t
      sie -- ben Jahr kein
      \set ignoreMelismata = ##f
      Laub ge -- tra -- gen.
    }
    \new Lyrics
    \with { alignAboveContext = down }
    {
      \set stanza = #"2"
      Ein klei -- nes Kind -- lein oh -- ne Schmer -- zen,
      das trug Ma -- ri -- a un -- ter ih -- rem Her -- zen.
    }
    \new Lyrics
    \with { alignAboveContext = down }
    {
      \set stanza = #"3"
      Als_das Kind -- lein durch den Wald ge -- tra -- gen,
      da ha_ben die Dor _ -- nen _
      Ro_sen ge -- tra -- gen.
    }
  >>
  \dropLyrics #-2.9
  \set stanza = #"1-3:" Je -- sus und Ma -- ri -- a.
}

\header {
  title = \markup "Maria durch ein Dornwald ging"
  composer = \markup \override #'(baseline-skip . 2)
  \right-column {
    "M&T: August Franz von Haxthausen""(1792-1866) 1850"
  }
  poet = \markup \override #'(baseline-skip . 2)
  \left-column {
    "arranged by Manuela"
    "for organ manualiter"
  }
}

Struktur =
{
  \override Score.NonMusicalPaperColumn.page-break-permission = ##f
  \override Score.SpacingSpanner.common-shortest-duration = #(ly:make-moment 1/2)
  \time 4/4
  \partial 4
  \mynote 4
}

\paper {
  #(include-special-characters)
  indent = #0
  tagline = ##f
  ragged-right = ##f
  ragged-last = ##f
  ragged-last-bottom = ##f
  print-all-headers = ##f
  print-page-number = ##f
  oddHeaderMarkup = ##f
  evenHeaderMarkup = ##f
  oddFooterMarkup = ##f
  top-margin = 25\mm
  bottom-margin = #top-margin
  line-width = 170\mm
  markup-markup-spacing.padding = #1
  markup-system-spacing.padding = #5
  ragged-last-bottom = ##t
  scoreTitleMarkup = #bookTitleMarkup
  bookTitleMarkup = ##f
}

\bookpart {
  #(for-each
    (lambda (p)
      (add-score
       (scorify-music #{
         {
           \orgel \sop \alt \ten \bas
           { \musicextrema \sop }
           \Akk
           {
             \Struktur
           }
           \lyr
           $p ##t
                      } #} )))
    (music-pitches #{
      {
        c b,
                   } #}
                   ))
}