LilyPond snippets: Templates

# Templates

## Vorlage für Alte Notation – moderne Transkription des gregorianischen Chorals

Dieses Beispiel zeigt eine moderne Transkription des Gregorianischen Chorals. Hier gibt es keine Takte, keine Notenhälse und es werden nur halbe und Viertelnoten verwendet. Zusätzliche Zeichen zeigen die Länge von Pausen an.

    \include "gregorian.ly"

    chant = \relative c' {
      \set Score.timing = ##f
      f4 a2 \divisioMinima
      g4 b a2 f2 \divisioMaior
      g4( f) f( g) a2 \finalis
    }

    verba = \lyricmode {
      Lo -- rem ip -- sum do -- lor sit a -- met
    }

    \score {
      \new Staff <<
        \new Voice = "melody" \chant
        \new Lyrics = "one" \lyricsto melody \verba
      >>
      \layout {
        \context {
          \Staff
          \remove "Time_signature_engraver"
          \remove "Bar_engraver"
          \hide Stem
        }
        \context {
          \Voice
          \override Stem.length = #0
        }
        \context {
          \Score
          barAlways = ##t
        }
      }
    }

## Vorlage für anglikanischen Psalm

Diese Vorlage zeigt eine Art, anglikanische Psalmengesänge zu setzen. Hier wird auch gezeigt, wie Strophen als einfacher Text unter den Noten hinzugefügt werden können. Zwei Strophen sind in unterschiedlicher Weise notiert um mehr Möglichkeiten darzustellen.

    SopranoMusic = \relative g' {
      g1 | c2 b | a1 | \bar "||"
      a1 | d2 c | c b | c1 | \bar "||"
    }

    AltoMusic = \relative c' {
      e1 | g2 g | f1 |
      f1 | f2 e | d d | e1 |
    }

    TenorMusic = \relative a {
      c1 | c2 c | c1 |
      d1 | g,2 g | g g | g1 |
    }

    BassMusic =  \relative c {
      c1 | e2 e | f1 |
      d1 | b2 c | g' g | c,1 |
    }

    global = {
      \time 2/2
    }

    dot = \markup {
      \raise #0.7 \musicglyph "dots.dot"
    }

    tick = \markup {
      \raise #1 \fontsize #-5 \musicglyph "scripts.rvarcomma"
    }

    % Use markup to center the chant on the page
    \markup {
      \fill-line {
        \score {  % centered
          <<
            \new ChoirStaff <<
              \new Staff <<
                \global
                \clef "treble"
                \new Voice = "Soprano" <<
                  \voiceOne
                  \SopranoMusic
                >>
                \new Voice = "Alto" <<
                  \voiceTwo
                  \AltoMusic
                >>
              >>
              \new Staff <<
                \clef "bass"
                \global
                \new Voice = "Tenor" <<
                  \voiceOne
                  \TenorMusic
                >>
                \new Voice = "Bass" <<
                  \voiceTwo
                  \BassMusic
                >>
              >>
            >>
          >>
          \layout {
            \context {
              \Score
              \override SpacingSpanner.base-shortest-duration = #(ly:make-moment 1/2)
            }
            \context {
              \Staff
              \remove "Time_signature_engraver"
            }
          }
        }  % End score
      }
    }  % End markup

    \markup {
      \fill-line {
        \column {
          \left-align {
            \null \null \null
            \line {
              \fontsize #5 O
              \fontsize #3 come
              let us \bold sing | unto \dot the | Lord : let
            }
            \line {
              us heartily
              \concat { re \bold joice }
              in the | strength of | our
            }
            \line {
              sal | vation.
            }
            \null
            \line {
              \hspace #2.5 8. Today if ye will hear his voice *
            }
            \line {
              \concat { \bold hard en }
              \tick not your \tick hearts : as in the pro-
            }
            \line {
              vocation * and as in the \bold day of tempt- \tick
            }
            \line {
              -ation \tick in the \tick wilderness.
            }
          }
        }
      }
    }

## Hymnus-Vorlage

Dieses Beispiel zeigt eine Möglichkeit, eine Hymnusmelodie zu setzen, in der jede Zeile mit einem Auftakt beginnt und einem unvollständigen Takt abschließt. Es zeigt auch, wie man die Strophen als allein stehenden Text unter die Noten hinzufügt.

    Timeline = {
      \time 4/4
      \tempo 4=96
      \partial 2
      s2 | s1 | s2 \breathe s2 | s1 | s2 \bar "||" \break
      s2 | s1 | s2 \breathe s2 | s1 | s2 \bar "||"
    }

    SopranoMusic = \relative g' {
      g4 g | g g g g | g g g g | g g g g | g2
      g4 g | g g g g | g g g g | g g g g | g2
    }

    AltoMusic = \relative c' {
      d4 d | d d d d | d d d d | d d d d | d2
      d4 d | d d d d | d d d d | d d d d | d2
    }

    TenorMusic = \relative a {
      b4 b | b b b b | b b b b | b b b b | b2
      b4 b | b b b b | b b b b | b b b b | b2
    }

    BassMusic =  \relative g {
      g4 g | g g g g | g g g g | g g g g | g2
      g4 g | g g g g | g g g g | g g g g | g2
    }

    global = {
     \key g \major
    }

    \score {  % Start score
      <<
        \new PianoStaff <<  % Start pianostaff
          \new Staff <<  % Start Staff = RH
            \global
            \clef "treble"
            \new Voice = "Soprano" <<  % Start Voice = "Soprano"
              \Timeline
              \voiceOne
              \SopranoMusic
            >>  % End Voice = "Soprano"
            \new Voice = "Alto" <<  % Start Voice = "Alto"
              \Timeline
              \voiceTwo
              \AltoMusic
            >>  % End Voice = "Alto"
          >>  % End Staff = RH
          \new Staff <<  % Start Staff = LH
            \global
            \clef "bass"
            \new Voice = "Tenor" <<  % Start Voice = "Tenor"
              \Timeline
              \voiceOne
              \TenorMusic
            >>  % End Voice = "Tenor"
            \new Voice = "Bass" <<  % Start Voice = "Bass"
              \Timeline
              \voiceTwo
              \BassMusic
            >>  % End Voice = "Bass"
          >>  % End Staff = LH
        >>  % End pianostaff
      >>
    }  % End score

    \markup {
      \fill-line {
        ""
        {
          \column {
            \left-align {
              "This is line one of the first verse"
              "This is line two of the same"
              "And here's line three of the first verse"
              "And the last line of the same"
            }
          }
        }
        ""
      }
    }

    \paper {  % Start paper block
      indent = 0     % don't indent first system
      line-width = 130   % shorten line length to suit music
    }  % End paper block

