LilyPond snippets: Templates

# Templates

## Exemples de notation ancienne – transcription moderne de musique grégorienne

Voici comment vous pourriez transcrire du grégorien. Pour mémoire, il n’y a en grégorien ni découpage en mesure, ni hampe ; seules sont utilisées des têtes de note blanches ou noires, ainsi que des signes spécifiques permettant d’indiquer des silences de différentes durées.

    \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
        }
      }
    }

## Psalmodie anglicane

Cet exemple illustre la manière de présenter un cantique tel qu’on le trouve dans l’église anglicane. Vous noterez comment sont ajoutés les couplets indépendamment de la musique. Dans le but de vous montrer plusieurs styles, comparez le code des deux couplets.

    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.
            }
          }
        }
      }
    }

## Modèle pour cantique

Le code ci-dessous illustre la manière d’agencer un cantique liturgique dans lequel chaque ligne débute et se termine par une mesure incomplète. Vous noterez par ailleurs l’affichage des paroles indépendamment de la musique.

    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

## Symboles de jazz

Bien que compliqué de prime abord, voici un canevas tout à fait indiqué pour les ensembles de jazz. Vous noterez que tous les instruments sont notés en ut (`\key c \major`), la tonalité de concert. Les notes seront automatiquement transposées dès lors qu’elles seront inscrites dans une section `\transpose`.

    \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 { }
    }

## Orchestre, chœur et piano

Ce canevas illustre l’utilisation de contextes `StaffGroup` pour regrouper les instruments selon leur famille, imbriqués dans un `GrandStaff`, ainsi que le recours à la fonction `\transpose` pour les instruments transpositeurs. Dans tous les identificateurs, la musique est stockée en ut. Les notes peuvent tout aussi bien être saisies en ut ou dans la tonalité particulière de l’instrument avant d’être transposées puis affectées à une variable.

    #(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 { }
    }

## Piano – cannevas simple

Voici une simple partition pour piano avec quelques notes.

    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 et paroles entre les portées

Lorsque la mélodie est doublée au piano, cela ne nécessite pas forcément une portée spécifique. Les paroles peuvent s’insérer entre les deux portées de la partition pour piano.

    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 { }
    }

## Piano, mélodie et paroles

Il s’agit du format classique pour le chant : une portée pour la mélodie et les paroles au-dessus de l’accompagnement au piano.

    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 { }
    }

## Modèle pour chœur SATB, sur quatre portées

Modèle pour chœur à quatre voix mixtes, chaque pupitre ayant sa propre portée.

    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
      >>
    }

## Paroles, musique et accords

Ce canevas comporte tous les éléments d’une chanson : la mélodie, les paroles, les accords.

    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 { }
    }

## Paroles, musique, accords et diagrammes de fret

Ce canevas comporte, en plus de la mélodie, des paroles et des accords, les diagrammes de fret.

    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 { }
    }

## Mélodie simple et accords

Vous avez besoin de la partition d’une mélodie avec les accords ? N’allez pas plus loin !

    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 { }
    }

## Portée unique et paroles

Ce canevas comporte une simple ligne mélodique agrémentée de paroles. Recopiez-le, ajoutez-y d’autres notes et paroles. Les ligatures automatiques sont ici désactivées comme il est d’usage en matière de musique vocale. Pour activer la fonction de ligature automatique, modifiez ou commentez la ligne en question.

    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 { }
    }

## Portée unique avec quelques notes

Cet exemple simpliste se compose d’une portée agrémentée de quelques notes. Il convient tout à fait pour un instrument seul ou un fragment mélodique. Recopiez-le dans un nouveau fichier, ajoutez-y d’autres notes et c’est prêt !

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

      a4 b c d
    }

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

## Quatuor à cordes (conducteur)

Voici un canevas pour quatuor à cordes. Notez l’utilisation de la variable `\global` pour traiter la métrique et la tonalité.

    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 { }
    }

## Quatuor à cordes, avec parties séparées

Grâce à ce canevas, vous pouvez obtenir une partition d’excellente facture pour quatuor à cordes mais aussi, si le besoin s’en faisait sentir, une partie séparée par instrument. Par ailleurs, cet exemple illustre l’utilisation de la fonction `\tag` dans le but d’extraire des parties séparées.

Il vous faudra découper ce canevas en plusieurs fichiers séparés ; leur nom respectif est indiqué en commentaire : ‘`piece.ly`’ comporte tout ce qui a trait à la musique, les autres fichiers – ‘`score.ly`’, ‘`vn1.ly`’, ‘`vn2.ly`’, ‘`vla.ly`’ et ‘`vlc.ly`’ – vous permettront d’obtenir les parties selon le pupitre.

N’oubliez pas de supprimer les commentaires superflus des fichiers individualisés !

    %%%%% 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 { }
    }

    %}

## Ensemble vocal avec réduction pour piano

Ce canevas ajoute une réduction pour piano à une partition standard pour chœur à quatre voix mixtes. Ceci illustre l’un des avantages de LilyPond : une expression musicale peut être réutilisée sans effort. Toute modification apportée à l’une des voix, mettons `tenorMusique`, sera automatiquement reportée dans la réduction pour piano.

    \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 >>
          >>
        >>
      >>
    }

## Ensemble vocal avec alignement des paroles selon le contexte

Ce canevas ressemble beaucoup à celui pour chœur à quatre voix mixtes. La différence réside dans le fait que les paroles sont positionnées en ayant recours à `alignAboveContext` et `alignBelowContext`.

    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
      >>
    }

## Ensemble vocal avec couplet et refrain

Ce canevas illustre la manière d’agencer une œuvre vocale où le couplet est chanté en solo et le refrain à deux voix. Vous noterez le recours aux silences invisibles dans la variable `\global` : ils permettent de positionner les changements de métrique et autres éléments communs à toutes les parties, ce pour l’intégralité du morceau.

    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
        }
      }
    }

## Ensemble vocal (simple)

Ce fichier constitue un canevas standard de partition pour chœur à quatre voix mixtes. Lorsque les ensembles s’étoffent, il est judicieux de recourir à une section spécifique incluse dans chacune des parties, tout particulièrement pour gérer la métrique et la tonalité qui, la plupart du temps, sont communes à tous les pupitres. Comme il est d’usage pour les hymnes, les quatre voix sont réparties sur deux portées.

    \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 — Morceaux choisis v2.22.2 (branche stable).