LilyPond snippets: Templates

# Templates

## Plantilla para notación de música antigua (transcripción moderna de canto gregoriano)

Este ejemplo muestra cómo hacer una transcripción moderna de canto gregoriano. El canto gregoriano no tiene compás ni plicas; utiliza solamente cabezas de nota de blanca y de negra, y unas marcas especiales que indican silencios de distintas longitudes.

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

## Plantilla de salmo del canto anglicano

Esta plantilla muestra una forma de preparar un cántico salmódico anglicano. También muestra cómo se pueden añadir estrofas adicionales como texto independiente por debajo de la música. Las dos estrofas se codifican en estilos diferentes para ilustrar más posibilidades.

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

## Plantilla para himnos

Este fragmento de código muestra una forma de preparar un himno cuando cada línea comienza con un compás parcial. También muestra cómo añadir los versos como texto independiente debajo de la música.

    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

## Plantilla para combo de jazz

Ésta es una plantilla bastante avanzada, para un conjunto de jazz. Observe que la notación de todos los instrumentos está en `\key c \major` (Do mayor). Esto se refiere al tono de concierto; la armadura se transporta automáticamente si la música está dentro de una sección `\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 { }
    }

## Plantilla de orquesta con coro y piano

Esta plantilla muestra el uso de contextos `StaffGroup` y `GrandStaff` anidados para sub-agrupar instrumentos del mismo tipo, y una forma de usar `\transpose` de manera que unas variables contengan la música para instrumentos transpositores en afinación de concierto.

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

## Plantilla de piano (sencilla)

Presentamos a continuación una plantilla de piano sencilla con algunas notas.

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

## Plantilla de piano con letra centrada

En lugar de tener un pentagrama dedicado a la melodía y la letra, ésta se puede centrar entre los pentagramas de un sistema de 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 { }
    }

## Plantilla de piano con melodía y letra

He aquí el típico formato dde una canción: un pentagrama con la melodía y la letra, y el acompañamiento de piano por debajo.

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

## Plantilla de coro SATB, a cuatro pentagramas

Plantilla de coro SATB (en cuatro pentagramas)

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

## Partitura para acordeón diatónico

Plantilla para escribir una partitura para acordeón diatónico.

- Hay una pauta horizontal que indica si el acordeón se debe cerrar (línea gruesa) o abrir (línea delgada).

- Hay una pauta rítmica pequeña con letra que describe los botones que hay que pulsar en el bajo. Las barras de compás están hechas a partir de líneas de rejilla.

- La pauta del tabulador para acordeones diatónicos muestra la posición geográfica de los botones y no (como en otros instrumentos) la altura de las notas; las llaves sobre el lado de la melodía del acordeón se ponen en tres columnas y unas doce filas.

En la notación de pauta del tabulador, la columna más externa se describe con notas entre líneas, la columnas más interna se describe con notas entre líneas y unas aspas como alteración accidental, y la columna central se describe con notas sobre una línea, mientras que la fila del medio se representa sobre la línea central del pentagrama.

A continuación algunas notas sobre la forma de transcribir notas de piano a acordeón diatónico:

1. Todo acordeón diatónico está construido para un cierto conjunto de tonalidades solamente (por ejemplo, para las tonalidades de Do mayor y Fa mayor), por lo que es importante transportar una melodía de piano que corresponda exactamente a una de esas tonalidades. Transporte el código fuente, no solamente la salida porque este código se necesita después para traducirlo de nuevo a la pauta del tabulador. Esto se puede hacer con la instrucción `displayLilyMusic`.

2. Tenemos que alternar las direcciones de abrir y de cerrar el fuelle de forma regular. Si el intérprete tiene un período de abrir el fuelle excesivamente largo, el acordeón puede romperse. Por otro lado, algunas armonías solamente están disponibles en una dirección. Teniendo esto en cuenta, debemos decidir qué partes de la melodía son las partes de cerrar y cuáles las de abrir.

3. Para cada una de las partes de abrir o cerrar, transcriba las notas del piano a la representación de tablatura correspondiente.

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

## Plantilla de pentagrama único con música, letra y acordes

Esta plantilla facilita la preparación de una canción con melodía, letra y acordes.

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

## Plantilla para un pentagrama único con música, letra, acordes y trastes

Presentamos a continuación un ejemplo de plantilla para una hoja guía de acordes con melodía, letra, acordes y diagramas de trastes.

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

## Plantilla de pentagrama único con música y acordes

¿Quiere preparar una hoja guía de acordes (o «lead sheet») con melodía y acordes? ¡No busque más!

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

## Plantilla de pentagrama único don notas y letra

Esta pequeña plantilla muestra una melodía sencilla con letra. Córtela y péguela, escriba las notas y luego la letra. Este ejemplo desactiva el barrado automático, que es lo más frecuente en las partes vocales antiguas. Para usar el barrado automático modifique o marque como un comentario la línea correspondiente.

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

## Plantilla de un solo pentagrama, con notas únicamente

Esta plantilla simple prepara un pentagrama con notas, adecuado para un instrumento solista o un fragmento melódico. Córtelo y péguelo en un archivo, escriba las notas y ¡ya está!

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

      a4 b c d
    }

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

## Plantilla de cuarteto de cuerda (sencilla)

Esta plantilla muestra un cuarteto de cuerda normal. También utiliza una sección `\global` para el compás y la armadura

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

## Plantilla de cuarteto de cuerda con particellas independientes

El fragmento de código “Plantilla de cuarteto de cuerda” produce un resultado satisfactorio para el cuarteto, pero ¿y si tenemos que imprimir las particellas? Esta nueva plantilla muestra cómo usar la funcionalidad `\tag` (etiqueta) para dividir fácilmente una pieza en particellas indicviduales.

Tenemos que dividir esta plantilla en archivos independientes; los nombres de archivo están dentro de los comentarios al principio de cada archivo. ‘`piece.ly`’ contiene todas las definiciones de música. Los otros archivos (‘`score.ly`’, ‘`vn1.ly`’, ‘`vn2.ly`’, ‘`vla.ly`’ y ‘`vlc.ly`’) producen la particella correspondiente.

¡No olvide quitar los comentarios que hemos especificado cuando use los archivos independientes!

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

    %}

## Plantilla de conjunto vocal con reducción de piano automática

Esta plantilla añade una reducción de piano automática a la partitura vocal SATB estándar que se mostró en la “Plantilla de conjunto vocal”. Esto presenta uno de los puntos fuertes de LilyPond: podemos usar una definición de música más de una vez. Si se hace cualquier cambio en las notas de la parte vocal (digamos `tenorMusic`), entonces los cambios se aplicarán también a la reducción de 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 >>
          >>
        >>
      >>
    }

## Plantilla para conjunto vocal con letras alineadas encima y debajo de los pentagramas

Esta plantilla es, básicamente, la misma que la sencilla plantilla “Conjunto vocal”, excepto que aquí todas las líneas de letra se colocan utilizando `alignAboveContext` y `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
      >>
    }

## Estrofa para solista y estribillo a dos voces

Esta plantilla crea una partitura que comienza con una estrofa para solista y continúa con un estribillo a dos voces. también muestra el uso de silencios de separación dentro de la variable `\global` para definir cambios de compás (y otros elementos que son comunes a todas las partes) a lo largo de toda la partitura.

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

## Plantilla de conjunto vocal

He aquí una partitura vocal estándar para cuatro voces SATB. Con grupos mayores, suele ser útil incluir una sección que aparezca en todas las partes. Por ejemplo, el compás y la armadura casi siempre son los mismos para todas. Como en la plantilla “Himno”, las cuatro voces se reagrupan en sólo dos pentagramas.

    \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 (rama estable).