## Vorlage für Jazz-Combo

Hier ist ein ziemlich kompliziertes Beispiel für ein Jazz-Ensemble. Achtung: Alle Instrumente sind in `\key c \major` (C-Dur) notiert. Das bezieht sich auf die klingende Musik: LilyPond transponiert die Tonart automatisch, wenn sich die Noten innerhalb eines `ranspose`-Abschnitts befinden.

    \header {
      title = "Song"
      subtitle = "(tune)"
      composer = "Me"
      meter = "moderato"
      piece = "Swing"
      tagline = \markup {
        \column {
          "LilyPond example file by Amelie Zapf,"
          "Berlin 07/07/2003"
        }
      }
    }
    % To make the example display in the documentation
    \paper {
      paper-width = 130
    }
    %#(set-global-staff-size 16)
    \include "english.ly"

    %%%%%%%%%%%% Some macros %%%%%%%%%%%%%%%%%%%

    sl = {
      \override NoteHead.style = #'slash
      \hide Stem
    }
    nsl = {
      \revert NoteHead.style
      \undo \hide Stem
    }
    crOn = \override NoteHead.style = #'cross
    crOff = \revert NoteHead.style

    %% insert chord name style stuff here.

    jazzChords = { }

    %%%%%%%%%%%% Keys'n'thangs %%%%%%%%%%%%%%%%%

    global = { \time 4/4 }

    Key = { \key c \major }

    % ############ Horns ############

    % ------ Trumpet ------
    trpt = \transpose c d \relative c'' {
      \Key
      c1 | c | c |
    }
    trpHarmony = \transpose c' d {
      \jazzChords
    }
    trumpet = {
      \global
      \clef treble
      <<
        \trpt
      >>
    }

    % ------ Alto Saxophone ------
    alto = \transpose c a \relative c' {
      \Key
      c1 | c | c |
    }
    altoHarmony = \transpose c' a {
      \jazzChords
    }
    altoSax = {
      \global
      \clef treble
      <<
        \alto
      >>
    }

    % ------ Baritone Saxophone ------
    bari = \transpose c a' \relative c {
      \Key
      c1
      c1
      \sl
      d4^"Solo" d d d
      \nsl
    }
    bariHarmony = \transpose c' a \chordmode {
      \jazzChords s1 s d2:maj e:m7
    }
    bariSax = {
      \global
      \clef treble
      <<
        \bari
      >>
    }

    % ------ Trombone ------
    tbone = \relative c {
      \Key
      c1 | c | c
    }
    tboneHarmony = \chordmode {
      \jazzChords
    }
    trombone = {
      \global
      \clef bass
      <<
        \tbone
      >>
    }

    % ############ Rhythm Section #############

    % ------ Guitar ------
    gtr = \relative c'' {
      \Key
      c1
      \sl
      b4 b b b
      \nsl
      c1
    }
    gtrHarmony = \chordmode {
      \jazzChords
      s1 c2:min7+ d2:maj9
    }
    guitar = {
      \global
      \clef treble
      <<
        \gtr
      >>
    }

    %% ------ Piano ------
    rhUpper = \relative c'' {
      \voiceOne
      \Key
      c1 | c | c
    }
    rhLower = \relative c' {
      \voiceTwo
      \Key
      e1 | e | e
    }

    lhUpper = \relative c' {
      \voiceOne
      \Key
      g1 | g | g
    }
    lhLower = \relative c {
      \voiceTwo
      \Key
      c1 | c | c
    }

    PianoRH = {
      \clef treble
      \global
      <<
        \new Voice = "one" \rhUpper
        \new Voice = "two" \rhLower
      >>
    }
    PianoLH = {
      \clef bass
      \global
      <<
        \new Voice = "one" \lhUpper
        \new Voice = "two" \lhLower
      >>
    }

    piano = {
      <<
        \new Staff = "upper" \PianoRH
        \new Staff = "lower" \PianoLH
      >>
    }

    % ------ Bass Guitar ------
    Bass = \relative c {
      \Key
      c1 | c | c
    }
    bass = {
      \global
      \clef bass
      <<
        \Bass
      >>
    }

    % ------ Drums ------
    up = \drummode {
      \voiceOne
      hh4 <hh sn> hh <hh sn>
      hh4 <hh sn> hh <hh sn>
      hh4 <hh sn> hh <hh sn>
    }
    down = \drummode {
      \voiceTwo
      bd4 s bd s
      bd4 s bd s
      bd4 s bd s
    }

    drumContents = {
      \global
      <<
        \new DrumVoice \up
        \new DrumVoice \down
      >>
    }

    %%%%%%%%% It All Goes Together Here %%%%%%%%%%%%%%%%%%%%%%

    \score {
      <<
        \new StaffGroup = "horns" <<
          \new Staff = "trumpet" \with { instrumentName = "Trumpet" }
          \trumpet
          \new Staff = "altosax" \with { instrumentName = "Alto Sax" }
          \altoSax
          \new ChordNames = "barichords" \with { instrumentName = "Trumpet" }
          \bariHarmony
          \new Staff = "barisax" \with { instrumentName = "Bari Sax" }
          \bariSax
          \new Staff = "trombone" \with { instrumentName = "Trombone" }
          \trombone
        >>

        \new StaffGroup = "rhythm" <<
          \new ChordNames = "chords" \gtrHarmony
          \new Staff = "guitar" \with { instrumentName = "Guitar" }
          \guitar
          \new PianoStaff = "piano" \with {
            instrumentName = "Piano"
            midiInstrument = "acoustic grand"
          }
          \piano
          \new Staff = "bass" \with { instrumentName = "Bass" }
          \bass
          \new DrumStaff \with { instrumentName = "Drums" }
          \drumContents
        >>
      >>
      \layout {
        \context { \Staff \RemoveEmptyStaves }
        \context {
          \Score
          \override BarNumber.padding = #3
          \override RehearsalMark.padding = #2
          skipBars = ##t
        }
      }
      \midi { }
    }

## Orchester, Chor und Klavier

Diese Vorlage zeigt die Benutzung von geschachtelten `StaffGroup`- und `GrandStaff`-Kontexte, um Instrumente in Untergruppen zu unterteilen, und die Benutzung von `\transpose` für transponierende Instrumente. Alle Noten werden in C geschrieben. Noten können in C eingegeben werden, oder auch in der Tonart des Instrumentes: dann müssen sie zuerst nach C transponiert werden, bevor sie einer Variable zugewiesen werden.

    #(set-global-staff-size 17)
    \paper {
      indent = 3.0\cm  % add space for instrumentName
      short-indent = 1.5\cm  % add less space for shortInstrumentName
    }

    fluteMusic = \relative c' { \key g \major g'1 b }

    % Pitches as written on a manuscript for Clarinet in A
    % are transposed to concert pitch.

    clarinetMusic = \transpose c' a
      \relative c'' { \key bes \major bes1 d }

    trumpetMusic = \relative c { \key g \major g''1 b }

    % Key signature is often omitted for horns

    hornMusic = \transpose c' f
      \relative c { d'1 fis }

    percussionMusic = \relative c { \key g \major g1 b }

    sopranoMusic = \relative c'' { \key g \major g'1 b }

    sopranoLyrics = \lyricmode { Lyr -- ics }

    altoIMusic = \relative c' { \key g \major g'1 b }

    altoIIMusic = \relative c' { \key g \major g'1 b }

    altoILyrics =  \sopranoLyrics

    altoIILyrics = \lyricmode { Ah -- ah }

    tenorMusic = \relative c' { \clef "treble_8" \key g \major g1 b }

    tenorLyrics = \sopranoLyrics

    pianoRHMusic = \relative c { \key g \major g''1 b }

    pianoLHMusic = \relative c { \clef bass \key g \major g1 b }

    violinIMusic = \relative c' { \key g \major g'1 b }

    violinIIMusic = \relative c' { \key g \major g'1 b }

    violaMusic = \relative c { \clef alto \key g \major g'1 b }

    celloMusic = \relative c { \clef bass \key g \major g1 b }

    bassMusic = \relative c { \clef "bass_8" \key g \major g,1 b }

    \score {
      <<
        \new StaffGroup = "StaffGroup_woodwinds" <<
          \new Staff = "Staff_flute" \with { instrumentName = "Flute" }
          \fluteMusic

          \new Staff = "Staff_clarinet" \with {
            instrumentName = \markup { \concat { "Clarinet in B" \flat } }
          }

          % Declare that written Middle C in the music
          % to follow sounds a concert B flat, for
          % output using sounded pitches such as MIDI.
          %\transposition bes

          % Print music for a B-flat clarinet
          \transpose bes c' \clarinetMusic
        >>

        \new StaffGroup = "StaffGroup_brass" <<
          \new Staff = "Staff_hornI" \with { instrumentName = "Horn in F" }
           % \transposition f
            \transpose f c' \hornMusic

          \new Staff = "Staff_trumpet" \with { instrumentName = "Trumpet in  C" }
          \trumpetMusic

        >>
        \new RhythmicStaff = "RhythmicStaff_percussion"
        \with { instrumentName = "Percussion" }
        <<
          \percussionMusic
        >>
        \new PianoStaff \with { instrumentName = "Piano" }
        <<
          \new Staff { \pianoRHMusic }
          \new Staff { \pianoLHMusic }
        >>
        \new ChoirStaff = "ChoirStaff_choir" <<
          \new Staff = "Staff_soprano" \with { instrumentName = "Soprano" }
          \new Voice = "soprano"
          \sopranoMusic

          \new Lyrics \lyricsto "soprano" { \sopranoLyrics }
          \new GrandStaff = "GrandStaff_altos"
          \with { \accepts Lyrics } <<
            \new Staff = "Staff_altoI"  \with { instrumentName = "Alto I" }
            \new Voice = "altoI"
            \altoIMusic

            \new Lyrics \lyricsto "altoI" { \altoILyrics }
            \new Staff = "Staff_altoII" \with { instrumentName = "Alto II" }
            \new Voice = "altoII"
            \altoIIMusic

            \new Lyrics \lyricsto "altoII" { \altoIILyrics }
          >>

          \new Staff = "Staff_tenor" \with { instrumentName = "Tenor" }
            \new Voice = "tenor"
            \tenorMusic

          \new Lyrics \lyricsto "tenor" { \tenorLyrics }
        >>
        \new StaffGroup = "StaffGroup_strings" <<
          \new GrandStaff = "GrandStaff_violins" <<
            \new Staff = "Staff_violinI" \with { instrumentName = "Violin I" }
            \violinIMusic

            \new Staff = "Staff_violinII" \with { instrumentName = "Violin II" }
            \violinIIMusic
          >>

          \new Staff = "Staff_viola" \with { instrumentName = "Viola" }
          \violaMusic

          \new Staff = "Staff_cello" \with { instrumentName = "Cello" }
          \celloMusic

          \new Staff = "Staff_bass" \with { instrumentName = "Double Bass" }
          \bassMusic
        >>
      >>
      \layout { }
    }

## Vorlage für einfache Klaviernotation

Hier ein einfaches Klaviersystem.

    upper = \relative c'' {
      \clef treble
      \key c \major
      \time 4/4

      a4 b c d
    }

    lower = \relative c {
      \clef bass
      \key c \major
      \time 4/4

      a2 c
    }

    \score {
      \new PianoStaff \with { instrumentName = "Piano" }
      <<
        \new Staff = "upper" \upper
        \new Staff = "lower" \lower
      >>
      \layout { }
      \midi { }
    }

## Piano template with centered lyrics

Anstatt ein eigenes System für Melodie und Text zu schreiben, können Sie den Text auch zwischen die beiden Klaviersysteme schreiben (und damit das zusätzliche System für die Gesangstimme auslassen).

    upper = \relative c'' {
      \clef treble
      \key c \major
      \time 4/4

      a4 b c d
    }

    lower = \relative c {
      \clef bass
      \key c \major
      \time 4/4

      a2 c
    }

    text = \lyricmode {
      Aaa Bee Cee Dee
    }

    \score {
      \new PianoStaff <<
        \new Staff = upper { \new Voice = "singer" \upper }
        \new Lyrics \lyricsto "singer" \text
        \new Staff = lower { \lower }
      >>
      \layout { }
      \midi { }
    }

## Vorlage für Klavier und Gesangsstimme

Das nächste Beispiel ist typisch für ein Lied: Im oberen System die Melodie mit Text, darunter Klavierbegleitung.

    melody = \relative c'' {
      \clef treble
      \key c \major
      \time 4/4

      a b c d
    }

    text = \lyricmode {
      Aaa Bee Cee Dee
    }

    upper = \relative c'' {
      \clef treble
      \key c \major
      \time 4/4

      a4 b c d
    }

    lower = \relative c {
      \clef bass
      \key c \major
      \time 4/4

      a2 c
    }

    \score {
      <<
        \new Voice = "mel" { \autoBeamOff \melody }
        \new Lyrics \lyricsto mel \text
        \new PianoStaff <<
          \new Staff = "upper" \upper
          \new Staff = "lower" \lower
        >>
      >>
      \layout {
        \context { \Staff \RemoveEmptyStaves }
      }
      \midi { }
    }

## SATB-Chorvorlage auf vier Systemen

SATB-Chorvorlage auf vier Systemen

    global = {
      \key c \major
      \time 4/4
      \dynamicUp
    }
    sopranonotes = \relative c'' {
      c2 \p \< d c d \f
    }
    sopranowords = \lyricmode { do do do do }
    altonotes = \relative c'' {
      c2\p d c d
    }
    altowords = \lyricmode { re re re re }
    tenornotes = {
      \clef "G_8"
      c2\mp d c d
    }
    tenorwords = \lyricmode { mi mi mi mi }
    bassnotes = {
      \clef bass
      c2\mf d c d
    }
    basswords = \lyricmode { mi mi mi mi }

    \score {
      \new ChoirStaff <<
        \new Staff <<
          \new Voice = "soprano" <<
            \global
            \sopranonotes
          >>
          \new Lyrics \lyricsto "soprano" \sopranowords
        >>
        \new Staff <<
          \new Voice = "alto" <<
            \global
            \altonotes
          >>
          \new Lyrics \lyricsto "alto" \altowords
        >>
        \new Staff <<
          \new Voice = "tenor" <<
            \global
            \tenornotes
          >>
          \new Lyrics \lyricsto "tenor" \tenorwords
        >>
        \new Staff <<
          \new Voice = "bass" <<
            \global
            \bassnotes
          >>
          \new Lyrics \lyricsto "bass" \basswords
        >>
      >>
    }

## Score for diatonic accordion

A template to write a score for a diatonic accordion.

- There is a horizontal staff indicating if the accordion must be pushed (thick line) or pulled (thin line)

- There is a small rhythmic staff with lyrics that describes the bass buttons to press. The bar lines are made from gridlines

- The tabulator staff for diatonic accordions shows the geographic position of the buttons and not (as for every other instrument) the pitch of the notes; the keys on the melody-side of the accordion are placed in three columns and about 12 rows

In the tabulator staff notation the outermost column is described with notes between lines, the innermost column is described with notes between lines and a cross as accidental, and the middle column is described with notes on a line, whereby the row in the middle is represented on the middle line in the staff.

Some words to transpose piano notes to the diatonic accordion:

1. Every diatonic accordion is built for some keys only (for example, for the keys of C major and F major), so it is important to transpose a piano melody to match one of these keys. Transpose the source code, not only the output because this code is required later on to translate it once more to the tabulator staff. This can be done with the command `displayLilyMusic`.

2. You have to alternate the push- and pull-direction of the accordion regularly. If the player has a too long part to pull the accordion gets broken. On the other hand, some harmonies are only available in one direction. Considering this, decide which parts of the melody are the push-parts and which the pull-parts.

3. For each pull- or push-part translate the piano notes to the according tabulature representation.

    verse = \lyricmode { Wie gross bist du! Wie gross bist du! }

    harmonies = \new ChordNames \chordmode {
      \germanChords
      \set chordChanges = ##t
      bes8 bes8 bes8
      es2 f
      bes1
    }

    NoStem = { \hide Stem }
    NoNoteHead = \hide NoteHead
    ZeroBeam = \override Beam.positions = #'(0 . 0)

    staffTabLine = \new Staff \with {
      \remove "Time_signature_engraver"
      \remove "Clef_engraver"
    } {
      \override Staff.StaffSymbol.line-positions = #'(0)
      % Shows one horizontal line. The vertical line
      %  (simulating a bar-line) is simulated with a gridline
      \set Staff.midiInstrument = #"choir aahs"
      \key c \major
      \relative c''
      {
        % disable the following line to see the noteheads while writing the song
        \NoNoteHead
        \override NoteHead.no-ledgers = ##t

        % The beam between 8th-notes is used to draw the push-line
        %How to fast write the push-lines:
        %  1. write repeatedly 'c c c c c c c c |' for the whole length of the song
        %  2. uncomment the line \NoNoteHead
        %  3. compile
        %  4. Mark the positions on which push/pull changes.
        %     In the score-picture click on the position
        %        the push- or pull-part starts
        %           (on the noteHead, the cursor will change to a hand-icon).
        %     The cursor in the source code will jump just at this position.
        %   a) If a push-part starts there, replace the 'c' by an 'e['
        %   b) If a pull-part starts there, replace the 'c' by an 's'
        %  5. Switch into 'overwrite-mode' by pressing the 'ins' key.
        %  6. For the pull-parts overwrite the 'c' with 's'
        %  7. For every push-part replace the last 'c' with 'e]'
        %        8. Switch into 'insert-mode' again
        %  9. At last it should look like e.g.
        %        (s s e[ c | c c c c c c c c | c c c c c c e] s s)
        % 10. re-enable the line \NoNoteHead
        \autoBeamOff
        \ZeroBeam
        s8 s s e[ c c c c c c e] | s s s s s
      }
    }

    % Accordion melody in tabulator score
    % 1. Place a copy of the piano melody below
    % 2. Separate piano melody into pull- and push-parts
    %      according to the staffTabLine you've already made
    % 3. For each line: Double the line. Remark the 1st one
    %      (Keeps unchanged as reference) and then change the second
    %      line using the transformation paper
    %    or the macros 'conv2diaton push.bsh' and 'conv2diaton pull.bsh'
    % Tips:
    % - In jEdit Search & Replace mark the Option 'Keep Dialog'

    AccordionTabTwoCBesDur = {
      % pull 1
      %<f' bes'>8 <f' a'>8 <d' bes'>8 |
      <g'' a''>8 <g'' b''>8 <e'' a''>8 |
      % push 2
      %<g' c''>4 <f' d''> <g' ees''> <f' a'> |
      <g'' a''>4 <d'' eisis''> <g'' bisis''> <d'' f''> |
      % pull 3
      % <f' bes'>2 r8 }
      <g'' a''>2 r8 }

    AccordionTab= { \dynamicUp
      % 1. Place a copy of the piano melody above
      % 2. Separate piano melody into pull- and push-parts
      %      according to the staffTabLine you've already made
      % 3. For each line: Double the line. Remark the 1st one
      %      (Keeps unchanged as reference) and then
      %      change the second line using the transformation paper
      % Tips:
      % - In jEdit Search & Replace mark the Option 'Keep Dialog'
      % -
      \AccordionTabTwoCBesDur
    }

    \layout {
      \context {
        \Score
        % The vertical line (simulating a bar-line) in
        % the staffBassRhytm is a gridline
        \consists "Grid_line_span_engraver"
      }
      \context {
        \Staff
        \consists "Grid_point_engraver"
        gridInterval = #(ly:make-moment 4/4) % 4/4 - tact. How many beats per bar
        % The following line has to be adjusted O-F-T-E-N.
        \override GridPoint.Y-extent = #'(-2 . -21)
      }
      \context {
        \ChoirStaff
        \remove "System_start_delimiter_engraver"
      }
    }

    staffVoice = \new Staff = astaffvoice  {
      \time 4/4
      \set Staff.instrumentName = "Voice"
      \set Staff.midiInstrument = "voice oohs"
      \key bes \major
      \partial 8*3
      \clef treble
      {
        \context Voice = "melodyVoi"
        {
          <f' bes'>8 <f' a'>8 <d' bes'>8 |
          <g' c''>4 <f' d''> <g' es''> <f' a'> |
          <f' bes'>2 r8
        }
        \bar "|."
      }
    }

    staffAccordionMel =
    \new Staff  \with { \remove "Clef_engraver" } {
      \accidentalStyle forget %Set the accidentals (Vorzeichen) for each note,
      %do not remember them for the rest of the measure.
      \time 4/4
      \set Staff.instrumentName="Accordion"
      \set Staff.midiInstrument="voice oohs"
      \key c \major
      \clef treble
      { \AccordionTab \bar "|." }
    }

    AltOn =
    #(define-music-function (mag) (number?)
      #{ \override Stem.length = #(* 7.0 mag)
          \override NoteHead.font-size =
    #(inexact->exact (* (/ 6.0 (log 2.0)) (log mag))) #})

    AltOff = {
      \revert Stem.length
      \revert NoteHead.font-size
    }

    BassRhytm = {s4 s8 | c2 c2 | c2 s8 }
    LyricBassRhythmI=  \lyricmode { c b | c }

    staffBassRhytm =
    \new Staff = staffbass \with { \remove "Clef_engraver" } {
      % This is not a RhythmicStaff  because it must be possible to append lyrics.

      \override Score.GridLine.extra-offset = #'( 13.0 . 0.0 ) % x.y
      \override Staff.StaffSymbol.line-positions = #'( 0 )
      % Shows one horizontal line. The vertical line
      %  (simulating a bar-line) is simulated by a grid
      % Search for 'grid' in this page to find all related functions
      \time 4/4
      {
        \context Voice = "VoiceBassRhytm"
        \stemDown \AltOn #0.6
        \relative c''
        {
          \BassRhytm
        }
        \AltOff
        \bar "|."
      }
    }

    \score {
      \new ChoirStaff <<
        \harmonies
        \staffVoice
        \context Lyrics = "lmelodyVoi"
          \with { alignBelowContext = astaffvoice }
          \lyricsto melodyVoi \verse
        \staffAccordionMel
        \staffTabLine
        \staffBassRhytm
        \context Lyrics = "lBassRhytmAboveI"
          \with { alignAboveContext = staffbass }
          \lyricsto VoiceBassRhytm \LyricBassRhythmI
      >>
    }

## Vorlage für eine Notenzeile mit Noten, Text und Akkorden

Mit diesem Beispiel können Sie einen Song mit Melodie, Text und Akkorden schreiben.

    melody = \relative c' {
      \clef treble
      \key c \major
      \time 4/4

      a4 b c d
    }

    text = \lyricmode {
      Aaa Bee Cee Dee
    }

    harmonies = \chordmode {
      a2 c
    }

    \score {
      <<
        \new ChordNames {
          \set chordChanges = ##t
          \harmonies
        }
        \new Voice = "one" { \autoBeamOff \melody }
        \new Lyrics \lyricsto "one" \text
      >>
      \layout { }
      \midi { }
    }

## Single staff template with notes, lyrics, chords and frets

Here is a simple lead sheet template with melody, lyrics, chords and fret diagrams.

    verseI = \lyricmode {
      \set stanza = #"1."
      This is the first verse
    }

    verseII = \lyricmode {
      \set stanza = #"2."
      This is the second verse.
    }

    theChords = \chordmode {
      % insert chords for chordnames and fretboards here
      c2 g4 c
    }

    staffMelody = \relative c' {
       \key c \major
       \clef treble
       % Type notes for melody here
       c4 d8 e f4 g
       \bar "|."
    }

    \score {
      <<
        \context ChordNames { \theChords }
        \context FretBoards { \theChords }
        \new Staff {
          \context Voice = "voiceMelody" { \staffMelody }
        }
        \new Lyrics = "lyricsI" {
          \lyricsto "voiceMelody" \verseI
        }
        \new Lyrics = "lyricsII" {
          \lyricsto "voiceMelody" \verseII
        }
      >>
      \layout { }
      \midi { }
    }

## Vorlage für eine Notenzeile mit Akkorden

Wollen Sie ein Liedblatt mit Melodie und Akkorden schreiben? Hier ist das richtige Beispiel für Sie!

    melody = \relative c' {
      \clef treble
      \key c \major
      \time 4/4

      f4 e8[ c] d4 g
      a2 ~ a
    }

    harmonies = \chordmode {
      c4:m f:min7 g:maj c:aug
      d2:dim b4:5 e:sus
    }

    \score {
      <<
        \new ChordNames {
          \set chordChanges = ##t
          \harmonies
        }
        \new Staff \melody
      >>
      \layout{ }
      \midi { }
    }

## Vorlage für ein Notensystem mit Noten und Gesangstext

Das nächste Beispiel zeigt eine einfache Melodie mit Text. Kopieren Sie es in Ihre Datei, fügen Sie Noten und Text hinzu und übersetzen Sie es mit LilyPond. In dem Beispiel wird die automatische Balkenverbindung ausgeschaltet (mit dem Befehl `\autoBeamOff`), wie es für Vokalmusik üblich ist. Wenn Sie die Balken wieder einschalten wollen, müssen Sie die entsprechende Zeile entweder ändern oder auskommentieren.

    melody = \relative c' {
      \clef treble
      \key c \major
      \time 4/4

      a4 b c d
    }

    text = \lyricmode {
      Aaa Bee Cee Dee
    }

    \score{
      <<
        \new Voice = "one" {
          \autoBeamOff
          \melody
        }
        \new Lyrics \lyricsto "one" \text
      >>
      \layout { }
      \midi { }
    }

## Vorlage für ein Notensystem

Das erste Beispiel zeigt ein Notensystem mit Noten, passend für ein Soloinstrument oder ein Melodiefragment. Kopieren Sie es und fügen Sie es in Ihre Datei ein, schreiben Sie die Noten hinzu, und Sie haben eine vollständige Notationsdatei.

    melody = \relative c' {
      \clef treble
      \key c \major
      \time 4/4

      a4 b c d
    }

    \score {
      \new Staff \melody
      \layout { }
      \midi { }
    }

## Vorlage für Streichquartett (einfach)

Dieses Beispiel demonstriert die Partitur für ein Streichquartett. Hier wird auch eine „`global`“-Variable für Taktart und Vorzeichen benutzt.

    global= {
      \time 4/4
      \key c \major
    }

    violinOne = \new Voice \relative c'' {
      c2 d
      e1
      \bar "|."
    }

    violinTwo = \new Voice \relative c'' {
      g2 f
      e1
      \bar "|."
    }

    viola = \new Voice \relative c' {
      \clef alto
      e2 d
      c1
      \bar "|."
    }

    cello = \new Voice \relative c' {
      \clef bass
      c2 b
      a1
      \bar "|."
    }

    \score {
      \new StaffGroup <<
        \new Staff \with { instrumentName = "Violin 1" }
        << \global \violinOne >>
        \new Staff \with { instrumentName = "Violin 2" }
        << \global \violinTwo >>
        \new Staff \with { instrumentName = "Viola" }
        << \global \viola >>
        \new Staff \with { instrumentName = "Cello" }
        << \global \cello >>
      >>
      \layout { }
      \midi { }
    }

## Vorlage für Streichquartett mit einzelnen Stimmen

Mit diesem Beispiel können Sie ein schönes Streichquartett notieren, aber wie gehen Sie vor, wenn Sie Stimmen brauchen? Das Beispiel oben hat gezeigt, wie Sie mit Variablen einzelne Abschnitte getrennt voneinander notieren können. Im nächsten Beispiel wird nun gezeigt, wie Sie mit diesen Variablen einzelne Stimmen erstellen.

Sie müssen das Beispiel in einzelne Dateien aufteilen; die Dateinamen sind in den Kommentaren am Anfang jeder Datei enthalten. ‘`piece.ly`’ enthält die Noten. Die anderen Dateien – ‘`score.ly`’, ‘`vn1.ly`’, ‘`vn2.ly`’, ‘`vla.ly`’ und ‘`vlc.ly`’ – erstellen daraus die entsprechenden Stimmen bzw. die Partitur (‘`score.ly`’). Mit `ag` wird den Stimmen ein Name zugewiesen, auf den zurückgegriffen werden kann.

    %%%%% piece.ly
    %%%%% (This is the global definitions file)

    global= {
      \time 4/4
      \key c \major
    }

    Violinone = \new Voice {
      \relative c'' {
        c2 d e1
        \bar "|."
      }
    }

    Violintwo = \new Voice {
      \relative c'' {
        g2 f e1
        \bar "|."
      }
    }

    Viola = \new Voice {
      \relative c' {
        \clef alto
        e2 d c1
        \bar "|."
      }
    }

    Cello = \new Voice {
      \relative c' {
        \clef bass
        c2 b a1
        \bar "|."
      }
    }

    music = {
      <<
        \tag #'score \tag #'vn1
        \new Staff \with { instrumentName = "Violin 1" }
        << \global \Violinone >>

        \tag #'score \tag #'vn2
        \new Staff \with { instrumentName = "Violin 2" }
        << \global \Violintwo>>

        \tag #'score \tag #'vla
        \new Staff \with { instrumentName = "Viola" }
        << \global \Viola>>

        \tag #'score \tag #'vlc
        \new Staff \with { instrumentName = "Cello" }
        << \global \Cello >>
      >>
    }

    % These are the other files you need to save on your computer

    % score.ly
    % (This is the main file)

    % uncomment the line below when using a separate file
    %\include "piece.ly"

    #(set-global-staff-size 14)

    \score {
      \new StaffGroup \keepWithTag #'score \music
      \layout { }
      \midi { }
    }

    %{ Uncomment this block when using separate files

    % vn1.ly
    % (This is the Violin 1 part file)

    \include "piece.ly"
    \score {
      \keepWithTag #'vn1 \music
      \layout { }
    }

    % vn2.ly
    % (This is the Violin 2 part file)

    \include "piece.ly"
    \score {
      \keepWithTag #'vn2 \music
      \layout { }
    }

    % vla.ly
    % (This is the Viola part file)

    \include "piece.ly"
    \score {
      \keepWithTag #'vla \music
      \layout { }
    }

    % vlc.ly
    % (This is the Cello part file)

    \include "piece.ly"
    \score {
      \keepWithTag #'vlc \music
      \layout { }
    }

    %}

## Vocal ensemble template with automatic piano reduction

In diesem Beispiel wird ein automatischer Klavierauszug zu der Chorpartitur hinzugefügt. Das zeigt eine der Stärken von LilyPond – man kann eine Variable mehr als einmal benutzen. Wenn Sie irgendeine Änderung an einer Chorstimme vornehmen, (etwa tenorMusic), verändert sich auch der Klavierauszug entsprechend.

    \paper {
      top-system-spacing.basic-distance = #10
      score-system-spacing.basic-distance = #20
      system-system-spacing.basic-distance = #20
      last-bottom-spacing.basic-distance = #10
    }

    global = {
      \key c \major
      \time 4/4
    }

    sopMusic = \relative {
      c''4 c c8[( b)] c4
    }
    sopWords = \lyricmode {
      hi hi hi hi
    }

    altoMusic = \relative {
      e'4 f d e
    }
    altoWords =\lyricmode {
      ha ha ha ha
    }

    tenorMusic = \relative {
      g4 a f g
    }
    tenorWords = \lyricmode {
      hu hu hu hu
    }

    bassMusic = \relative {
      c4 c g c
    }
    bassWords = \lyricmode {
      ho ho ho ho
    }

    \score {
      <<
        \new ChoirStaff <<
          \new Lyrics = "sopranos" \with {
            % This is needed for lyrics above a staff
            \override VerticalAxisGroup.staff-affinity = #DOWN
          }
          \new Staff = "women" <<
            \new Voice = "sopranos" { \voiceOne << \global \sopMusic >> }
            \new Voice = "altos" { \voiceTwo << \global \altoMusic >> }
          >>
          \new Lyrics = "altos"
          \new Lyrics = "tenors" \with {
            % This is needed for lyrics above a staff
            \override VerticalAxisGroup.staff-affinity = #DOWN
          }

          \new Staff = "men" <<
            \clef bass
            \new Voice = "tenors" { \voiceOne << \global \tenorMusic >> }
            \new Voice = "basses" { \voiceTwo << \global \bassMusic >> }
          >>
          \new Lyrics = "basses"
          \context Lyrics = "sopranos" \lyricsto "sopranos" \sopWords
          \context Lyrics = "altos" \lyricsto "altos" \altoWords
          \context Lyrics = "tenors" \lyricsto "tenors" \tenorWords
          \context Lyrics = "basses" \lyricsto "basses" \bassWords
        >>
        \new PianoStaff <<
          \new Staff <<
            \set Staff.printPartCombineTexts = ##f
            \partCombine
            << \global \sopMusic >>
            << \global \altoMusic >>
          >>
          \new Staff <<
            \clef bass
            \set Staff.printPartCombineTexts = ##f
            \partCombine
            << \global \tenorMusic >>
            << \global \bassMusic >>
          >>
        >>
      >>
    }

## Vorlage für Vokalensemble mit dem Gesangstext über und unter dem System

In diesem Beispiel werden die Texte mit den Befehlen `alignAboveContext` und `alignBelowContext` über und unter dem System angeordnet.

    global = {
      \key c \major
      \time 4/4
    }

    sopMusic = \relative c'' {
      c4 c c8[( b)] c4
    }
    sopWords = \lyricmode {
      hi hi hi hi
    }

    altoMusic = \relative c' {
      e4 f d e
    }
    altoWords = \lyricmode {
      ha ha ha ha
    }

    tenorMusic = \relative c' {
      g4 a f g
    }
    tenorWords = \lyricmode {
      hu hu hu hu
    }

    bassMusic = \relative c {
      c4 c g c
    }
    bassWords = \lyricmode {
      ho ho ho ho
    }

    \score {
      \new ChoirStaff <<
        \new Staff = "women" <<
          \new Voice = "sopranos" { \voiceOne << \global \sopMusic >> }
          \new Voice = "altos" { \voiceTwo << \global \altoMusic >> }
        >>
        \new Lyrics \with { alignAboveContext = #"women" }
          \lyricsto "sopranos" \sopWords
        \new Lyrics \with { alignBelowContext = #"women" }
          \lyricsto "altos" \altoWords
        % we could remove the line about this with the line below, since
        % we want the alto lyrics to be below the alto Voice anyway.
        % \new Lyrics \lyricsto "altos" \altoWords

        \new Staff = "men" <<
          \clef bass
          \new Voice = "tenors" { \voiceOne << \global \tenorMusic >> }
          \new Voice = "basses" { \voiceTwo << \global \bassMusic >> }
        >>
        \new Lyrics \with { alignAboveContext = #"men" }
          \lyricsto "tenors" \tenorWords
        \new Lyrics \with { alignBelowContext = #"men" }
          \lyricsto "basses" \bassWords
        % again, we could replace the line above this with the line below.
        % \new Lyrics \lyricsto "basses" \bassWords
      >>
    }

## Sologesang und zweistimmiger Refrain

Diese Vorlage erstellt eine Partitur, die mit Sologesang beginnt und einen Refrain für zwei Stimmen enthält. Sie zeigt auch die Benutzung von Platzhalter-Pausen innerhalb der `\global`-Variable, um Taktwechsel (und andere Elemente, die für alle Stimmen gleich sind) für das gesamte Stück zu definieren.

    global = {
      \key g \major

      % verse
      \time 3/4
      s2.*2
      \break

      % refrain
      \time 2/4
      s2*2
      \bar "|."
    }

    SoloNotes = \relative g' {
      \clef "treble"

      % verse
      g4 g g |
      b4 b b |

      % refrain
      R2*2 |
    }

    SoloLyrics = \lyricmode {
      One two three |
      four five six |
    }

    SopranoNotes = \relative c'' {
      \clef "treble"

      % verse
      R2.*2 |

      % refrain
      c4 c |
      g4 g |
    }

    SopranoLyrics = \lyricmode {
      la la |
      la la |
    }

    BassNotes = \relative c {
      \clef "bass"

      % verse
      R2.*2 |

      % refrain
      c4 e |
      d4 d |
    }

    BassLyrics = \lyricmode {
      dum dum |
      dum dum |
    }

    \score {
      <<
        \new Voice = "SoloVoice" << \global \SoloNotes >>
        \new Lyrics \lyricsto "SoloVoice" \SoloLyrics

        \new ChoirStaff <<
          \new Voice = "SopranoVoice" << \global \SopranoNotes >>
          \new Lyrics \lyricsto "SopranoVoice" \SopranoLyrics

          \new Voice = "BassVoice" << \global \BassNotes >>
          \new Lyrics \lyricsto "BassVoice" \BassLyrics
        >>
      >>
      \layout {
        ragged-right = ##t
        \context { \Staff
          % these lines prevent empty staves from being printed
          \RemoveEmptyStaves
          \override VerticalAxisGroup.remove-first = ##t
        }
      }
    }

## Vorlage für Vokalensemble

Dieses Beispiel ist für vierstimmigen Gesang (SATB). Bei größeren Stücken ist es oft sinnvoll, eine allgemeine Variable zu bestimmen, die in allen Stimmen eingefügt wird. Taktart und Vorzeichen etwa sind fast immer gleich in allen Stimmen.

    \paper {
      top-system-spacing.basic-distance = #10
      score-system-spacing.basic-distance = #20
      system-system-spacing.basic-distance = #20
      last-bottom-spacing.basic-distance = #10
    }

    global = {
      \key c \major
      \time 4/4
    }

    sopMusic = \relative {
      c''4 c c8[( b)] c4
    }
    sopWords = \lyricmode {
      hi hi hi hi
    }

    altoMusic = \relative {
      e'4 f d e
    }
    altoWords = \lyricmode {
      ha ha ha ha
    }

    tenorMusic = \relative {
      g4 a f g
    }
    tenorWords = \lyricmode {
      hu hu hu hu
    }

    bassMusic = \relative {
      c4 c g c
    }
    bassWords = \lyricmode {
      ho ho ho ho
    }

    \score {
      \new ChoirStaff <<
        \new Lyrics = "sopranos" \with {
          % this is needed for lyrics above a staff
          \override VerticalAxisGroup.staff-affinity = #DOWN
        }
        \new Staff = "women" <<
          \new Voice = "sopranos" {
            \voiceOne
            << \global \sopMusic >>
          }
          \new Voice = "altos" {
            \voiceTwo
            << \global \altoMusic >>
          }
        >>
        \new Lyrics = "altos"
        \new Lyrics = "tenors" \with {
          % this is needed for lyrics above a staff
          \override VerticalAxisGroup.staff-affinity = #DOWN
        }
        \new Staff = "men" <<
          \clef bass
          \new Voice = "tenors" {
            \voiceOne
            << \global \tenorMusic >>
          }
          \new Voice = "basses" {
            \voiceTwo << \global \bassMusic >>
          }
        >>
        \new Lyrics = "basses"
        \context Lyrics = "sopranos" \lyricsto "sopranos" \sopWords
        \context Lyrics = "altos" \lyricsto "altos" \altoWords
        \context Lyrics = "tenors" \lyricsto "tenors" \tenorWords
        \context Lyrics = "basses" \lyricsto "basses" \bassWords
      >>
    }

#### LilyPond – Snippets v2.22.2 (stabiler Zweig).