LilyPond — Fragments

Aquest document mostra un conjunt seleccionat de fragments del Lilypond del LilyPond Snippet Repository (LSR). Està en el domini públic.

Voldríem donar moltes gràcies a Sebastiano Vigna per mantenir la pàgina web i la base de dades LSR, i a la Universitat de Milà per allotjar LSR.

Si us plau noteu que aquest document no és un subconjunt exacte del LSR: alguns fragments provenen del directory de codi Lilypond input/new, i els fragments del LSR es converteixen mitjançant convert-ly, atès que el LSR es basa en una versió estable del LilyPond, i aquest document és per a la versió 2.25.14.

Els fragments estan agrupats per etiquetes; les etiquetes llistades a la taula de continguts concorden amb una secció del manual de notació del LilyPond. Els fragments poden tenir moltes etiquetes, i no totes les etiquetes del LSR poden aparèixer en aquest document.

A la versió HTML d’aquest document podeu clicar sobre el nom del fitxer o figura per a cada exemple per veure el fitxer d’entrada corresponent.

Para mayor información sobre la forma en que este manual se relaciona con el resto de la documentación, o para leer este manual en otros formatos, consulte Manuales.

Si le falta algún manual, encontrará toda la documentación en https://lilypond.org/.


Pitches

Pitches


Afegir un àmbit per veu

Es pot afegir un àmbit per cada veu. En aquest cas, l’àmbit s’ha de desplaçar manualment per evitar col·lisions.

\new Staff <<
  \new Voice \with {
    \consists "Ambitus_engraver"
  } \relative c'' {
    \override Ambitus.X-offset = 2.0
    \voiceOne
    c4 a d e
    f1
  }
  \new Voice \with {
    \consists "Ambitus_engraver"
  } \relative c' {
    \voiceTwo
    es4 f g as
    b1
  }
>>

[image of music]


Afegir una indicació d’octava alta a una sola veu

Si teniu més d’una veu al mateix pentagrama, el canvi d’octavació d’una veu transportarà la posició de les notes en totes les veus mentre duri la clau de l’octava. Si l’octavació es vol aplicar sols a una veu, s’han d’ajustar explícitament la middleCPosition i la clau d’octava. En aquest fragment de codi el valor de middleCPosition per a la clau de Fa és normalment 6, sis posicions per sobre de la línia del Do central, de manera que en la porció de 8va el valor de middleCPosition és encara 7 posicions (una octava) més alta.

\layout {
  \context {
    \Staff
    \remove Ottava_spanner_engraver
  }
  \context {
    \Voice
    \consists Ottava_spanner_engraver
  }
}

{
  \clef bass
  << { <g d'>1~ q2 <c' e'> }
  \\
    {
      r2.
      \ottava -1
      <b,,, b,,>4 ~ |
      q2
      \ottava 0
      <c e>2
    }
  >>
}

[image of music]


Aiken head thin variant noteheads

Aiken head white notes get harder to read at smaller staff sizes, especially with ledger lines. Losing interior white space makes them appear as quarter notes.

\score {
  {
    \aikenHeads
    c''2 a' c' a

    % Switch to thin-variant noteheads
    \set shapeNoteStyles = ##(doThin reThin miThin
                              faThin sol laThin tiThin)
    c'' a' c' a
  }
}

[image of music]


Alterar la longitud de les pliques unides per una barra

Es pot variar la longitud de les pliques de les figures unides per una barra mitjançant la sobreescriptura de la propietat beamed-lengths dels detalls (details) de l’objecte Stem. Si s’utilitza un sol valor com argument, la longitud s’aplica a totes les pliques. Si s’usen diversos arguments, el primer s’aplica a les corxeres, el segon a les semicorxeres, i així successivament. L’últim argument també s’aplica a totes les figures que són més curtes que la longitud de la figura de l’últim argument. També es poden usar arguments no enters.

\relative c'' {
  \override Stem.details.beamed-lengths = #'(2)
  a8[ a] a16[ a] a32[ a]
  \override Stem.details.beamed-lengths = #'(8 10 12)
  a8[ a] a16[ a] a32[ a] r8
  \override Stem.details.beamed-lengths = #'(8)
  a8[ a]
  \override Stem.details.beamed-lengths = #'(8.5)
  a8[ a]
  \revert Stem.details.beamed-lengths
  a8[ a] a16[ a] a32[ a] r16
}

[image of music]


Indicacions de tessitura

Les indicacions d’àmbit o tessitura indiquen rangs d’altures per a les veus.

Les alteracions accidentals sols es mostren si no formen part de l’armadura de tonalitat. Els objectes gràfics AmbitusNoteHead també tenen línies addicionals.

\layout {
  \context {
    \Voice
    \consists "Ambitus_engraver"
  }
}

<<
  \new Staff {
    \relative c' {
      \time 2/4
      c4 f'
    }
  }
  \new Staff {
    \relative c' {
      \time  2/4
      \key d \major
      cis4 as'
    }
  }
>>

[image of music]


Ambitus after key signature

By default, ambitus are positioned at the left of the clef. The \ambitusAfter function allows for changing this placement. Syntax is \ambitusAfter grob-interface (see Graphical Object Interfaces for a list of possible values for grob-interface.)

A common use case is printing the ambitus between key signature and time signature.

\new Staff \with {
  \consists Ambitus_engraver
} \relative {
  \ambitusAfter key-signature
  \key d \major
  es'8 g bes cis d2
}

[image of music]


Àmbits amb diverses veus

L’addició del gravador Ambitus_engraver al context de Staff crea un sol àmbit per pentagrama, fins i tot en el cas de pentagrames amb diverses veus.

\new Staff \with {
  \consists "Ambitus_engraver"
  }
<<
  \new Voice \relative c'' {
    \voiceOne
    c4 a d e
    f1
  }
  \new Voice \relative c' {
    \voiceTwo
    es4 f g as
    b1
  }
>>

[image of music]


Aplicar estils de cap segons la nota de l’escala

La propietat shapeNoteStyles es pot usar per definir diversos estils de caps de nota per a cada grau de l’escala (segons estigui establert per l’armadura o per la propietat tonic). Aquesta propietat requereix un conjunt de símbols, que poden ser purament arbitraris (es permeten expressions geomètriques com triangle, triangle, cross, aspes, i xcircle, cercle amb aspes) o basats en una antiga tradició americana de gravat (també es permeten certs noms de nota llatins).

Dit això, per imitar antics cançoners americans, hi ha diversos estils predefinits de caps de nota disponibles mitjançant ordres d’abreviatura com \aikenHeads o \sacredHarpHeads.

Aquest exemple mostra diferents formes d’obtenir caps de nota amb forma i mostra la capacitat de transportar una melodia sense perdre la correspondència entre les funcions harmòniques i els estils de caps de nota.

fragment = {
  \key c \major
  c2 d
  e2 f
  g2 a
  b2 c
}

\new Staff {
  \transpose c d
  \relative c' {
    \set shapeNoteStyles = ##(do re mi fa
                               #f la ti)
    \fragment
  }

  \break

  \relative c' {
    \set shapeNoteStyles = ##(cross triangle fa #f
                               mensural xcircle diamond)
    \fragment
  }
}

[image of music]


Canviar la direcció de la plica de les notes de tercera línia automàticament, basat en la melodia

El LilyPond pot alterar la direcció de la plica de les notes que van en la tercera línia d’un pentagrama de forma que segueixi la melodia, mitjançant l’addició del gravador Melody_engraver al context Voice i sobreescrivint el valor de neutral-direction per a l’objecte Stem (plica).

\relative c'' {
  \time 3/4
  a8 b g f b g |
  \set suspendMelodyDecisions = ##t
  a  b g f b g |
  \unset suspendMelodyDecisions
  c  b d c b c |
}

\layout {
  \context {
    \Voice
    \consists "Melody_engraver"
    \autoBeamOff
  }
}

[image of music]


Changing ottava text

Internally, \ottava sets the properties ottavation (for example, to 8va or 8vb) and middleCPosition. To override the text of the bracket, set ottavation after invoking \ottava.

Short text is especially useful when a brief ottava is used.

{
  c'2
  \ottava 1
  \set Staff.ottavation = "8"
  c''2
  \ottava 0
  c'1
  \ottava 1
  \set Staff.ottavation = "Text"
  c''1
}

[image of music]


Modificació de la separació en les indicacions de tessitura

És possible ajustar la separació predeterminada entre les notes de la indicació de tessitura i la línia que les uneix.

\layout {
  \context {
    \Voice
    \consists "Ambitus_engraver"
  }
}

\new Staff {
  \time 2/4
  % Default setting
  c'4 g''
}

\new Staff {
  \time 2/4
  \override AmbitusLine.gap = 0
  c'4 g''
}

\new Staff {
  \time 2/4
  \override AmbitusLine.gap = 1
  c'4 g''
}

\new Staff {
  \time 2/4
  \override AmbitusLine.gap = 1.5
  c'4 g''
}

\paper { tagline = ##f }

[image of music]


Canviar l’interval de les línies de la pauta

S’usa staffLineLayoutFunction per canviar la posició de les notes. Aquest fragment de codi mostra com ajustar el seu valor al de ly:pitch-semitones per produir una escala cromàtica amb la distància entre cada espai i línia del pentagrama igual a un semitò.

scale = \relative c' {
  a4 ais b c
  cis4 d dis e
  f4 fis g gis
  a1
}

\new Staff \with {
  \remove "Accidental_engraver"
  staffLineLayoutFunction = #ly:pitch-semitones
}
{
  <<
    \scale
    \context NoteNames {
      \set printOctaveNames = ##f
      \scale
    }
  >>
}

[image of music]


Les claus es poden transposar en intervals arbitraris

Es poden transposar les claus en intervals arbitraris, no sols octaves.

\relative c' {
  \clef treble
  c4 c c c
  \clef "treble_8"
  c4 c c c
  \clef "treble_5"
  c4 c c c
  \clef "treble^3"
  c4 c c c
}

[image of music]


Acolorir les notes segons la seva alçada

És possible acolorir el cap de les notes depenent de la seva alçada i/o del seu nom: la funció que s’usa en aquest exemple fa possible fins i tot distingir els harmònics.

%Association list of pitches to colors.
#(define color-mapping
   (list
    (cons (ly:make-pitch 0 0 NATURAL) (x11-color 'red))
    (cons (ly:make-pitch 0 0 SHARP) (x11-color 'green))
    (cons (ly:make-pitch 0 1 FLAT) (x11-color 'green))
    (cons (ly:make-pitch 0 2 NATURAL) (x11-color 'red))
    (cons (ly:make-pitch 0 2 SHARP) (x11-color 'green))
    (cons (ly:make-pitch 0 3 FLAT) (x11-color 'red))
    (cons (ly:make-pitch 0 3 NATURAL) (x11-color 'green))
    (cons (ly:make-pitch 0 4 SHARP) (x11-color 'red))
    (cons (ly:make-pitch 0 5 NATURAL) (x11-color 'green))
    (cons (ly:make-pitch 0 5 FLAT) (x11-color 'red))
    (cons (ly:make-pitch 0 6 SHARP) (x11-color 'red))
    (cons (ly:make-pitch 0 1 NATURAL) (x11-color 'blue))
    (cons (ly:make-pitch 0 3 SHARP) (x11-color 'blue))
    (cons (ly:make-pitch 0 4 FLAT) (x11-color 'blue))
    (cons (ly:make-pitch 0 5 SHARP) (x11-color 'blue))
    (cons (ly:make-pitch 0 6 FLAT) (x11-color 'blue))))

%Compare pitch and alteration (not octave).
#(define (pitch-equals? p1 p2)
   (and
    (= (ly:pitch-alteration p1) (ly:pitch-alteration p2))
    (= (ly:pitch-notename p1) (ly:pitch-notename p2))))

#(define (pitch-to-color pitch)
   (let ((color (assoc pitch color-mapping pitch-equals?)))
     (if color
         (cdr color))))

#(define (color-notehead grob)
   (pitch-to-color
    (ly:event-property (event-cause grob) 'pitch)))

\score {
  \new Staff \relative c' {
    \override NoteHead.color = #color-notehead
    c8 b d dis ees f g aes
  }
}

[image of music]


Crear una seqüència de notes a diferents alçades

En una música que tingui moltes aparicions de la mateixa seqüència de notes a diferents altures, podria ser d’utilitat la següent funció musical. Admet una nota, de la qual sols s’utilitza la seva alçada. Les funcions de suport a l’Scheme s’han agafat prestades del document de "Consells i ajustament" de la versió 2.10 del manual. Aquest exemple crea les duracions rítmiques que s’usen a tot el llarg de «Mart», de «Els Planetes» de Gustav Holst.

rhythm =
#(define-music-function (p) (ly:pitch?)
   "Make the rhythm in Mars (the Planets) at the given pitch"
  #{ \tuplet 3/2 { $p 8 8 8 } 4 4 8 8 4 #})

\new Staff {
  \time 5/4
  \rhythm c'
  \rhythm c''
  \rhythm g
}

[image of music]


Creació d’armadures personalitzades

El LilyPond accepta armadures personalitzades. En aquest exemple, es mostra l’armadura de re menor amb una rang estès de bemolls.

\new Staff \with {
  \override StaffSymbol.line-count = #8
  \override KeySignature.flat-positions = #'((-7 . 6))
  \override KeyCancellation.flat-positions = #'((-7 . 6))
  % presumably sharps are also printed in both octaves
  \override KeySignature.sharp-positions = #'((-6 . 7))
  \override KeyCancellation.sharp-positions = #'((-6 . 7))

  \override Clef.stencil = #
  (lambda (grob)(grob-interpret-markup grob
  #{ \markup\combine
    \musicglyph "clefs.C"
    \translate #'(-3 . -2)
    \musicglyph "clefs.F"
   #}))
    clefPosition = #3
    middleCPosition = #3
    middleCClefPosition = #3
}

{
  \key d\minor
  f bes, f bes,
}

[image of music]


Direction of merged ’fa’ shape note heads

Using property NoteCollision.fa-merge-direction, the direction of “fa” shape note heads (“fa”, “faThin”, etc.) can be controlled independently of the stem direction if two voices with the same pitch and different stem directions are merged. If this property is not set, the “down” glyph variant is used.

{
  \clef bass

  << { \aikenHeads
       f2
       \override Staff.NoteCollision.fa-merge-direction = #UP
       f2 }
  \\ { \aikenHeads
       f2
       f2 }
  >>
}

[image of music]


Force a cancellation natural before accidentals

The following example shows how to force a natural sign before an accidental.

\relative c' {
  \key es \major
  bes c des
  \tweak Accidental.restore-first ##t
  eis
}

[image of music]


Forçar la impressió de la clau

Quan ja s’ha imprimit la clau i encara no s’ha canviat a una diferent, el LilyPond ignorarà la repetició de l’ordre \clef, ja que no constitueix un canvi de clau. És possible forçar la reimpressió de la clau usant l’ordre \set Staff.forceClef = ##t.

\relative c' {
  \clef treble
  c1
  \clef treble
  c1
  \set Staff.forceClef = ##t
  c1
  \clef treble
  c1
}

[image of music]


Generació de notes aleatòries

Aquest fragment de codi basat en l’Scheme genera 24 notes aleatòries (o tantes com calguin), basant-se en l’hora actual (o en qualsevol nombre pseudo-aleatori que s’especifiqui en el seu lloc, per obtenir les mateixes notes aleatòries cada cop): és a dir, per obtenir diferents patrons de notes, sols ha de modificar aquest número.

randomNotes =
#(define-music-function (n from to dur)
   (integer? ly:pitch? ly:pitch? ly:duration?)
   (let ((from-step (ly:pitch-steps from))
         (to-step (ly:pitch-steps to)))
     (make-sequential-music
      (map (lambda (_)
             (let* ((step (+ from-step
                             (random (- to-step from-step))))
                    (pitch (ly:make-pitch 0 step 0)))
               #{ $pitch $dur #}))
           (iota n)))))

\randomNotes 24 c' g'' 8

[image of music]


Ocultar les alteracions sobre notes lligades al principi d’un sistema nou

Aquí es mostra la manera d’ocultar les alteracions de les notes lligades al començament d’uns sistema nou.

\relative c'' {
  \override Accidental.hide-tied-accidental-after-break = ##t
  cis1~ cis~
  \break
  cis
}

\paper { tagline = ##f }

[image of music]


Mantenir la mida del símbol en els canvis de clau

Quan es produeix un canvi de clau, el símbol de clau s’imprimeix a una mida més petita que la clau inicial. Això es pot ajustar amb full-size-change.

\relative c' {
  \clef "treble"
  c1
  \clef "bass"
  c1
  \clef "treble"
  c1
  \override Staff.Clef.full-size-change = ##t
  \clef "bass"
  c1
  \clef "treble"
  c1
  \revert Staff.Clef.full-size-change
  \clef "bass"
  c1
  \clef "treble"
  c1
}

[image of music]


Exemple de «Makam»

El «Makam» és un tipus de melodia de Turquia que utilitza alteracions microtonals de 1/9 de to. Consulteu el fitxer d’inici makam.ly (vegeu el «Manual d’aprenentatge 2.25.14, 4.6.3 Altres forms d’informació» per esbrinar la situació d’aquest fitxer) per veure detalls dels noms de les notes i les alteracions.

% Initialize makam settings
\include "makam.ly"

\relative c' {
  \set Staff.keyAlterations = #`((6 . ,(- KOMA)) (3 . ,BAKIYE))
  c4 cc db fk
  gbm4 gfc gfb efk
  fk4 db cc c
}

[image of music]


Modifying the Ottava spanner slope

It is possible to change the slope of the Ottava spanner.

\relative c'' {
  \override Staff.OttavaBracket.stencil = #ly:line-spanner::print
  \override Staff.OttavaBracket.bound-details =
    #`((left . ((Y . 0)
                (attach-dir . ,LEFT)
                (padding . 0)
                (stencil-align-dir-y . ,CENTER)))
       (right . ((Y . 5.0) ; Change the number here
                 (padding . 0)
                 (attach-dir . ,RIGHT)
                 (text . ,(make-draw-dashed-line-markup
                           (cons 0 -1.2))))))
  \override Staff.OttavaBracket.left-bound-info =
     #ly:horizontal-line-spanner::calc-left-bound-info-and-text
  \override Staff.OttavaBracket.right-bound-info =
     #ly:horizontal-line-spanner::calc-right-bound-info
  \ottava 1
  c1
  c'''1
}

[image of music]


Armadures de tonalitat no tradicional

La molt utilitzada ordre \key estableix la propietat keyAlterations, dins del context Staff.

Per crear armadures de tonalitat no estàndard, ajusteu aquesta propietat directament. El format d’aquesta ordre és una llista:

\set Staff.keyAlterations = #`(((octava . pas) . alteració) on, per cada element dins de la llista octava especifica l’octava (sent zero l’octava des del Do central fins al Si per sobre), pas especifica la nota dins de l’octava (zero significa Do i 6 significa Si), i alteració és ,SHARP ,FLAT ,DOUBLE-SHARP etc. (observeu la coma precedent).

De forma alternativa, per a cada element de la llista l’ús del format més concís (pas. alteració) especifica que la mateixa alteració ha d’estar en totes les octaves.

Vet aquí un exemple d’una possible armadura per generar una escala exàtona:

\include "arabic.ly"
\relative do' {
  \set Staff.keyAlterations = #`((0 . ,SEMI-FLAT)
                                 (1 . ,SEMI-FLAT)
                                 (2 . ,FLAT)
                                 (5 . ,FLAT)
                                 (6 . ,SEMI-FLAT))
%\set Staff.extraNatural = ##f
  re reb \dwn reb resd
  dod dob dosd \dwn dob |
  dobsb dodsd do do |
}

[image of music]


Nombres com notes de notació fàcil

Els caps de nota de notació fàcil utilitzen la propietat note-names de l’objecte NoteHead per determinar el que apareix dins del cap. Mitjançant la sobreescriptura d’aquesta propietat, és possible imprimir nombres que representen el grau de l’escala.

Es pot crear un gravador simple que faci això per al cap de cada nota que ve.

#(define Ez_numbers_engraver
   (make-engraver
    (acknowledgers
     ((note-head-interface engraver grob source-engraver)
      (let* ((context (ly:translator-context engraver))
	     (tonic-pitch (ly:context-property context 'tonic))
	     (tonic-name (ly:pitch-notename tonic-pitch))
	     (grob-pitch
	      (ly:event-property (event-cause grob) 'pitch))
	     (grob-name (ly:pitch-notename grob-pitch))
	     (delta (modulo (- grob-name tonic-name) 7))
	     (note-names
	      (make-vector 7 (number->string (1+ delta)))))
	(ly:grob-set-property! grob 'note-names note-names))))))

#(set-global-staff-size 26)

\paper { tagline = ##f }

\layout {
  ragged-right = ##t
  \context {
    \Voice
    \consists \Ez_numbers_engraver
  }
}

\relative c' {
  \easyHeadsOn
  c4 d e f
  g4 a b c \break

  \key a \major
  a,4 b cis d
  e4 fis gis a \break

  \key d \dorian
  d,4 e f g
  a4 b c d
}

[image of music]


Plantilla d’orquestra amb cor i piano

Aquesta plantilla mostra l’ús de contextos StaffGroup i GrandStaff niuats per sub-agrupar instruments del mateix tipus, i una forma d’usar \transpose de manera que unes variables continguin la música per a instruments transpositors en afinació de concert.

#(set-global-staff-size 17)

\paper {
  indent = 3.0\cm  % add space for instrumentName
  short-indent = 1.5\cm  % add less space for shortInstrumentName
}

\header { tagline = ##f }


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

[image of music]


Evitar que s’afegeixen becaires addicionals automàticament

Segons les regles tradicionals de composició tipogràfica, s’imprimeix un becaire abans d’un sostingut o un bemoll quan s’ha de cancel·lar un doble sostingut o un doble bemoll anterior en la mateixa nota. Per modificar aquest comportament a la pràctica actual establiu el valor de la propietat extraNatural a ##f (fals) dins del context de Staff.

\relative c'' {
  aeses4 aes ais a
  \set Staff.extraNatural = ##f
  aeses4 aes ais a
}

[image of music]


Evitar que se impriman becuadros cuando cambia la armadura

Quan es canvia l’armadura de la tonalitat, s’imprimeixen becaires automàticament per cancel·lar les alteracions de les armadures anteriors. Això es pot evitar establint al valor “falso” la propietat printKeyCancellation del context Staff.

\relative c' {
  \key d \major
  a4 b cis d
  \key g \minor
  a4 bes c d
  \set Staff.printKeyCancellation = ##f
  \key d \major
  a4 b cis d
  \key g \minor
  a4 bes c d
}

[image of music]


Citació d’una altra veu amb transposició

Els passatges citats tenen en compte la trasnposició de la font tant com la del destí. En aquest exemple, tots els instruments interpreten una nota amb el so de Do central; el destí d’un instrument transpositor en Fa. La part de destí es pot transportar utilitzant \transpose. En aquest cas les notes citades romanen sense canvis.

\addQuote clarinet {
  \transposition bes
  \repeat unfold 8 { d'16 d' d'8 }
}

\addQuote sax {
  \transposition es'
  \repeat unfold 16 { a8 }
}

quoteTest = {
  % french horn
  \transposition f
  g'4
  << \quoteDuring "clarinet" { \skip 4 } s4^"clar." >>
  << \quoteDuring "sax" { \skip 4 } s4^"sax." >>
  g'4
}

{
  \new Staff \with {
    instrumentName = \markup { \column { Horn "in F" } }
  }
  \quoteTest
  \transpose c' d' << \quoteTest s4_"up a tone" >>
}

[image of music]


Separar les cancel·lacions de tonalitat dels canvis d’armadura

De forma predeterminada, les alteracions accidentals que s’usen per a les cancel·lacions a les armadures es col·loquen adjacents a les que s’usen per als canvis de tonalitat. Aquest comportament es pot canviar sobreescrivint la propietat 'break-align-orders de l’objecte gràfic BreakAlignment.

El valor de 'break-align-orders és un vector de longitud 3, amb llistes entre cometes els elements de les quals són objectes que es poden dividir en un salt. Aquest exemple sols modifica la segona llista, movent key-cancellation abans de staff-bar; modificant la segona llista, el comportament d’alineació dels salts canvia en la meitat d’un sistema, no al principi ni al final.

#(define (insert-before where what lst)
   (cond
    ((null? lst)           ; If the list is empty,
     (list what))          ; return a single-element list.
    ((eq? where (car lst)) ; If we find symbol `where`,
     (cons what lst))      ; insert `what` before curr. position.
    (else                  ; Otherwise keep building the list by
     (cons (car lst)       ; adding the current element and
                           ; recursing with the next element.
           (insert-before where what (cdr lst))))))

cancellationFirst =
\override Score.BreakAlignment.break-align-orders =
#(grob-transformer
  'break-align-orders
  (lambda (grob orig)
    (let* ((middle (vector-ref orig 1))
           (middle (delq 'key-cancellation middle))
           (middle (insert-before
                    'staff-bar 'key-cancellation middle)))
      (vector
       ;; end of line
       (vector-ref orig 0)
       ;; middle of line
       middle
       ;; beginning of line
       (vector-ref orig 2)))))

music = { \key es \major d'1 \bar "||"
          \key a \major d'1 }

{ <>^\markup "default"
  \music }

{ <>^\markup "cancellation first"
  \cancellationFirst
  \music }

\paper { tagline = ##f }

[image of music]


Transposició de la música amb el menor nombre d’alteracions

Aquest exemple utilitza codi de l’Scheme per forçar les modificacions enharmòniques de les notes, i així tenir el menor nombre d’alteracions accidentals. En aquest cas s’apliquen les regles següents:

D’aquesta forma se selecciona el major nombre de notes enharmòniques naturals.

#(define (naturalize-pitch p)
   (let ((o (ly:pitch-octave p))
         (a (* 4 (ly:pitch-alteration p)))
         ;; alteration, a, in quarter tone steps,
         ;; for historical reasons
         (n (ly:pitch-notename p)))
     (cond
      ((and (> a 1) (or (eqv? n 6) (eqv? n 2)))
       (set! a (- a 2))
       (set! n (+ n 1)))
      ((and (< a -1) (or (eqv? n 0) (eqv? n 3)))
       (set! a (+ a 2))
       (set! n (- n 1))))
     (cond
      ((> a 2) (set! a (- a 4)) (set! n (+ n 1)))
      ((< a -2) (set! a (+ a 4)) (set! n (- n 1))))
     (if (< n 0) (begin (set! o (- o 1)) (set! n (+ n 7))))
     (if (> n 6) (begin (set! o (+ o 1)) (set! n (- n 7))))
     (ly:make-pitch o n (/ a 4))))

#(define (naturalize music)
   (let ((es (ly:music-property music 'elements))
         (e (ly:music-property music 'element))
         (p (ly:music-property music 'pitch)))
     (if (pair? es)
         (ly:music-set-property!
          music 'elements
          (map naturalize es)))
     (if (ly:music? e)
         (ly:music-set-property!
          music 'element
          (naturalize e)))
     (if (ly:pitch? p)
         (begin
           (set! p (naturalize-pitch p))
           (ly:music-set-property! music 'pitch p)))
     music))

naturalizeMusic =
#(define-music-function (m)
   (ly:music?)
   (naturalize m))

music = \relative c' { c4 d e g }

\score {
  \new Staff {
    \transpose c ais { \music }
    \naturalizeMusic \transpose c ais { \music }
    \transpose c deses { \music }
    \naturalizeMusic \transpose c deses { \music }
  }
  \layout { }
}

[image of music]


Turkish Makam example

This template uses the start of a well-known Turkish Saz Semai that is familiar in the repertoire in order to illustrate some of the elements of Turkish music notation.

\paper { tagline = ##f }

% Initialize makam settings
\include "turkish-makam.ly"

\header {
    title = "Hüseyni Saz Semaisi"
    composer = "Lavtacı Andon"
}

\relative {
  \set Staff.extraNatural = ##f
  \set Staff.autoBeaming = ##f

  \key a \huseyni
  \time 10/8

  a'4 g'16 [fb] e8. [d16] d [c d e] c [d c8] bfc |
  a16 [bfc a8] bfc c16 [d c8] d16 [e d8] e4 fb8 |
  d4 a'8 a16 [g fb e] fb8 [g] a8. [b16] a16 [g] |
  g4 g16 [fb] fb8. [e16] e [g fb e] e4 r8 |
}

[image of music]


Ajustament de les propietats de clau

La modificació del glif de la clau, la seva posició o octava, no canvien ’per se’ la posició de les notes següents del pentagrama. Per aconseguir armadures adequades de tonalitat sobre les línies del pentagrama, s’ha d’especificar també middleCClefPosition, amb valor positius o negatius que moguin Do central cap amunt o cap avall, respectivament, en relació amb la línia central del pentagrama (usualment la tercera).

Per exemple, l’ordre \clef "treble_8" equival a un ajustament de clefGlyph, clefPosition (que controla la posició vertical de la clau sobre el pentagrama), middleCPosition i clefTransposition. Se imprimeix la clau cada cop que es modifica qualsevol de les propietats excepte middleCPosition.

Els exemple següents mostren les possibilitats quan s’ajusten aquestes propietats manualment. En la primera línia, els canvis manuals preserven la posició relativa estàndard de les clau i les notes, però no ho fan a la segona línia.

{
  % The default treble clef
  \key f \major
  c'1
  % The standard bass clef
  \set Staff.clefGlyph = "clefs.F"
  \set Staff.clefPosition = 2
  \set Staff.middleCPosition = 6
  \set Staff.middleCClefPosition = 6
  \key g \major
  c'1
  % The baritone clef
  \set Staff.clefGlyph = "clefs.C"
  \set Staff.clefPosition = 4
  \set Staff.middleCPosition = 4
  \set Staff.middleCClefPosition = 4
  \key f \major
  c'1
  % The standard choral tenor clef
  \set Staff.clefGlyph = "clefs.G"
  \set Staff.clefPosition = -2
  \set Staff.clefTransposition = -7
  \set Staff.middleCPosition = 1
  \set Staff.middleCClefPosition = 1
  \key f \major
  c'1
  % A non-standard clef
  \set Staff.clefPosition = 0
  \set Staff.clefTransposition = 0
  \set Staff.middleCPosition = -4
  \set Staff.middleCClefPosition = -4
  \key g \major
  c'1 \break

  % The following clef changes do not preserve
  % the normal relationship between notes, key signatures
  % and clefs:

  \set Staff.clefGlyph = "clefs.F"
  \set Staff.clefPosition = 2
  c'1
  \set Staff.clefGlyph = "clefs.G"
  c'1
  \set Staff.clefGlyph = "clefs.C"
  c'1
  \set Staff.clefTransposition = 7
  c'1
  \set Staff.clefTransposition = 0
  \set Staff.clefPosition = 0
  c'1

  % Return to the normal clef:

  \set Staff.middleCPosition = 0
  c'1
}

\paper { tagline = ##f }

[image of music]


Usar canvi automàtic de pentagrama amb més d’una veu

Utilització de autochange amb més d’una veu.

\score {
  \new PianoStaff
  <<
    \new Staff = "up" {
      <<
        \set Timing.beamExceptions = #'()
        \set Timing.beatStructure = #'(4)
        \new Voice {
          \voiceOne
          \autoChange
          \relative c' {
            g8 a b c d e f g
            g,8 a b c d e f g
          }
        }

        \new Voice {
          \voiceTwo
          \autoChange
          \relative c' {
            g8 a b c d e f g
            g,,8 a b c d e f g
          }
        }
      >>
    }

    \new Staff = "down" {
      \clef bass
    }
  >>
}

[image of music]


Rhythms

Rhythms


Afegir barres, lligadures d’expressió i d’unió, etc., quan s’usen ritmes amb i sense grups de valoració especial.

La sintaxi del LilyPond pot implicar moltes col·locacions poc comunes per als parèntesis, claus, etc., que a vegades s’han d’intercalar. Per exemple, en introduir una barra manual, la clau esquerra d’apertura s’ha d’escriure després de la nota inicial i de la seva duració, no abans. De forma semblant, la clau dreta de tancament ha de seguir immediatament a la nota que es vol ubicar al final del barrat, fins i tot si aquesta nota resulta estar dins d’un grup de valoració especial. Aquest fragment de codi mostra com combinar el barrat manual, les lligadures d’expressió i d’unió i les lligadures de fraseig, amb seccions de valoració especial (tancades entre claus).

{
  r16[ g16 \tuplet 3/2 { r16 e'8] }
  g16( a \tuplet 3/2 { b d e') }
  g8[( a \tuplet 3/2 { b d') e'] ~ }
  \time 2/4
  \tuplet 5/4 { e'32\( a b d' e' } a'4.\)
}

[image of music]


Escriptura de parts de percussió

Mitjançant la utilització de les potents eines preconfigurades com la funció \drummode i el context DrumStaff, la introducció de parts per a percussió és molt fàcil: les percussions se situen en les seves pròpies posicions de pentagrama (amb una clau especial) i tenen els caps corresponents a l’instrument. És possible afegir un símbol addicional a la percussió o reduir el nombre de línies.

drh = \drummode {
        cymc4.^"crash" hhc16^"h.h." hh hhc8 hho hhc8 hh16 hh
        hhc4 r4 r2
      }
drl = \drummode {
        bd4 sn8 bd bd4 << bd ss >>
        bd8 tommh tommh bd toml toml bd tomfh16 tomfh
      }
timb = \drummode {
         timh4 ssh timl8 ssh r timh r4
         ssh8 timl r4 cb8 cb
       }

\score {
  <<
    \new DrumStaff \with {
      instrumentName = "timbales"
      drumStyleTable = #timbales-style
      \override StaffSymbol.line-count = #2
      \override BarLine.bar-extent = #'(-1 . 1)
    }
    <<
      \timb
    >>
    \new DrumStaff \with { instrumentName = "drums" }
    <<
      \new DrumVoice { \stemUp \drh }
      \new DrumVoice { \stemDown \drl }
    >>
  >>
  \layout { }
  \midi { \tempo 4 = 120 }
}

[image of music]


Ajustament d’espaiat de les notes d’adorn

Es poden ajustar la separació entre les notes d’adorn utilitzant la propietat spacing-increment de Score.GraceSpacing.

graceNotes = {
  \grace { c4 c8 c16 c32 }
  c8
}

\relative c'' {
  c8
  \graceNotes
  \override Score.GraceSpacing.spacing-increment = #2.0
  \graceNotes
  \revert Score.GraceSpacing.spacing-increment
  \graceNotes
}

[image of music]


Alineació dels números de compàs

Els números de compàs s’alineen de forma predeterminada per la dreta amb el seu objecte pare. Aquest objecte és pel general la vora esquerra, d’una línia o, si els números s’imprimeixen dins de la línia, la vora esquerra d’una línia divisòria. Els números també es poden situar directament sobre la barra de compàs o alineats per l’esquerra amb ella.

\relative c' {
  \set Score.currentBarNumber = 111
  \override Score.BarNumber.break-visibility = #all-visible
  % Increase the size of the bar number by 2
  \override Score.BarNumber.font-size = 2
  % Print a bar number every second measure
  \set Score.barNumberVisibility = #(every-nth-bar-number-visible 2)
  c1 | c1
  % Center-align bar numbers
  \override Score.BarNumber.self-alignment-X = #CENTER
  c1 | c1
  % Left-align bar numbers
  \override Score.BarNumber.self-alignment-X = #LEFT
  c1 | c1
}

[image of music]


Formes alternatives de la figura breu

Les figures de breu també estan disponibles amb dues línies verticals a les vores del cap en lloc d’una sola línia i la forma en estil barroc.

\relative c'' {
  \time 4/2
  c\breve |
  \override Staff.NoteHead.style = #'altdefault
  b\breve
  \override Staff.NoteHead.style = #'baroque
  b\breve
  \revert Staff.NoteHead.style
  a\breve
}

[image of music]


Appoggiatura or grace note before a bar line

By default, appoggiaturas and grace notes that occur on the first beat of a measure are printed after the bar line. They can however be printed before, simply by adding an invisible BarLine and then the visible one, as demonstrated here.

{
  R1
  %% default
  \appoggiatura d''8 c''4 r2.
  %% cheated
  \appoggiatura { \bar "" d''8 \bar "|" } c''4 r2.
}

[image of music]


Subdivisions de barra automàtiques

Es poden subdividir les barres automàticament. Establint la propietat subdivideBeams, les barres se subdivideixen en posiciones de pols (tal i com s’especifica a beatLength).

\new Staff {
  \relative c'' {
    <<
      {
        \voiceOne
        \set subdivideBeams = ##t
        b32[ a g f c' b a g
        b32^"subdivide beams" a g f c' b a g]
      }
      \new Voice {
        \voiceTwo
        b32_"default"[ a g f c' b a g
        b32 a g f c' b a g]
      }
    >>
    \oneVoice
    \once \set minimumBeamSubdivisionInterval = \musicLength 8
    b32^"minimumBeamSubdivisionInterval 1 8"[ a g f c' b a g]
    \once \set maximumBeamSubdivisionInterval = \musicLength 16
    b32^"maximumBeamSubdivisionInterval 1 16"[ a g f c' b a g]
  }
}

[image of music]


Modificar duracions automàticament

Es pot usar shiftDurations per canviar la longitud de les notes d’una peça musical. Agafa dos arguments: El factor d’escalat com una potència de dos, i el nombre de puntets a afegir com un enter positiu.

\paper {
  indent = 0
  tagline = ##f
}

music = \relative c'' { a1 b2 c4 d8 r }

{
  \time 4/2
  \music
  \time 4/4
  \shiftDurations 1 0 \music
  \time 2/4
  \shiftDurations 2 0 \music
  \time 4/1
  \shiftDurations -1 0 \music
  \time 8/1
  \shiftDurations -2 0 \music
  \time 6/2
  \shiftDurations 0 1 \music
  \time 7/2
  \shiftDurations 0 2 \music
}

[image of music]


Finals de barra en el context Score

Les regles de final de barra especificades en el context Score s’apliquen a tots els pentagrames, però es poden modificar tant en els nivells de Staff como de Voice:

\relative c'' {
  \time 5/4
  % Set default beaming for all staves
  \set Score.baseMoment = \musicLength 8
  \set Score.beatStructure = 3,4,3
  <<
    \new Staff {
      c8 c c c c c c c c c
    }
    \new Staff {
      % Modify beaming for just this staff
      \set Staff.beatStructure = 6,4
      c8 c c c c c c c c c
    }
    \new Staff {
      % Inherit beaming from Score context
      <<
        {
          \voiceOne
          c8 c c c c c c c c c
        }
        % Modify beaming for this voice only
        \new Voice {
          \voiceTwo
          \set Voice.beatStructure = 6,4
          a8 a a a a a a a a a
        }
      >>
    }
  >>
}

[image of music]


Barres que travessen salts de línia

Normalment estan prohibits els salts de línia si les barres travessen les línies divisòries. Es pot canviar aquest comportament com es mostra aquí:

\relative c'' {
  \override Beam.breakable = ##t
  c8 c[ c] c[ c] c[ c] c[ \break
  c8] c[ c] c[ c] c[ c] c
}

\paper { tagline = ##f }

[image of music]


Canviar el salt de les barres en angle

S’insereixen automàticament barres en angle quan es detecta un interval molt gran entre les notes. Es pot fer un ajustament fi d’aquest comportament mitjançant de la propietat auto-knee-gap. Es traça una barra doblada si el salt és més gran que el valor de auto-knee-gap més l’amplada de l’objecte barra (que depèn de la duració de les notes i de la inclinació de la barra). De forma predeterminada auto-knee-gap està establerta a 5.5 espais de pentagrama.

{
  f8 f''8 f8 f''8
  \override Beam.auto-knee-gap = 6
  f8 f''8 f8 f''8
}

[image of music]


Canviar la forma dels silencis multicompàs

Si hi ha deu compassos de silenci o menys, s’imprimeix en el pentagrama una sèrie de silencis de breu i longa (coneguts en alemany com “Kirchenpausen”, «silencis eclesiàstics»); en cas contrari es mostra una barra normal. Aquest nombre predeterminat de deu es pot canviar sobreescrivint la propietat expand-limit:

\relative c'' {
  \compressMMRests {
    R1*2 | R1*5 | R1*9
    \override MultiMeasureRest.expand-limit = 3
    R1*2 | R1*5 | R1*9
  }
}

[image of music]


Modificar el nombre de puntets d’una nota

La quantitat de puntets d’una nota es pot modificar independentment dels puntets que s’escriuen després d’una nota.

\relative c' {
  c4.. a16 r2 |
  \override Dots.dot-count = 4
  c4.. a16 r2 |
  \override Dots.dot-count = 0
  c4.. a16 r2 |
  \revert Dots.dot-count
  c4.. a16 r2 |
}

[image of music]


Canviar el tempo sense indicació metronòmica

Per canviar el tempo a la sortida MIDI sense imprimir res, fem invisible la indicació metronòmica:

\score {
  \new Staff \relative c' {
    \tempo 4 = 160
    c4 e g b
    c4 b d c
    \set Score.tempoHideNote = ##t
    \tempo 4 = 96
    d,4 fis a cis
    d4 cis e d
  }
  \layout { }
  \midi { }
}

[image of music]


Canviar el número del grup especial

De forma predeterminada sols s’imprimeix sobre la clau de grup el numerador del grup especial, és a dir, el numerador de l’argument de l’odre \tuplet.

De forma alternativa, es pot imprimir una fracció en la forma numerador:denominador del número de del grup, o eliminar el número.

\relative c'' {
  \tuplet 3/2 { c8 c c }
  \tuplet 3/2 { c8 c c }
  \override TupletNumber.text = #tuplet-number::calc-fraction-text
  \tuplet 3/2 { c8 c c }
  \omit TupletNumber
  \tuplet 3/2 { c8 c c }
}

[image of music]


Modificar el compàs d’una secció polimètrica utilitzant \scaleDurations

La propietat measureLength, junt amb measurePosition, determina quan cal dibuixar una línia divisòria. No obstant, en utilitzar \scaleDurations, l’escalat proporcional de les duracions fa difícil introduir canvis de compàs. En aquest cas s’ha d’establir manualment el valor de measureLength utilitzant la funció ly:make-moment. El segon argument ha de ser el mateix que el segon artgument de \scaleDurations.

\layout {
  \context {
    \Score
    \remove "Timing_translator"
  }
  \context {
    \Staff
    \consists "Timing_translator"
  }
}

<<
  \new Staff {
    \scaleDurations 8/5 {
      \time 6/8
      \set Timing.measureLength = \musicLength 1*6/5
      b8 b b b b b
      \time 2/4
      \set Timing.measureLength = \musicLength 1*4/5
      b4 b
    }
  }
  \new Staff {
    \clef bass
    \time 2/4
    c2 d e f
  }
>>

[image of music]


Notació de responsos o salms

Aquest tipus de notació s’utilitza per als cants salmòdics, en les quals les estrofes no sempre tenen la mateixa longitud.

stemOff = \hide Staff.Stem
stemOn  = \undo \stemOff

\score {
  \new Staff \with { \remove "Time_signature_engraver" }
  {
    \key g \minor
    \cadenzaOn
    \stemOff a'\breve bes'4 g'4
    \stemOn a'2 \section
    \stemOff a'\breve g'4 a'4
    \stemOn f'2 \section
    \stemOff a'\breve^\markup { \italic flexe }
    \stemOn g'2 \fine
  }
}

[image of music]


Indicacions de compassos compostos

Les indicacions de compàs poc freqüents com "5/8" es poden executar com a compassos compostos (per exemple "3/8 + 2/8"), que combinen dos o més metres diferents. El LilyPond pot fer la música d’aquest tipus fàcil de llegir e interpretar, imprimint explícitament les indicacions de compàs compost i adaptant el comportament automàtic de les barres (també es poden afegir indicacions gràfiques de l’agrupació de compassos; vegeu el fragment de codi apropiat en la base de dades).

\relative c' {
  \compoundMeter #'((2 8) (3 8))
  c8 d e fis gis
  c8 fis, gis e d
  c8 d e4 gis8
}

[image of music]


Símbols de direcció y símbols d’agrupació de compàs

L’agrupació de pulsacions dins d’un compàs està controlada per la propietat de context beatStructure. Hi ha establerts valors de beatStructure per a molts tipus de compassos a scm/time-signature-settings.scm. Els valors de beatStructure es poden canviar o establir amb \set. Com alternativa, es pot usar \time per establir tant el compàs com l’estructura de pulsacions. Per això, especifiquem l’agrupació interna de les pulsacions del compàs com una llista de nombres (en la sintaxi de l’Scheme) abans de la indicació del compàs.

\time s’aplica al context Timing, per la qual cosa no restableix els valors de beatStructure ni de baseMoment que s’estableixen en altres contextos de nivell inferior, com Voice.

Si el gravador Measure_grouping_engraver està inclòs en un dels contextos de presentació, s’imprimiran signes d’agrupació de pulsacions. Aquests símbols faciliten la lectura de música moderna rítmicament complexa. En aquest exemple, el compàs de 9/8 s’agrupa segons dos patrons diferents utilitzant els dos mètodes, mentre que el compàs de 5/8 s’agrup d’acord amb l’ajustament predeterminat que està a scm/time-signature-settings.scm:

\score {
  \new Voice \relative c'' {
    \time 9/8
    g8 g d d g g a( bes g) |
    \set Timing.beatStructure = 2,2,2,3
    g8 g d d g g a( bes g) |
    \time 4,5 9/8
    g8 g d d g g a( bes g) |
    \time 5/8
    a4. g4 |
  }
  \layout {
    \context {
      \Staff
      \consists "Measure_grouping_engraver"
    }
  }
}

[image of music]


Números de compàs alineats a l’esquerra de forma consistent

Quan s’alinien els números de compàs, poden aparèixer problemes de superposició amb les claus de sistema. Aquest fragment de codi ho resoleu deixant alineats a la dreta els números de compàs després d’un salt de línia.

consistentlyLeftAlignedBarNumbers = {
  \override Score.BarNumber.break-visibility = #end-of-line-invisible
  \override Score.BarNumber.self-alignment-X =
    #(lambda (grob)
       (let ((break-dir (ly:item-break-dir grob)))
         (if (= break-dir RIGHT) RIGHT LEFT)))
}

\new ChoirStaff <<
  \new Staff {
    \relative c' {
      \set Score.barNumberVisibility = #(every-nth-bar-number-visible 3)
      \bar ""
      \consistentlyLeftAlignedBarNumbers

      \set Score.currentBarNumber = #112
      \repeat unfold 8 { R1 }
      \break
      \repeat unfold 9 { R1 }
      \break
      \repeat unfold 7 { R1 }
    }
  }
  \new Staff {
    \relative c' {
      \repeat unfold 24 { R1 }
    }
  }
>>

\layout {
  indent = #0
  ragged-right = ##t
  ragged-last = ##t
}

\paper { tagline = ##f }

[image of music]


Control de la visibilitat dels corxets de grup especial

El comportament predeterminat de la visibilitat dels corxets de grup de valoració especial és imprimir el corxet a no ser que hi hagi una barra de la mateixa longitud que el grup especial. Per controlas la visibilitat dels corxets de grup, establiu la propietat 'bracket-visibility a #t (sempre imprimir el corxet). #f (no imprimir-lo mai) o #'if-no-beam (imprimir el corxet sols si no hi ha barra).

music = \relative c'' {
  \tuplet 3/2 { c16[ d e } f8]
  \tuplet 3/2 { c8 d e }
  \tuplet 3/2 { c4 d e }
}

\new Voice {
  \relative c' {
    \override Score.TextMark.non-musical = ##f
    \textMark "default" \music
    \override TupletBracket.bracket-visibility = #'if-no-beam
    \textMark \markup \typewriter "'if-no-beam" \music
    \override TupletBracket.bracket-visibility = ##t
    \textMark \markup \typewriter "#t" \music
    \override TupletBracket.bracket-visibility = ##f
    \textMark \markup \typewriter "#f" \music
    \omit TupletBracket
    \textMark \markup \typewriter "omit" \music
  }
}

\paper { tagline = ##f }

[image of music]


Cow and ride bell example

Two different bells, entered with ’cb’ (cowbell) and ’rb’ (ridebell).

\paper { tagline = ##f }

#(define mydrums '((ridebell default #f  3)
                   (cowbell  default #f -2)))

\new DrumStaff \with { instrumentName = #"Different Bells" }

\drummode {
  \set DrumStaff.drumStyleTable = #(alist->hash-table mydrums)
  \set DrumStaff.clefPosition = 0.5
  \override DrumStaff.StaffSymbol.line-positions = #'(-2 3)
  \override Staff.BarLine.bar-extent = #'(-1.0 . 1.5)

  \time 2/4
  rb8 8 cb8 16 rb16-> ~ |
  16 8 16 cb8 8 |
}

[image of music]


Crear indicacions metronòmiques en mode de marcatge

Es poden crear indicacions metronòmiques noves en mode de marcatge, però no canvien el tempo en la sortida MIDI.

\relative c' {
  \tempo \markup {
    \concat {
      (
      \smaller \general-align #Y #DOWN \note {16.} #1
      " = "
      \smaller \general-align #Y #DOWN \note {8} #1
      )
    }
  }
  c1
  c4 c' c,2
}

[image of music]


Gravat manual de les lligadures

Es poden gravar a mà les lligadures modificant la propietat tie-configuration de l’objecte TieColumn. El primer nombre indica la distància a partir de la tercera línia del pentagrama en espais de pentagrama, i el segon nombre indica la direcció (1 = cap amunt, -1 = cap avall).

\relative c' {
  <>^"default"
  g'1 ^~ g

  <>^"0"
  \once \override Tie.staff-position = 0
  g1 ^~ g

  <>^"0.0"
  \once \override Tie.staff-position = 0.0
  g1 ^~ g

  <>^"reset"
  \revert Tie.staff-position
  g1 ^~ g
}

\relative c' {
  \override TextScript.outside-staff-priority = ##f
  \override TextScript.padding = 0

  <>^"default"
  <c e g>1~ <c e g>

  <>^"0, -2, -4"
  \override TieColumn.tie-configuration =
    #'((0 . 1) (-2 . 1) (-4 . 1))
  <c e g>1~ <c e g>

  <>^"0.0, -2.0, -4.0"
  \override TieColumn.tie-configuration =
    #'((0.0 . 1) (-2.0 . 1) (-4.0 . 1))
  <c e g>1~ <c e g>

  <>^"reset"
  \override TieColumn.tie-configuration = ##f
  <c e g>1~ <c e g>
}

\paper { tagline = ##f }

[image of music]


Trèmols amb barres flotants

Si la duració total d’un trèmol és menor d’una negra, o exactament d’una blanca, normalment es grava amb totes les barres de corxera tocant les pliques. Certs estils de notació de partitures composen algunes d’aquestes barres com a barres flotants centrades que no toquen les pliques de les figures. El nombre de barres flotants en aquest tipus de trèmol està controlat per la propietat 'gap-count del l’objecte Beam i la separació entre les barres i les pliques es fixa amb la propietat 'gap.

\relative c'' {
  \repeat tremolo 8 { a32 f }
  \override Beam.gap-count = #1
  \repeat tremolo 8 { a32 f }
  \override Beam.gap-count = #2
  \repeat tremolo 8 { a32 f }
  \override Beam.gap-count = #3
  \repeat tremolo 8 { a32 f }

  \override Beam.gap-count = #3
  \override Beam.gap = #1.33
  \repeat tremolo 8 { a32 f }
  \override Beam.gap = #1
  \repeat tremolo 8 { a32 f }
  \override Beam.gap = #0.67
  \repeat tremolo 8 { a32 f }
  \override Beam.gap = #0.33
  \repeat tremolo 8 { a32 f }
}

[image of music]


Entering several tuplets using only one \tuplet command

The property tupletSpannerDuration sets how long each of the tuplets contained within the brackets after \tuplet should last. Many consecutive tuplets can then be placed within a single \tuplet expression, thus saving typing.

There are several ways to set tupletSpannerDuration. The command \tupletSpan sets it to a given duration, and clears it when instead of a duration \default is specified. Another way is to use an optional argument with \tuplet.

\relative c' {
  \time 2/4
  \tupletSpan 4
  \tuplet 3/2 { c8^"\\tupletSpan 4" c c c c c }
  \tupletSpan \default
  \tuplet 3/2 { c8^"\\tupletSpan \\default" c c c c c }
  \tuplet 3/2 4 { c8^"\\tuplet 3/2 4 {...}" c c c c c }
}

[image of music]


Claudàtors rectes i extrems de barra separats

Són possibles tant els claudàtors rectes sobre notes soltes com extrems de barra separats en figures unides, amb una combinació de stemLeftBeamCount, stemRightBeamCount i indicadors de barra [] emparellats.

Per a claudàtors rectes que apunten a la dreta sobre notes soltes, useu indicadors de barra emparellats [] y establiu stemLeftBeamCount a zero (vegeu l’exemple 1).

Per a claudàtors rectes que apunten a l’esquerra, establiu en canvi stemRightBeamCount (exemple 2).

Per a extrems separats que apunten a la dreta al final d’un conjunt de notes unides, establiu stemRightBeamCount a un valor positiu. I per a extrems separats que apunten a l’esquerra al principi d’un conjunt de notes unides, establiu stemLeftBeamCount en canvi (exemple 3).

A vegades per a una nota separada rodejada de silencis té sentit que porti els dos extrems separats del claudàtor pla, apuntant a la dreta i a l’esquerra. Feu-lo sols amb indicadors de barra emparellats [ ] (exemple 4).

Observeu que \set stemLeftBeamCount sempre equival a \once \set. En altres paraules, els ajustaments de la quantitat de barres no es recorden, i per això el parell de claudàtors plans aplicats a la nota Do semicorxera c'16[] de l’últim exemple no té res a veure amb el \set de dues notes per darrera.

\score {
  <<
    % Example 1
    \new RhythmicStaff {
      \set stemLeftBeamCount = 0
      c16[]
      r8.
    }
    % Example 2
    \new RhythmicStaff {
      r8.
      \set stemRightBeamCount = 0
      16[]
    }
    % Example 3
    \new RhythmicStaff {
      16 16
      \set stemRightBeamCount = 2
      16 r r
      \set stemLeftBeamCount = 2
      16 16 16
    }
    % Example 4
    \new RhythmicStaff {
      16 16
      \set stemRightBeamCount = 2
      16 r16
      16[]
      r16
      \set stemLeftBeamCount = 2
      16 16
    }
  >>
}

[image of music]


Forçar que les marques d’assaig comencin en una lletra o nombre donats

Aquest fragment de codi mostra com obtenir marques d’assaig ordenades automàticament, però partint de la lletra o nombre desitjat.

\relative c'' {
  c1 \mark \default
  c1 \mark \default
  c1 \mark \default
  c1 \mark #14
  c1 \mark \default
  c1 \mark \default
  c1 \mark \default
  c1
}

[image of music]


Generar claudàtors personalitzats

La propietat stencil del grob Flag (l’objecte gràfic claudàtor) es pot fixar a un funció de l’Scheme personalitzat que genera el glif del claudàtor.

#(define-public (weight-flag grob)
   (let* ((stem-grob (ly:grob-parent grob X))
          (log (- (ly:grob-property stem-grob 'duration-log) 2))
          (is-up? (eqv? (ly:grob-property stem-grob 'direction) UP))
          (yext (if is-up? (cons (* log -0.8) 0) (cons 0 (* log 0.8))))
          (flag-stencil (make-filled-box-stencil '(-0.4 . 0.4) yext))
          (stroke-style (ly:grob-property grob 'stroke-style))
          (stroke-stencil (if (equal? stroke-style "grace")
                              (make-line-stencil 0.2 -0.9 -0.4 0.9 -0.4)
                              empty-stencil)))
     (ly:stencil-add flag-stencil stroke-stencil)))


% Create a flag stencil by looking up the glyph from the font
#(define (inverted-flag grob)
   (let* ((stem-grob (ly:grob-parent grob X))
          (dir (if (eqv? (ly:grob-property stem-grob 'direction) UP) "d" "u"))
          (flag (retrieve-glyph-flag "" dir "" grob))
          (line-thickness (ly:staff-symbol-line-thickness grob))
          (stem-thickness (ly:grob-property stem-grob 'thickness))
          (stem-width (* line-thickness stem-thickness))
          (stroke-style (ly:grob-property grob 'stroke-style))
          (stencil (if (null? stroke-style)
                       flag
                       (add-stroke-glyph flag stem-grob dir stroke-style "")))
          (rotated-flag (ly:stencil-rotate-absolute stencil 180 0 0)))
     (ly:stencil-translate rotated-flag (cons (- (/ stem-width 2)) 0))))

snippetexamplenotes =
{
  \autoBeamOff c'8 d'16 c'32 d'64 \acciaccatura {c'8} d'64
}

{
  \time 1/4
  \textMark "Normal flags"
  \snippetexamplenotes

  \textMark "Custom flag: inverted"
  \override Flag.stencil = #inverted-flag
  \snippetexamplenotes

  \textMark "Custom flag: weight"
  \override Flag.stencil = #weight-flag
  \snippetexamplenotes

  \textMark "Revert to normal"
  \revert Flag.stencil
  \snippetexamplenotes
}

[image of music]


Ritmes rasguejats de guitarra

Per a la música de guitarra, és possible mostrar els ritmes de rasgueig, a més de les notes de la melodia, acords i diagrames de posicions.

\include "predefined-guitar-fretboards.ly"
<<
  \new ChordNames {
    \chordmode {
      c1 | f | g | c
    }
  }
  \new FretBoards {
    \chordmode {
      c1 | f | g | c
    }
  }
  \new Voice \with {
    \consists "Pitch_squash_engraver"
  } {
    \relative c'' {
      \improvisationOn
      c4 c8 c c4 c8 c
      f4 f8 f f4 f8 f
      g4 g8 g g4 g8 g
      c4 c8 c c4 c8 c
    }
  }
  \new Voice = "melody" {
    \relative c'' {
      c2 e4 e4
      f2. r4
      g2. a4
      e4 c2.
    }
  }
  \new Lyrics {
    \lyricsto "melody" {
      This is my song.
      I like to sing.
    }
  }
>>

[image of music]


Indicacions polimètricques de compàs totalment personalitzades

Tot i que l’element més essencial no és la indicació polimètrica de compàs que es mostra, s’ha inclòs per mostrar la pulsació de la peça, que és la plantilla d’una cançó real dels Balcans.

melody = \relative c'' {
  \key g \major
  \compoundMeter #'((3 8) (2 8) (2 8) (3 8) (2 8) (2 8)
                    (2 8) (2 8) (3 8) (2 8) (2 8))
  c8 c c d4 c8 c b c b a4 g fis8 e d c b' c d e4-^ fis8 g \break
  c,4. d4 c4 d4. c4 d c2 d4. e4-^ d4
  c4. d4 c4 d4. c4 d c2 d4. e4-^ d4 \break
  c4. d4 c4 d4. c4 d c2 d4. e4-^ d4
  c4. d4 c4 d4. c4 d c2 d4. e4-^ d4 \break
}

drum = \new DrumStaff \drummode {
  \repeat volta 2 {
    bd4.^\markup { Drums } sn4 bd \bar ";"
    sn4. bd4 sn \bar ";"
    bd sn bd4. sn4 bd
  }
}

\new Staff \with {
  instrumentName = \markup { \concat { "B" \flat " Sop." } }
}

{
  \melody
  \drum
}

\paper { tagline = ##f }

[image of music]


High and Low woodblock example

Two Woodblocks, entered with ’wbh’ (high woodblock) and ’wbl’ (low woodblock). The length of the barline has been altered with an \override command otherwise it would be too short. The positions of the two stafflines also have to be explicitly defined.

\paper { tagline = ##f }

% These lines define the position of the woodblocks in the stave;
% if you like, you can change it or you can use special note heads
% for the woodblocks.
#(define mydrums '((hiwoodblock default #f  3)
                   (lowoodblock default #f -2)))

woodstaff = {
  % This defines a staff with only two lines.
  % It also defines the positions of the two lines.
  \override Staff.StaffSymbol.line-positions = #'(-2 3)

  % This is necessary; if not entered,
  % the barline would be too short!
  \override Staff.BarLine.bar-extent = #'(-1.0 . 1.5)
  % small correction for the clef:
  \set DrumStaff.clefPosition = 0.5
}

\new DrumStaff {
  % with this you load your new drum style table
  \set DrumStaff.drumStyleTable = #(alist->hash-table mydrums)

  \woodstaff

  \drummode {
    \time 2/4
    wbl8 16 16 8-> 8 |
    wbl8 16 16-> ~ 16 16 r8 |
  }
}

[image of music]


Fer invisible un objecte amb la propietat ’transparent

Si s’ajusta la propietat transparent d’un objecte, s’imprimeix en “tinta invisible”: l’objecte no s’imprimeix però es retenen tots els seus altres comportaments. L’objecte encara ocupa espai, participa en les col·lisions i se li poden afegir lligadures d’expressió, lligadures d’unió i barres de corxera.

Aquest fragment de codi mostra com connectar diferents veus usant lligadures d’únió. Normalment les lligadures d’unió sols connecten dues notes que estiguin a la mateixa veu. Mitjançant la introducció d’una lligadura en una veu diferent i pintant de color blanc la primera plica cap a amunt dins d’aquesta veu, la lligadura sembla creuar d’una veu a l’altra.

\relative {
  \time 2/4
  <<
    {
      \once \hide Stem
      \once \override Stem.length = #8
      b'8 ~ 8\noBeam
      \once \hide Stem
      \once \override Stem.length = #8
      g8 ~ 8\noBeam
    }
    \\
    {
      b8 g g e
    }
  >>
}

[image of music]


Fer lligadures d’expressió amb estructura complexa de discontinuïtat

Les lligadures d’expressió es poden construir amb patrons de discontinuïtat complexos mitjançant la definició de la propietat dash-definition. dash-definition és una llista de paràmetres que defineixen el comportament de discontinuïtat d’un segment de la lligadura d’expressió.

La lligadura es defineix en termes del paràmetre de bezier t el rang del qual va de 0 a l’esquerra de la lligadura fins a 1 a l’extrem dret de la lligadura. cada element de discontinuïtat és una llista (t-inici t-final fracció-discontinuïtat període-discontinuitat). La regió de la lligadura des de t-inici fins a t-final tindrà una fracció fracció-discontinuitat de cada període-discontinuïtat de color negre. període-discontinuïtat es defineix en termes d’espais de pentagrama. fracció-discontinuïtat s’estableix al valor d’1 per a una lligadura contïnua.

\relative c' {
  \once \override
    Slur.dash-definition = #'((0 0.3 0.1 0.75)
                                (0.3 0.6 1 1)
                                (0.65 1.0 0.4 0.75))
  c4( d e f)
  \once \override
    Slur.dash-definition = #'((0 0.25 1 1)
                                (0.3 0.7 0.4 0.75)
                                (0.75 1.0 1 1))
  c4( d e f)
}

[image of music]


Control manual de les posicions de les barres

Es poden controlar manualment les posicions de les barres de corxera sobreescrivint el valor del paràmetre positions de l’objecte gràfic Beam.

\relative c' {
  \time 2/4
  % from upper staff-line (position 2) to center (position 0)
  \override Beam.positions = #'(2 . 0)
  c8 c
  % from center to one above center (position 1)
  \override Beam.positions = #'(0 . 1)
  c8 c
}

[image of music]


Combinació dels silencis multicompàs a una part polifònica

Quan s’usen silencis multicompàs en un pentagrama polifònic, els silencis s’ubiquen de forma diferent depenent de a quina veu pertanyin. Malgrat això, es poden imprimir sobre la mateixa línia del pentagrama, usant l’ajustament que apareix a continuació.

normalPos = \revert MultiMeasureRest.direction

{
  <<
    {
      c''1
      R1
      c''1
      \normalPos
      R1
    }
    \\
    {
      c'1
      R1
      c'1
      \normalPos
      R1
    }
  >>
}

[image of music]


Modificació de la longitud del corxet de grup especial

Tuplet brackets can be made to run to prefatory matter or the next note. Default tuplet brackets end at the right edge of the final note of the tuplet; full-length tuplet brackets extend farther to the right, either to cover all the non-rhythmic notation up to the following note, or to cover only the whitespace before the next item of notation, be that a clef, time signature, key signature, or another note. The example shows how to switch tuplets to full length mode and how to modify what material they cover.

\new RhythmicStaff {
  % Set tuplets to be extendable...
  \set tupletFullLength = ##t
  % ...to cover all items up to the next note
  \set tupletFullLengthNote = ##t
  \time 2/4
  \tuplet 3/2 { c4 4 4 }
  % ...or to cover just whitespace
  \set tupletFullLengthNote = ##f
  \time 4/4
  \tuplet 5/4 { 4 1 }
  \time 3/4
  2.
}

[image of music]


Desplaçament de les notes amb puntet en polifonia

Quan una nota amb puntet a la veu superior es mou per evitar la col·lisió amb una nota de una altra veu, el comportament predeterminat és desplaçar la nota superior a la dreta. Es pot canviar usant la propietat prefer-dotted-right de NoteCollision.

\new Staff \relative c' <<
  {
    f2. f4
    \override Staff.NoteCollision.prefer-dotted-right = ##f
    f2. f4
    \override Staff.NoteCollision.prefer-dotted-right = ##t
    f2. f4
  }
  \\
  { e4 e e e e e e e e e e e }
>>

[image of music]


Multi-measure rest length control

Multi-measure rests have length according to their total duration which is under the control of MultiMeasureRest.space-increment. Note that the default value is 2.0.

\relative c' {
  \compressEmptyMeasures
  R1*2 R1*4 R1*64 R1*16
  \override Staff.MultiMeasureRest.space-increment = 2.5
  R1*2 R1*4 R1*64 R1*16
}

\paper { tagline = ##f }

[image of music]


Marcatge de silencis multicompàs

Els elements de marcatge aplicats a un silenci multicompàs se centren a sobre o a sota del silenci. Els elements de marcatge extensos que s’adjunten a silencis multicompàs no produeixen l’expansió del comàs. Per expandir un silenci multicompàs de forma que càpiga tot el marcatge, utilitzeu un acord buit amb un marcatge aplicat abans del silenci multicompàs.

El text aplicat a un silenci separador d’aquesta forma s’alinea per l’esquerra a la posició en la qual la nota estaria situada dins del compàs, però si la longitud del compàs està determinada per la longitud del text, el text apareixerà centrat.

\relative c' {
  \compressMMRests {
    \textLengthOn
    <>^\markup { [MAJOR GENERAL] }
    R1*19
    <>_\markup { \italic { Cue: ... it is yours } }
    <>^\markup { A }
    R1*30^\markup { [MABEL] }
    \textLengthOff
    c4^\markup { CHORUS } d f c
  }
}

[image of music]


Nombres d’agrupació especial diferents o els predeterminats

El LilyPond també proporciona funcions de format per imprimir números de grup especial diferents a la pròpia fracció, així com per afegir una figura al número o a la fracció de l’agrupació.

\relative c'' {
  \once \override TupletNumber.text =
    #(tuplet-number::non-default-tuplet-denominator-text 7)
  \tuplet 3/2  { c4. c4. c4. c4. }
  \once \override TupletNumber.text =
    #(tuplet-number::non-default-tuplet-fraction-text 12 7)
  \tuplet 3/2  { c4. c4. c4. c4. }
  \once \override TupletNumber.text =
    #(tuplet-number::append-note-wrapper
      (tuplet-number::non-default-tuplet-fraction-text 12 7)
      (ly:make-duration 3 0))
  \tuplet 3/2  { c4. c4. c4. c4. }
  \once \override TupletNumber.text =
    #(tuplet-number::append-note-wrapper
      tuplet-number::calc-denominator-text
      (ly:make-duration 2 0))
  \tuplet 3/2  { c8 c8 c8 c8 c8 c8 }
  \once \override TupletNumber.text =
    #(tuplet-number::append-note-wrapper
      tuplet-number::calc-fraction-text
      (ly:make-duration 2 0))
  \tuplet 3/2  { c8 c8 c8 c8 c8 c8 }
  \once \override TupletNumber.text =
    #(tuplet-number::fraction-with-notes
      (ly:make-duration 2 1) (ly:make-duration 3 0))
  \tuplet 3/2  { c4. c4. c4. c4. }
  \once \override TupletNumber.text =
    #(tuplet-number::non-default-fraction-with-notes 12
      (ly:make-duration 3 0) 4 (ly:make-duration 2 0))
  \tuplet 3/2  { c4. c4. c4. c4. }
}

[image of music]


Numbering single measure rests

Multi measure rests show their length by a number except for single measures. This can be changed by setting restNumberThreshold.

{
  \compressEmptyMeasures
  R1 R1*10 R1*11 \bar "||"
  \set restNumberThreshold = 0
  R1 R1*10 R1*11 \bar "||"
  \set restNumberThreshold = 10
  R1 R1*10 R1*11
}

[image of music]


Partcombine i autoBeamOff

Pot ser difícil entendre la funció de \autoBeamOff quan s’usa amb \partcombine.

Pot ser preferible usar

\set Staff.autoBeaming = ##f

en el seu lloc, per assegurar-se que el barrat automàtic es desactiva per a tot el pentagrama.

\partcombine funciona aparentement amb tres veus: plica amunt quan hi ha una sola veu, plica avall amb l’altra, i plica amunt quan està combinada.

Una crida a \autoBeamOff en el primer argument de partcombine s’aplica a la veu que està activa en el moment en el qual es processa la crida, ja sigui veu única amb la plica cap amunt, cap avall o combinades. Una crida a \autoBeamOff en el segon argument s’aplica a la veu que estigui sola amb la aplica avall.

Per poder usar \autoBeamOff amb l’objectiu de detenir tot el barrat automàtic quan s’usa amb \partcombine, cal fer tres crides a \autoBeamOff.

{
  %\set Staff.autoBeaming = ##f % turns off all autobeaming
  \partCombine
  {
    \autoBeamOff % applies to split up stems
    \repeat unfold 4 a'16
    %\autoBeamOff % applies to combined up stems
    \repeat unfold 4 a'8
    \repeat unfold 4 a'16
  }
  {
    \autoBeamOff % applies to down stems
    \repeat unfold 4 f'8
    \repeat unfold 8 f'16 |
  }
}

[image of music]


Percussion example

A short example taken from Stravinsky’s L’histoire du Soldat.

#(define mydrums '((bassdrum   default #f  4)
                   (snare      default #f -4)
                   (tambourine default #f  0)))

\paper { tagline = ##f }

global = {
  \time 3/8 s4.
  \time 2/4 s2*2
  \time 3/8 s4.
  \time 2/4 s2
}

drumsA = {
  \context DrumVoice <<
    { \global }
    { \drummode {
        \autoBeamOff
        \stemDown sn8 \stemUp tamb s8 |
        sn4 \stemDown sn4 |
        \stemUp tamb8 \stemDown sn8 \stemUp sn16 \stemDown sn \stemUp sn8 |
        \stemDown sn8 \stemUp tamb s8 |
        \stemUp sn4 s8 \stemUp tamb
      }
    }
  >>
}

drumsB = {
  \drummode {
    s4 bd8 s2*2 s4 bd8 s4 bd8 s8
  }
}

\layout {
  indent = 40
  \context {
    \DrumStaff
    drumStyleTable = #(alist->hash-table mydrums)
  }
}

\score {
  \new StaffGroup <<
    \new DrumStaff \with {
      instrumentName = \markup \center-column {
        "Tambourine"
        "et"
        "caisse claire s. timbre"
        }
  }
  \drumsA
  \new DrumStaff \with {
    instrumentName = "Grosse Caisse"
  }
  \drumsB
  >>
}

[image of music]


Permetre salts de línia dins de grups especials amb barra

Aquest exemple artificial mostra com es poden permetre tant els salts de línia manuals com els automàtics dins d’un grup de valoració especial unit per una barra. Observeu que aquests grups sincopats s’han de barrar manualment.

\paper { tagline = ##f }
\layout {
  \context {
    \Voice
    % Permit line breaks within tuplets
    \remove "Forbid_line_break_engraver"
    % Allow beams to be broken at line breaks
    \override Beam.breakable = ##t
  }
}
\relative c'' {
  a8
  \repeat unfold 5 { \tuplet 3/2 { c[ b a] } }
  % Insert a manual line break within a tuplet
  \tuplet 3/2 { c[ b \bar "" \break a] }
  \repeat unfold 5 { \tuplet 3/2 { c[ b a] } }
  c8
}

[image of music]


Col·locar les barres de les notes d’adorn a la mateixa alçada que les barres de notes normals

Quan es col·loquen figures sobre línies addicionals, les seves barres se situen generalment en mig del pentagrama. La barra de les notes d’adorn és més curta i les notes d’adorn sobre les línies addicionals podrien tenir la barra fora del pentagrama. Podem corregir aquest barrat per a les notes d’adorn.

\relative c {
  f8[ e]
  \grace {
    f8[ e]
    \override Stem.no-stem-extend = ##f
    f8[ e]
    \revert Stem.no-stem-extend
  }
  f8[ e]
}

[image of music]


Posicionament de les notes d’adorn amb espai flotant

En establir la propietat 'strict-grace-spacing fem que les columnes musicals per a les notes d’adorn siguin ‘flotants’, és a dir, desacoblades de les notes que no són d’adorn: primer s’aplica l’espaiat de les notes normals, i després es posen les columnes musicals de les notes d’adorn a l’esquerra de les columnes musicals de les notes principals.

\relative c'' {
  <<
    \override Score.SpacingSpanner.strict-grace-spacing = ##t
    \new Staff \new Voice {
      \afterGrace c4 { c16[ c8 c16] }
      c8[ \grace { b16 d } c8]
      c4 r
    }
    \new Staff {
      c16 c c c c c c c c4 r
    }
  >>
}

[image of music]


Posicionar els silencis multicompàs

A diferència dels silencis normals, no existeix una ordre predefinida per modificar la posició predeterminada d’un símbol de silenci multicompàs sobre el pentagrama, adjuntant-lo a una nota, independentment de quin sigui la seva forma. No obstant, en la música polifònica els silencis multicompàs de les veus de numeració parell i imparell estan separats verticalment. La col·locació dels silencis multicompàs es pot controlar com es ve a continuació:

\relative c'' {
  % Multi-measure rests by default are set under the fourth line
  R1
  % They can be moved using an override
  \override MultiMeasureRest.staff-position = -2
  R1
  \override MultiMeasureRest.staff-position = 0
  R1
  \override MultiMeasureRest.staff-position = 2
  R1
  \override MultiMeasureRest.staff-position = 3
  R1
  \override MultiMeasureRest.staff-position = 6
  R1
  \revert MultiMeasureRest.staff-position
  \break

  % In two Voices, odd-numbered voices are under the top line
  << { R1 } \\ { a1 } >>
  % Even-numbered voices are under the bottom line
  << { a1 } \\ { R1 } >>
  % Multi-measure rests in both voices remain separate
  << { R1 } \\ { R1 } >>

  % Separating multi-measure rests in more than two voices
  % requires an override
  << { R1 } \\ { R1 } \\
     \once \override MultiMeasureRest.staff-position = 0
     { R1 }
  >>

  % Using compressed bars in multiple voices requires another override
  % in all voices to avoid multiple instances being printed
  \compressMMRests
  <<
   \revert MultiMeasureRest.direction
    { R1*3 }
    \\
   \revert MultiMeasureRest.direction
    { R1*3 }
  >>
}

[image of music]


Positioning opposing fermatas on a bar line

This snippet demonstrates a command that prints fermatas both above and below a bar line. If there would not otherwise be a bar line, it adds a double bar line. Semantically, the command codes a longer-than-normal caesura, which might be considered misuse depending on the situation.

twoWayFermata = {
  \once \set Staff.caesuraType = #'((underlying-bar-line . "||"))
  \once \set Staff.caesuraTypeTransform = ##f
  \caesura ^\fermata _\fermata
}

music = {
  f'1 \twoWayFermata
  R1
  f'2 \twoWayFermata f'2
  R1
  b'1 \twoWayFermata \fine
}

\new GrandStaff <<
  \new Staff \music
  \new Staff \music
>>

[image of music]


Evitar que una marca de assaig final suprimeixi el corxet d’un grup de valoració especial

En afegir una marca d’assaig mark al final pot succeir que es perdi una indicació de grup especial col·locat al final. Es pot solucionar establint TupletBracket #'full-length-to-extent al valor false.

% due to issue 2362 a long mark such as
%   \textEndMark "Composed Feb 2007 - Feb 2008"
% cannot be used here.

\paper { tagline = ##f }

\new Staff {
   \set tupletFullLength = ##t
   \time 1/8
   \tuplet 3/2 8 { c'16 c' c' c' c' c' c' c' c' }
   \tweak direction #DOWN \textEndMark "1234"
}

\new Staff {
  \set tupletFullLength = ##t
  \override TupletBracket.full-length-to-extent = ##f

  \time 1/8
   \tuplet 3/2 8 { c'16 c' c' c' c' c' c' c' c' }
   \tweak direction #DOWN \textEndMark "1234"
}

[image of music]


Imprimir números de compàs a intervals regulars

Es poden imprimir els nombre de compàs a intervals regulars mitjançant l’establiment de la propietat barNumberVisibility. Aquí els números de compàs s’imprimeixen cada dos compassos excepte al final de la línia.

\relative c' {
  \override Score.BarNumber.break-visibility = #end-of-line-invisible
  \set Score.currentBarNumber = 11
  % Print a bar number every second measure
  \set Score.barNumberVisibility = #(every-nth-bar-number-visible 2)
  c1 | c | c | c | c
  \break
  c1 | c | c | c | c
}

\paper { tagline = ##f }

[image of music]


Printing bar numbers for broken measures

By default a BarNumber of a broken measure is not repeated at the beginning of the new line. Use first-bar-number-invisible-save-broken-bars for barNumberVisibility to get a parenthesized BarNumber there.

\layout {
  \context {
    \Score
    barNumberVisibility = #first-bar-number-invisible-save-broken-bars
    \override BarNumber.break-visibility = ##(#f #t #t)
  }
}

\relative c' {
  c1 | d | e | f2 \bar "" \break
  fis | g1 | e2 \bar "" \break
  <>^"reenabled default"
  % back to default -
  % \unset Score.barNumberVisibility would do so as well
  \set Score.barNumberVisibility =
    #first-bar-number-invisible-and-no-parenthesized-bar-numbers
  es | d1 | c
}

\paper { tagline = ##f }

[image of music]


Impressió de nombre de compàs dins de rectangles o circumferències

Els nombres de compàs també es poden imprimir dins de rectangles o de circumferències.

\relative c' {
  % Prevent bar numbers at the end of a line and permit them elsewhere
  \override Score.BarNumber.break-visibility = #end-of-line-invisible
  \set Score.barNumberVisibility = #(every-nth-bar-number-visible 4)

  % Increase the size of the bar number by 2
  \override Score.BarNumber.font-size = 2

  % Draw a box round the following bar number(s)
  \override Score.BarNumber.stencil
    = #(make-stencil-boxer 0.1 0.25 ly:text-interface::print)
  \repeat unfold 5 { c1 }

  % Draw a circle round the following bar number(s)
  \override Score.BarNumber.stencil
    = #(make-stencil-circler 0.1 0.25 ly:text-interface::print)
  \repeat unfold 4 { c1 } \bar "|."
}

[image of music]


Printing bar numbers using modulo-bar-number-visible

If the remainder of the division of the current BarNumber by the first argument of modulo-bar-number-visible equals its second argument print the BarNumber.

Useful to print the BarNumber at certain distances, p.e.:

\layout {
  \context {
    \Score
    \override BarNumber.break-visibility = ##(#f #t #t)
    barNumberVisibility = #(modulo-bar-number-visible 3 2)
  }
}

\relative c' {
  c1 | d | e | f \break
  g1 | e | d | c
}

\paper { tagline = ##f }

[image of music]


Printing bar numbers with changing regular intervals

Using the set-bar-number-visibility context function, bar number intervals can be changed.

\relative c' {
  \override Score.BarNumber.break-visibility = #end-of-line-invisible
  \context Score \applyContext #(set-bar-number-visibility 4)
  \repeat unfold 10 c'1
  \context Score \applyContext #(set-bar-number-visibility 2)
  \repeat unfold 10 c
}

\paper { tagline = ##f }

[image of music]


Impressió d’indicacions de metrònom i lletres d’assaig a sota del pentagrama

De forma predeterminada, les indicacions de metrònom i les lletres d’assaig s’imprimeixen a sobre del pentagrama. Per col·locar-les a sota del pentagrama, simplement ajustem adequadament la propietat direction de MetronomeMark o de RehearsalMark.

\layout {
  indent = 0
  ragged-right = ##f
}

{
  % Metronome marks below the staff
  \override Score.MetronomeMark.direction = #DOWN
  \tempo 8. = 120
  c''1

  % Rehearsal marks below the staff
  \override Score.RehearsalMark.direction = #DOWN
  \mark \default
  c''1
}

[image of music]


Impressió de música que tingui compassos en cada pentagrama

En el següent fragment de codi, dues parts diferents tenen un compàs completament diferent i malgrat això es mantenen sincronitzades. Les barres de compàs ja no es poden imprimir en el nivell de Score; per permetre barres de compàs independents en cada part es tralladen els gravadores Default_barline_engraver i Timing_translator des del context de partitura Score fins el context de pentagrama Staff.

Si calen nombres de compàs, el gravador de nombres de compàs Bar_number_engraver també s’ha de traslladar, ja que descansa en propietat fixades pel Timing_translator; es pot usar un bloc \with per afegir nombres de compàs al pentagrama apropiat.

\paper {
  indent = #0
  ragged-right = ##t
  tagline = ##f
}

global = { \time 3/4 { s2.*3 } \bar "" \break { s2.*3 } }

\layout {
  \context {
    \Score
    \remove "Timing_translator"
    \remove "Bar_number_engraver"
    \override SpacingSpanner.uniform-stretching = ##t
    \override SpacingSpanner.strict-note-spacing = ##t
    proportionalNotationDuration = \musicLength 64
  }
  \context {
    \Staff
    \consists "Timing_translator"
  }
  \context {
    \Voice
    \remove "Forbid_line_break_engraver"
    tupletFullLength = ##t
  }
}

Bassklarinette = \new Staff \with {
  \consists "Bar_number_engraver"
  barNumberVisibility = #(every-nth-bar-number-visible 2)
  \override BarNumber.break-visibility = #end-of-line-invisible
} <<
  \global {
    \bar "|"
    \clef treble
    \time 3/8
    d''4.

    \bar "|"
    \time 3/4
    r8 des''2( c''8)

    \bar "|"
    \time 7/8
    r4. ees''2 ~

    \bar "|"
    \time 2/4
    \tupletUp
    \tuplet 3/2 { ees''4 r4 d''4 ~ }

    \bar "|"
    \time 3/8
    \tupletUp
    \tuplet 4/3 { d''4 r4 }

    \bar "|"
    \time 2/4
    e''2

    \bar "|"
    \time 3/8
    es''4.

    \bar "|"
    \time 3/4
    r8 d''2 r8
    \bar "|"
  }
>>

Perkussion = \new StaffGroup <<
  \new Staff <<
    \global {
      \bar "|"
      \clef percussion
      \time 3/4
      r4 c'2 ~

      \bar "|"
      c'2.

      \bar "|"
      R2.

      \bar "|"
      r2 g'4 ~

      \bar "|"
      g'2. ~

      \bar "|"
      g'2.
    }
  >>
  \new Staff <<
    \global {
      \bar "|"
      \clef percussion
      \time 3/4
      R2.

      \bar "|"
      g'2. ~

      \bar "|"
      g'2.

      \bar "|"
      r4 g'2 ~

      \bar "|"
      g'2 r4

      \bar "|"
      g'2.
    }
  >>
>>

\score {
  <<
    \Bassklarinette
    \Perkussion
  >>
}

[image of music]


Impressió del nombre de compàs al primer compàs

De forma predeterminada se suprimeix el nombre de compàs del primer compàs d’una partitura si és més petit o igual a ‘1’. En establir el valor de barNumberVisibility a all-bar-numbers-visible, es pot imprimir qualsevol nombre de compàs per al primer compàs i tots els següents. Observeu que, perquè això funcioni, s’ha d’inserir una línia divisòria buida abans de la primera nota.

\layout {
  indent = 0
  ragged-right = ##t
}

\relative c' {
  \set Score.barNumberVisibility = #all-bar-numbers-visible
  c1 | d | e | f \break
  g1 | e | d | c
}

[image of music]


Printing tuplet brackets on the note head side

Whichever option you choose for controlling the tuplet bracket visibility, it will show or hide the tuplet bracket irrespectively of tuplet bracket placement (stem side or note head side). However, when placing the tuplet bracket on the note head side some authors recommend always printing the tuplet bracket. The option visible-over-note-heads can be used to achieve this.

music = \relative c'' {
  \tupletNeutral \tuplet 3/2 { c16[ d e } f8]
  \tupletUp \tuplet 3/2 { c8 d e }
}

\new Voice {
  \relative c' {
    \time 2/4
    \override TupletBracket.visible-over-note-heads = ##t
    \override Score.TextMark.non-musical = ##f
    { \textMark \markup "default" \music }
    \override TupletBracket.bracket-visibility = #'if-no-beam
    { \textMark \markup \typewriter "'if-no-beam" \music }
  }
}

[image of music]


Redefinició dels valors globals predeterminats per a notes d’adorn

Els valors predeterminats per a les notes d’adorn estan emmagatzemats en els identificadors startGraceMusic, stopGraceMusic, startAcciaccaturaMusic, stopAcciaccaturaMusic, startAppoggiaturaMusic i stopAppoggiaturaMusic, que estan definits al fitxer ly/grace-init.ly. Redefinint-los es poden obtenir altres efectes.

startAcciaccaturaMusic = {
  <>(
  \override Flag.stroke-style = "grace"
  \slurDashed
}

stopAcciaccaturaMusic = {
  \revert Flag.stroke-style
  \slurSolid
  <>)
}

\relative c'' {
  \acciaccatura d8 c1
}

[image of music]


Supressió dels nombres de compàs de tota la partitura

Es poden eliminar completament els nombres de compàs traient el gravador Bar_number_engraver del context de Score.

\layout {
  \context {
    \Score
    \omit BarNumber
    % or:
    %\remove "Bar_number_engraver"
  }
}

\relative c'' {
  c4 c c c \break
  c4 c c c
}

\paper { tagline = ##f }

[image of music]


Treure les barres de compàs entre els pentagrames d’un StaffGroup PianoStaff o GrandStaff

De forma predeterminada, les línies divisòries als grups StaffGroup, PianoStaff o GrandStaff es connecten entre els pentagrames. Es pot alterar aquest comportament pentagrama a pentagrama.

\relative c' {
  \new StaffGroup <<
    \new Staff {
      e1 | e
      \once \override Staff.BarLine.allow-span-bar = ##f
      e1 | e | e
    }
    \new Staff {
      c1 | c | c
      \once \override Staff.BarLine.allow-span-bar = ##f
      c1 | c
    }
    \new Staff {
      a1 | a | a | a | a
    }
  >>
}

[image of music]


Estils de silencis

Els silencis es poden imprimir en diferents estils.

restsA = {
  r\maxima r\longa r\breve r1 r2 r4 r8 r16 s32
  s64 s128 s256 s512 s1024 s1024
}
restsB = {
  r\maxima r\longa r\breve r1 r2 r4 r8 r16 r32
  r64 r128 r256 r512 r1024 s1024
}

\new Staff \relative c {
  \omit Score.TimeSignature
  \cadenzaOn

  \override Staff.Rest.style = #'mensural
  <>^\markup \typewriter { mensural } \restsA \bar "" \break

  \override Staff.Rest.style = #'neomensural
  <>^\markup \typewriter { neomensural } \restsA \bar "" \break

  \override Staff.Rest.style = #'classical
  <>^\markup \typewriter { classical } \restsB \bar "" \break

  \override Staff.Rest.style = #'z
  <>^\markup \typewriter { z-style } \restsB \bar "" \break

  \override Staff.Rest.style = #'default
  <>^\markup \typewriter { default } \restsB \bar "" \break
}

\paper {
  indent = 0
  tagline = ##f
}

[image of music]


Alteració dels finals de barra predeterminats

Per gravar les barres agrupades en la forma 3-4-3-2 sóls cal modificar l’estructura de polsos.

\relative c'' {
  \time 12/8

  % Default beaming
  a8 a a a a a a a a a a a

  % Set new values for beam endings
  \set Score.beatStructure = 3,4,3,2
  a8 a a a a a a a a a a a
}

[image of music]


Barres rítmiques

Als fulls guia d’acords o fulls guia “senzilles”, a vegades no s’imprimeix realment cap nota, i en el seu lloc es fa una notació que té sols “patrons rítmics” i acords a sobre dels compassos, donant l’estructura de la cançó. Aquesta funcionalitat és útil, per exemple, en crear o transcriure l’estructura d’una cançó i també si es volen compartir els fulls guia amb guitarristes o músics de jazz. La forma estàndard en la qual hi ha suport per a aquesta modalitat usant \repeat percent no és adequada aquí perquè el primer compàs hauria de ser una nota o silenci normals. Aquest exemple mostra dues solucions al problema, redefinint els silencis normals perquè s’imprimeixin com a barres inclinades (si la duració de cada pols no és una negra, substituirem el r4 que apareix a les definicions amb un silenci de la duració adequada).

startPat = {
  \improvisationOn
  \omit Stem
}
stopPat = {
  \improvisationOff
  \undo \omit Stem
}

\new Voice \with {
  \consists Pitch_squash_engraver
} {
  c'4 d' e' f' |
  \startPat
  4 4 4 4 |
  \stopPat
  f'4 e' d' c'
}

[image of music]


Silencis de separació en mode de lletra

La sintaxi s per als silencis de desplaçament sols està disponible als modes de nota i d’acord. En altres situacions, per exemple en escriure la lletra de les cançons, es recomana usar l’ordre \skip.

<<
  \relative c'' { a1 | a }
  \new Lyrics \lyricmode { \skip 1 bla1 }
>>

[image of music]


Silencis de separació en mode de lletra (2)

Tot i que no es poden usar els silencis de separació s dins de \lyricmode (s’agafen com una “s”, literal, no com un espai), sí hi ha disponibles les comtes dobles ("") i la barra baixa (_). Així com per exemple:

<<
  \relative c'' { a4 b c d }
  \new Lyrics \lyricmode { a4 "" _ gap }
>>

[image of music]


Stemlets (pliques de mida reduïda)

En certes convencions de notació es permet que les barres s’estenguin per sobre dels silencis. Depenent de les nostre preferències, aquestes barres poden presentar petites pliques perquè l’ull apreciï més fàcilment el ritme, i en alguns casos de música moderna el propi silenci s’omet i romanen sols les petites pliques sense cap.

Aquest fragment de codi mostra un progressió a partir de la notació tradicional, passant per barres sobre silencis i pliques sobre els silencis, fins les pliques sols. Les petites pliques o Stemlets es generen sobreescrivint la propietat 'stemlet-length de l’objecte Stem, mentre que els silencis queden ocults establint 'transparent = ##t.

Alguns elements de \markup s’inclouen en la font per imprimir títols sobre cada estil de notació.

\paper { ragged-right = ##f }

{
  c'16^\markup { traditional } d' r f'
  g'16[^\markup { beams over rests } f' r d']

  % N.B. use Score.Stem to set for the whole score.
  \override Staff.Stem.stemlet-length = #0.75

  c'16[^\markup { stemlets over rests } d' r f']
  g'16[^\markup { stemlets and no rests } f'
  \once \hide Rest
  r16 d']
}

[image of music]


Barres que respecten el pols estrictament

Es poden fer que les barres secundàries apuntin en la direcció del pols o fracció a que pertanyen. La primera barra evita els corxets aïllats (que és el comportament predeterminat); la segona barra segueix el pols o fracció estrictament.

\relative c'' {
  \time 6/8
  a8. a16 a a
  \set strictBeatBeaming = ##t
  a8. a16 a a
}

[image of music]


Subdivisió de barres

Les barres de semicorxera, o de figures més breus, no es subdivideixen de forma predeterminada. És a dir, les tres (o més) barres s’amplien sense trencar-se sobre grups complets de notes. Aquest comportament es pot modificar per subdividir les barres en subgrups mitjançant l’establiment de la propietat subdivideBeams. Quan està activada, les barres es subdivideixen a intervals definits pel valor actual de baseMoment mitjançant la reducció de les barres repetides a una sola entre els subgrups. Observeu que el valor predeterminat de baseMoment és un més que el denominador del tipus de compàs actual, si no es fixa explícitament. S’ha d’ajustar a una fracció que dóna la duració del subgrup de barres utilitzant la funció ly:make-moment, como es veu en aquest fragment de codi. Així mateix, quan es modifica baseMoment, s’hauria de canviar també beatStructure perquè correspongui al baseMoment nou:

\relative c'' {
  c32[ c c c c c c c]

  \set subdivideBeams = ##t
  c32[ c c c c c c c]

  % Set minimum beam subdivision interval to 1/8 just for this beam
  \once \set minimumBeamSubdivisionInterval = \musicLength 8
  c32[ c c c c c c c]

  % Set maximum beam subdivision interval to 1/16 just for this beam
  \once \set maximumBeamSubdivisionInterval = \musicLength 16
  c32[ c c c c c c c]

  % Set maximum beam subdivision interval to 3/8 just for this beam
  \once \set maximumBeamSubdivisionInterval = \musicLength 8*3
  c64[ c c c c c c c c c c c c c c c]

  r2.

  % Shorten beam by 1/32
  c32[ c c c c c c] r32

  % Shorten beam by 3/32
  c32[ c c c c] r16.

  % Respect the incomplete beams of the previous two examples
  \set respectIncompleteBeams = ##t
  c32[ c c c c c c] r32
  % no visual change here as last two stems are exempt from this
  % special rule
  c32[ c c c c] r16.
}

[image of music]


Tam-tam example

A tam-tam example, entered with ’tt’

#(define mydrums '((tamtam default #f 0)))

\new DrumStaff \with { instrumentName = #"Tamtam" }

\drummode {
  \set DrumStaff.drumStyleTable = #(alist->hash-table mydrums)
  \override Staff.StaffSymbol.line-positions = #'( 0 )
  \override Staff.BarLine.bar-extent = #'(-1.5 . 1.5)

  tt 1 \pp \laissezVibrer
}

\paper { tagline = ##f }

[image of music]


Tambourine example

A tambourine example, entered ’tamb’

\paper { tagline = ##f }

#(define mydrums '((tambourine default #f 0)))

\new DrumStaff \with { instrumentName = #"Tambourine" }

\drummode {
  \set DrumStaff.drumStyleTable = #(alist->hash-table mydrums)
  \override Staff.StaffSymbol.line-positions = #'( 0 )
  \override Staff.BarLine.bar-extent = #'(-1.5 . 1.5)

  \time 6/8
  tamb8. 16 8 8 8 8 |
  tamb4. 8 8 8 |
  % the trick with the scaled duration and the shorter rest
  % is neccessary for the correct ending of the trill-span!
  tamb2.*5/6 \startTrillSpan s8 \stopTrillSpan |
}

[image of music]


Rectangle de tres segments visibles

Aquest exemple mostra com afegir una ordre de marcatge per obtenir un rectangle de tres segments visibles rodejant un element de text (o un altre element de marcatge).

% New command to add a three sided box, with sides north, west and south
% Based on the box-stencil command defined in scm/stencil.scm
% Note that ";;" is used to comment a line in Scheme
#(define-public (NWS-box-stencil stencil thickness padding)
   "Add a box around STENCIL, producing a new stencil."
   (let* ((x-ext (interval-widen (ly:stencil-extent stencil X) padding))
          (y-ext (interval-widen (ly:stencil-extent stencil Y) padding))
          (y-rule (make-filled-box-stencil (cons 0 thickness) y-ext))
          (x-rule (make-filled-box-stencil
                   (interval-widen x-ext thickness) (cons 0 thickness))))
     ;; (set! stencil (ly:stencil-combine-at-edge stencil X 1 y-rule padding))
     (set! stencil (ly:stencil-combine-at-edge stencil X LEFT y-rule padding))
     (set! stencil (ly:stencil-combine-at-edge stencil Y UP x-rule 0.0))
     (set! stencil (ly:stencil-combine-at-edge stencil Y DOWN x-rule 0.0))
     stencil))

% The corresponding markup command, based on the \box command defined
% in scm/define-markup-commands.scm
#(define-markup-command (NWS-box layout props arg) (markup?)
   #:properties ((thickness 0.1) (font-size 0) (box-padding 0.2))
   "Draw a box round @var{arg}.  Looks at @code{thickness},
@code{box-padding} and @code{font-size} properties to determine line
thickness and padding around the markup."
   (let ((pad (* (magstep font-size) box-padding))
         (m (interpret-markup layout props arg)))
     (NWS-box-stencil m thickness pad)))

% Test it:

\relative c' {
  c1^\markup { \NWS-box ABCD }
  c1^\markup { \NWS-box \note {4} #1.0 }
}

[image of music]


Time signature in brackets

The time signature can be enclosed within brackets.

\relative c'' {
  \override Staff.TimeSignature.stencil = #(lambda (grob)
    (bracketify-stencil (ly:time-signature::print grob) Y 0.1 0.2 0.1))
  \time 2/4
  a4 b8 c
}

[image of music]


Compàs entre parèntesis

La indicació de compàs pot envoltar-se entre parèntesi.

\relative c'' {
  \override Staff.TimeSignature.stencil = #(lambda (grob)
    (parenthesize-stencil (ly:time-signature::print grob) 0.1 0.4 0.4 0.1))
  \time 2/4
  a4 b8 c
}

[image of music]


Indicació de compàs imprimint sols el numerador (en lloc de la fracció)

A vegades, la indicació de compàs no ha d’imprimir la fracció completa (per exemple 7/4), sinó sols el numerador (7 en aquest cas). Això es pot fer fàcilment utilitzant \override Staff.TimeSignature.style = #'single-number per canviar l’estil permanentment. Usant \revert Staff.TimeSignature.style, es pot revertir el canvi. Per aplicar l’estil d’un dígit únic a una sola indicació de compàs, utilitzeu l’ordre \override i anteposeu l’ordre \once.

\relative c'' {
  \time 3/4
  c4 c c
  % Change the style permanently
  \override Staff.TimeSignature.style = #'single-number
  \time 2/4
  c4 c
  \time 3/4
  c4 c c
  % Revert to default style:
  \revert Staff.TimeSignature.style
  \time 2/4
  c4 c
  % single-number style only for the next time signature
  \once \override Staff.TimeSignature.style = #'single-number
  \time 5/4
  c4 c c c c
  \time 2/4
  c4 c
}

[image of music]


Ajustament de la disposició de les notes d’adorn dins de la música

La disposició de les expressions d’adorn es pot canviar al llarg de tota la música usant les funcions add-grace-property i remove-grace-property. L’exemple següent esborra la definició de la direcció de la plica per a aquest nota d’adorn, de manera que les pliques no sempre apunten cap a dalt, i canvia la forma predeterminada dels caps a aspes.

\relative c'' {
  \new Staff {
    $(remove-grace-property 'Voice 'Stem 'direction)
    $(add-grace-property 'Voice 'NoteHead 'style 'cross)
    \new Voice {
       \acciaccatura { f16 } g4
       \grace { d16 e } f4
       \appoggiatura { f,32 g a } e2
    }
  }
}

[image of music]


User defined time signatures

New time signature styles can be defined. The time signature in the second measure should be upside down in both staves.

#(add-simple-time-signature-style 'topsy-turvy
   (lambda (fraction)
     (make-rotate-markup 180 (make-compound-meter-markup fraction))))

<<
  \new Staff {
    \time 3/4 f'2.
    \override Score.TimeSignature.style = #'topsy-turvy
    \time 3/4 R2. \bar "|."
  }
  \new Staff {
    R2. e''
  }
>>

[image of music]


Ús d’estils alternatius per als corxets

Es poden imprimir estils alternatius del corxet o ganxo de les corxeres i figures menors, mitjançant la sobreescriptura de la propietat stencil de l’objecte Flag. Són valors vàlids modern-straight-flag, old-straight-flag i flat-flag.

testnotes = {
  \autoBeamOff
  c8 d16 c32 d64 \acciaccatura { c8 } d64 r4
}

\score {
  \relative c' {
    \time 2/4
    \testnotes

    \override Flag.stencil = #modern-straight-flag
    \testnotes

    \override Flag.stencil = #old-straight-flag
    \testnotes

    \override Flag.stencil = #flat-flag
    \testnotes

    \revert Flag.stencil
    \testnotes
  }
  \layout {
    indent = 0
    \context {
      \Score
      \override NonMusicalPaperColumn.line-break-permission = ##f
    }
  }
}

[image of music]


Utilitzar la barra que tatxa les notes amb notes normals

És possible aplicar la barreta que creua la barra de les acciacatures, en altres situacions.

\relative c'' {
  \override Flag.stroke-style = "grace"
  c8( d2) e8( f4)
}

[image of music]


Ús de les lligadures als arpegis

Algunes vegades s’usen lligadures d’unió per escriure els arpegis. En aquest cas, les dues notes lligades no han de ser consecutives. Això es pot aconseguir establint la propietat tieWaitForNote al valor #t. La mateixa funcionalitat és d’utilitat, per exemple, per lligar un tremol a un acord, però en principi també es pot usar per a notes normals consecutives. l

\relative c' {
  \set tieWaitForNote = ##t
  \grace { c16[ ~ e ~ g] ~ } <c, e g>2
  \repeat tremolo 8 { c32 ~ c' ~ } <c c,>1
  e8 ~ c ~ a ~ f ~ <e' c a f>2
  \tieUp
  c8 ~ a
  \tieDown
  \tieDotted
  g8 ~ c g2
}

[image of music]


Expressive marks

Expressive marks


Afegir barres, lligadures d’expressió i d’unió, etc., quan s’usen ritmes amb i sense grups de valoració especial.

La sintaxi del LilyPond pot implicar moltes col·locacions poc comunes per als parèntesis, claus, etc., que a vegades s’han d’intercalar. Per exemple, en introduir una barra manual, la clau esquerra d’apertura s’ha d’escriure després de la nota inicial i de la seva duració, no abans. De forma semblant, la clau dreta de tancament ha de seguir immediatament a la nota que es vol ubicar al final del barrat, fins i tot si aquesta nota resulta estar dins d’un grup de valoració especial. Aquest fragment de codi mostra com combinar el barrat manual, les lligadures d’expressió i d’unió i les lligadures de fraseig, amb seccions de valoració especial (tancades entre claus).

{
  r16[ g16 \tuplet 3/2 { r16 e'8] }
  g16( a \tuplet 3/2 { b d e') }
  g8[( a \tuplet 3/2 { b d') e'] ~ }
  \time 2/4
  \tuplet 5/4 { e'32\( a b d' e' } a'4.\)
}

[image of music]


Envoltar entre parèntesis una marca expressiva o una nota d’un acord

La funció \parenthesize és un ajustament especial que envolta objectes entre parèntesis. EL grob associat és ParenthesesItem.

\relative c' {
  c2-\parenthesize ->
  \override Parentheses.padding = #0.1
  \override Parentheses.font-size = #-4
  <d \parenthesize f a>2
}

[image of music]


Afegir marques de temps a glissandos llargs

Els temps que se salten a glissandos molt llargs s’indiquen a vegades mitjançant marques de temps, que sovint consisteixen en figures sense cap. Aquestes pliques es poden usar també per allotjar indicacions expressives intermèdies.

Si les pliques no queden ben alineades amb el glissando, podria caldre recol·locar-les lleugerament.

glissandoSkipOn = {
  \override NoteColumn.glissando-skip = ##t
  \hide NoteHead
  \override NoteHead.no-ledgers = ##t
}

glissandoSkipOff = {
  \revert NoteColumn.glissando-skip
  \undo \hide NoteHead
  \revert NoteHead.no-ledgers
}

\relative c'' {
  r8 f8\glissando
  \glissandoSkipOn
  f4 g a a8\noBeam
  \glissandoSkipOff
  a8

  r8 f8\glissando
  \glissandoSkipOn
  g4 a8
  \glissandoSkipOff
  a8 |

  r4 f\glissando \<
  \glissandoSkipOn
  a4\f \>
  \glissandoSkipOff
  b8\! r |
}

[image of music]


Adjusting slur positions vertically

Using \override Slur.positions it is possible to set the vertical position of the start and end points of a slur to absolute values (or rather, forcing LilyPond’s slur algorithm to consider these values as desired). In many cases, this means a lot of trial and error until good values are found. You probably have tried the \offset command next just to find out that it doesn’t work for slurs, emitting a warning instead.

The code in this snippet allows you to tweak the vertical start and end positions by specifying relative changes, similar to \offset.

Syntax: \offsetPositions #'(dy1 . dy2)

offsetPositions =
#(define-music-function (offsets) (number-pair?)
  #{
     \once \override Slur.control-points =
       #(lambda (grob)
          (match-let ((((_ . y1) _ _ (_ . y2))
                       (ly:slur::calc-control-points grob))
                      ((off1 . off2) offsets))
            (set! (ly:grob-property grob 'positions)
                  (cons (+ y1 off1) (+ y2 off2)))
            (ly:slur::calc-control-points grob)))
  #})

\relative c'' {
  c4(^"default" c, d2)
  \offsetPositions #'(0 . 1)
  c'4(^"(0 . 1)" c, d2)
  \offsetPositions #'(0 . 2)
  c'4(^"(0 . 2)" c, d2)
  \bar "||"
  g4(^"default" a d'2)
  \offsetPositions #'(1 . 0)
  g,,4(^"(1 . 0)" a d'2)
  \offsetPositions #'(2 . 0)
  g,,4(^"(2 . 0)" a d'2)
}

[image of music]


Ajustar la forma de les caigudes i pujades de to

Pot caldre ajustar la propietat shortest-duration-space per poder ajustar la mida de les caigudes i pujades de to («falls» i «doits»).

\relative c'' {
  \override Score.SpacingSpanner.shortest-duration-space = 4.0
  c2-\bendAfter 5
  c2-\bendAfter -4.75
  c2-\bendAfter 8.5
  c2-\bendAfter -6
}

[image of music]


Aligning the ends of hairpins to NoteColumn directions

The ends of hairpins may be aligned to the LEFT, CENTER or RIGHT of NoteColumn grobs by overriding the property endpoint-alignments, which is a pair of numbers representing the left and right ends of the hairpin. endpoint-alignments are expected to be directions (either -1, 0 or 1). Other values will be transformed with a warning. The right end of a hairpin terminating at a rest is not affected, always ending at the left edge of the rest.

{
  c'2\< <c' d'>\! |
  \override Hairpin.endpoint-alignments = #'(1 . -1)
  c'2\< <c' d'>\! |
  \override Hairpin.endpoint-alignments = #`(,LEFT . ,CENTER)
  c'2\< <c' d'>\! |
}

[image of music]


Formes alternatives de la figura breu

Les figures de breu també estan disponibles amb dues línies verticals a les vores del cap en lloc d’una sola línia i la forma en estil barroc.

\relative c'' {
  \time 4/2
  c\breve |
  \override Staff.NoteHead.style = #'altdefault
  b\breve
  \override Staff.NoteHead.style = #'baroque
  b\breve
  \revert Staff.NoteHead.style
  a\breve
}

[image of music]


Lligadures asimètriques

Es pot fer que una lligradura d’expressió sigui asimètrica per adaptar-se millor un patró asimètric de notes.

slurNotes = { d,8( a' d f a f' d, a) }

\relative c' {
  \stemDown
  \slurUp
  \slurNotes
  \once \override Slur.eccentricity = #3.0
  \slurNotes
}

[image of music]


Marques de respiració

Les marques de respiració estan disponibles per diversos gustos: coma (la predeterminada), ratlla curta, v baixa i “vies del tren” (cesura).

\new Staff \relative c'' {
  \key es \major
  \time 3/4
  % this bar contains no \breathe
  << { g4 as g } \\ { es4 bes es } >> |
  % Modern notation:
  % by default, \breathe uses the rcomma, just as if saying:
  % \override BreathingSign.text =
  %   #(make-musicglyph-markup "scripts.rcomma")
  << { g4 as g } \\ { es4 \breathe bes es } >> |

  % rvarcomma and lvarcomma are variations of the default rcomma
  % and lcomma
  % N.B.: must use Staff context here, since we start a Voice below
  \override Staff.BreathingSign.text =
    \markup { \musicglyph "scripts.rvarcomma" }
  << { g4 as g } \\ { es4 \breathe bes es } >> |

  % raltcomma and laltcomma are alternative variations of the
  % default rcomma and lcomma
  \override Staff.BreathingSign.text =
    \markup { \musicglyph "scripts.raltcomma" }
  << { g4 as g } \\ { es4 \breathe bes es } >> |

  % vee
  \override BreathingSign.text =
    \markup { \musicglyph "scripts.upbow" }
  es8[ d es f g] \breathe f |

  % caesura
  \override BreathingSign.text =
    \markup { \musicglyph "scripts.caesura.curved" }
  es8[ d] \breathe es[ f g f] |
  es2 r4 \bar "||"
}

[image of music]


Regulador interromput

Per fer invisibles parts d’un regulador de crescendo, s’usa el mètode de dibuixar un rectangle blanc a sobre de la respectiva del regulador, tapant-la. El rectangle es defineix com codi de postscript dins d’un element de marcatge de text.

L’ordre de marcatge with-dimensions indica al LilyPond que consideri sols l’extrem inferior del rectangle quan realitzi l’espaiat d’aquest rectangle frente al regulador. La propietat staff-padding evita que el rectangle càpiga entre el regulador i el pentagrama.

Assegureu-vos que el regulador està a una capa més baixa que l’element de marcatge de text per traçar el rectangle a sobre del regulador.

\relative c' {
  <<
    {
      \dynamicUp
      r2 r16 c'8.\pp r4
    }
    \\
    {
      \override DynamicLineSpanner.layer = #0
      des,2\mf\< ~
      \override TextScript.layer = #2
      \once\override TextScript.staff-padding = #6
      \once\override TextScript.vertical-skylines = #'()
      des16_\markup \with-dimensions #'(2 . 7) #'(0 . 0)
                    \with-color #white
                    \filled-box #'(2 . 7) #'(0 . 2) #0
      r8. des4 ~ des16->\sff r8.
    }
  >>
}

[image of music]


Cesura tipus "vies del tren" amb calderó

En ocasions es denota una «cesura» mitjançant una doble marca de respiració semblant a les vies d’un tren, amb un calderó a sobre. Aquest fragment de codi presenta una combinació visualment satisfactòria d’aquestes dues marques.

\relative c'' {
  c2.
  % construct the symbol
  \override BreathingSign.text = \markup {
    \override #'(direction . 1)
    \override #'(baseline-skip . 1.8)
    \dir-column {
      \translate #'(0.155 . 0)
        \center-align \musicglyph "scripts.caesura.curved"
      \center-align \musicglyph "scripts.ufermata"
    }
  }
  \breathe c4
  % set the breath mark back to normal
  \revert BreathingSign.text
  c2. \breathe c4
  \bar "|."
}

[image of music]


Centrar text a sota d’un regulador

Aquest exemple proporciona una funció per escriure un regulador amb text a sota, com “molto” o “poco”. El text afegit canvia la direcció d’acord amb la del regulador. L’objecte hairpin està alineat amb DynamicText.

L’exemple il·lustra també com modificar la manera en la qual s’imprimeix normalment un object, utilitzat codi de l’Scheme.

\paper { tagline = ##f }

hairpinWithCenteredText =
#(define-music-function (text) (markup?)
  #{
    \once \override Voice.Hairpin.after-line-breaking =
      #(lambda (grob)
        (let* ((stencil (ly:hairpin::print grob))
               (par-y (ly:grob-parent grob Y))
               (dir (ly:grob-property par-y 'direction))
               (staff-line-thickness
                 (ly:output-def-lookup (ly:grob-layout grob) 'line-thickness))
               (new-stencil (ly:stencil-aligned-to
                 (ly:stencil-combine-at-edge
                   (ly:stencil-aligned-to stencil X CENTER)
                   Y dir
                   (ly:stencil-aligned-to
                     (grob-interpret-markup
                       grob
                       (make-fontsize-markup
                         (magnification->font-size
                           (+ (ly:staff-symbol-staff-space grob)
                              (/ staff-line-thickness 2)))
                           text)) X CENTER))
                 X LEFT))
               (staff-space (ly:output-def-lookup
                 (ly:grob-layout grob) 'staff-space))
               (par-x (ly:grob-parent grob X))
               (dyn-text (grob::has-interface par-x 'dynamic-text-interface))
               (dyn-text-stencil-x-length
                 (if dyn-text
                   (interval-length
                     (ly:stencil-extent (ly:grob-property par-x 'stencil) X))
                   0))
               (x-shift
                 (if dyn-text
                   (-
                     (+ staff-space dyn-text-stencil-x-length)
                     (* 0.5 staff-line-thickness)) 0)))

        (ly:grob-set-property! grob 'Y-offset 0)
        (ly:grob-set-property! grob 'stencil
           (ly:stencil-translate-axis
            new-stencil
            x-shift X))))
  #})

hairpinMolto =
\hairpinWithCenteredText \markup { \italic molto }

hairpinMore =
\hairpinWithCenteredText \markup { \larger moltissimo }

\layout { ragged-right = ##f }

\relative c' {
  \hairpinMolto
  c2\< c\f
  \hairpinMore
  c2\ppppp\< c\f
  \break
  \hairpinMolto
  c2^\< c\f
  \hairpinMore
  c2\ppppp\< c\f
}

[image of music]


Canviar el text i els estils d’objecte d’extensió per a les indicacions dinàmiques textuals

Es pot modificar el text empleat per als crescendos i decrescendos modificant les propietats de context crescendoText i decrescendoText.

L’estil de la línia d’extensió es pot canviar modificant la propietat 'style de DynamicTextSpanner. El valor predeterminat és 'dashed-line (línia discontínua), i entre d’altres valors possibles es troben 'line (línia), 'dotted-line (línia de punts) i 'none (res):

\relative c'' {
  \set crescendoText = \markup { \italic { cresc. poco } }
  \set crescendoSpanner = #'text
  \override DynamicTextSpanner.style = #'dotted-line
  a2\< a
  a2 a
  a2 a
  a2 a\mf
}

[image of music]


Modificar l’aspecte continu d’una lligadura d’expressió a puntejat o intermitent

Es pot canviar l’aspecte de les lligadures d’expressió de contínues a puntejades o intermitents.

\relative c' {
  c4( d e c)
  \slurDotted
  c4( d e c)
  \slurSolid
  c4( d e c)
  \slurDashed
  c4( d e c)
  \slurSolid
  c4( d e c)
}

[image of music]


Canviar el símbol de la marca de respiració

El glif de la marca de respiració es pot ajustar sobreescrivint la propietat de text de l’objecte de presentació BreathingSign, amb qualsevol altre text de marcatge.

\relative c'' {
  c2
  \override BreathingSign.text =
    \markup { \musicglyph "scripts.rvarcomma" }
  \breathe
  d2
}

[image of music]


Modificar el nombre de puntets d’una nota

La quantitat de puntets d’una nota es pot modificar independentment dels puntets que s’escriuen després d’una nota.

\relative c' {
  c4.. a16 r2 |
  \override Dots.dot-count = 4
  c4.. a16 r2 |
  \override Dots.dot-count = 0
  c4.. a16 r2 |
  \revert Dots.dot-count
  c4.. a16 r2 |
}

[image of music]


Combinar indicacions dinàmiques amb marcatges textuals

Certes indicacions dinàmiques poden portar textos (com “più forte” o “piano subito”). Es poden produir usant un bloc \markup.

piuF = \markup { \italic più \dynamic f }

\layout { ragged-right = ##f }

\relative c'' {
  c2\f c-\piuF
}

[image of music]


Glissando contemporani

Es pot gravar un glissando contemporani sense nota final utilitzant una nota oculta i temporització de cadenza.

\relative c'' {
  \time 3/4
  \override Glissando.style = #'zigzag
  c4 c
  \cadenzaOn
  c4\glissando
  \hideNotes
  c,,4
  \unHideNotes
  \cadenzaOff
  \bar "|"
}

[image of music]


Controlar la visibilitat dels objectes d’extensió després d’un salt de línia

La visibilitat dels objectes d’extensió que acaben a la primera nota després d’un salt de línia està controlada per la funció de crida de after-line-breaking ly:spanner::kill-zero-spanned-time.

Per als objectes com els glissandos i els reguladors, el comportament predeterminat és ocultar l’objecte d’extensió després del salt; la inhabilitació de la funció de callblack fa que l’object d’extensió trencat per l’esquerra pot mostrar-se.

De forma inversa, els objectes d’extensió que són visibles normalment, com els objectes d’extensió de text, es poden ocultar habilitant la funció de callback.

\paper {
  ragged-right = ##t
  tagline = ##f
}

\relative c'' {
  \override Hairpin.to-barline = ##f
  \override Glissando.breakable = ##t
  % show hairpin
  \override Hairpin.after-line-breaking = ##t
  % hide text span
  \override TextSpanner.after-line-breaking =
    #ly:spanner::kill-zero-spanned-time
  e2\<\startTextSpan
  % show glissando
  \override Glissando.after-line-breaking = ##t
  f2\glissando
  \break
  f,1\!\stopTextSpan
}

[image of music]


Controlar l’ordenació vertical de les inscripcions

L’orden vertical que ocupen les inscripcions gràfiques està controlat amb la propietat 'script-priority. Quant més baix és aquest número, més a prop de la nota es col·locarà. En aquest exemple, el TextScript (el sostingut) té primer la prioritat més baixa, per la qual cosa se situa en la posició més baixa al primer exemple. En el segon, el semitrí (el Script) és el que la té més baixa, per la qual cosa se situa en la part interior. Quan dos objectes tenen la mateixa prioritat, l’ordre en el qual s’introdueixen determina quin serà el que apareix en primer lloc.

\relative c''' {
  \once \override TextScript.script-priority = -100
  a2^\prall^\markup { \sharp }

  \once \override Script.script-priority = -100
  a2^\prall^\markup { \sharp }

  \set fingeringOrientations = #'(up)
  <c-2 a-1>2
  <a-1 c\tweak script-priority -100 -2>2
}

[image of music]


Crear un grupet d’anticipació

La creació d’un grupet circular d’anticipació entre dues notes, on la nota inferior del grupet utilitza una alteració, requereix diverses sobreescriptures de propietats. La propietat outside-staff-priority es pot establir al valor #f, atès que en aquest cas tindria prioritat sobre la propietat avoid-slur property. Canviant les fraccions 2/3 i 1/3 pot ajustar-se la posició horitzontal.

\relative c'' {
  \after 2*2/3 \turn c2( d4) r |
  \after 4 \turn c4.( d8)
  \after 4
  {
    \once \set suggestAccidentals = ##t
    \once \override AccidentalSuggestion.outside-staff-priority = ##f
    \once \override AccidentalSuggestion.avoid-slur = #'inside
    \once \override AccidentalSuggestion.font-size = -3
    \once \override AccidentalSuggestion.script-priority = -1
    \once \hideNotes
    cis8\turn \noBeam
  }
  d4.( e8)
}

[image of music]


Crear arpegis entre notes de veus diferents

Es pot dibuixar un símbol d’arpegi entre notes de diferents veus que estan sobre el mateix pentagrama si el gravador Span_arpeggio_engraver es trasllada al context de Staff:

\new Staff \with {
  \consists "Span_arpeggio_engraver"
}
\relative c' {
  \set Staff.connectArpeggios = ##t
  <<
    { <e' g>4\arpeggio <d f> <d f>2 }
    \\
    { <d, f>2\arpeggio <g b>2 }
  >>
}

[image of music]


Crear arpegis que es creuen entre pentagrames dins d’un sistema de piano

Dins d’un PianoStaff, és possible fer que un arpegi creuï entre els pentagrames ajustant la propietat PianoStaff.connectArpeggios.

\new PianoStaff \relative c'' <<
  \set PianoStaff.connectArpeggios = ##t
  \new Staff {
    <c e g c>4\arpeggio
    <g c e g>4\arpeggio
    <e g c e>4\arpeggio
    <c e g c>4\arpeggio
  }
  \new Staff {
    \clef bass
    \repeat unfold 4 {
      <c,, e g c>4\arpeggio
    }
  }
>>

[image of music]


Creació d’arpegis que es creuen entre pentagrames dins d’altres contextos

Es poden crear arpegis que es creuen entre pentagrames dins de contextos diferents a GrandStaff, PianoStaff i Span_arpeggio_engraver en el context de Score.

\score {
  \new ChoirStaff {
    \set Score.connectArpeggios = ##t
    <<
      \new Voice \relative c' {
        <c e>2\arpeggio
        <d f>2\arpeggio
        <c e>1\arpeggio
      }
      \new Voice \relative c {
        \clef bass
        <c g'>2\arpeggio
        <b g'>2\arpeggio
        <c g'>1\arpeggio
      }
    >>
  }
  \layout {
    \context {
      \Score
      \consists "Span_arpeggio_engraver"
    }
  }
}

[image of music]


Crear digitacions de dues xifres

És possible crear digitacions amb el nombre més gran de 5.

\relative c' {
  c1-10
  c1-50
  c1-36
  c1-29
}

[image of music]


Crear indicacions dinàmiques "vertaderes" entre parèntesis

Tot i que la manera més fàcil d’afegir parèntesis a una indicació de dinàmica és utilitzar un bloc \markup, aquest mètode té un inconvenient: els objectes que es creen es comportaran com elements de marcatge de text i no com indicacions dinàmiques.

No obstant, és possible crear un objecte utilitzant el codi de l’Scheme equivalent (com s’explica a la Referència de la notació), en combinació amb la funció make-dynamic-script. D’aquesta forma l’element de marcatge es tractarà com una indicació dinàmica, i per tant seguirà sent compatible amb ordre com ara \dynamicUp o \dynamicDown.

paren =
#(define-event-function (dyn) (ly:event?)
   (make-dynamic-script
    #{ \markup \concat {
         \normal-text \italic \fontsize #2 (
	 \pad-x #0.2 #(ly:music-property dyn 'text)
	 \normal-text \italic \fontsize #2 )
       }
    #}))

\relative c'' {
  c4\paren\f c c \dynamicUp c\paren\p
}

[image of music]


Fer lligadures entre veus diferents

En determinades situacions cal crear lligadures d’expressió entre notes que estan a veus diferents.

La solució és afegir notes invisible a una de les veus utilitzant \hideNotes.

Aquest exemple és el compàs 235 de la Chacona de la segona Partita per a violí sol, BMW 1004, de Bach.

\relative c' {
  <<
    {
      d16( a') s a s a[ s a] s a[ s a]
    }
    \\
    {
      \slurUp
      bes,16[ s e](
      \hideNotes a)
      \unHideNotes f[(
      \hideNotes a)
      \unHideNotes fis](
      \hideNotes a)
      \unHideNotes g[(
      \hideNotes a)
      \unHideNotes gis](
      \hideNotes a)
    }
  >>
}

[image of music]


Crear elements de extensió textuals

Les ordres \startTextSpan i \stopTextSpan permeten la creació d’elements d’extensió textuals tan fàcilment com indicacions de pedal o octavacions. Sobreescrivim certes propietats de l’object TextSpanner per modificar la seva sortida.

\paper { ragged-right = ##f }

\relative c'' {
  \override TextSpanner.bound-details.left.text = #"bla"
  \override TextSpanner.bound-details.right.text = #"blu"
  a4 \startTextSpan
  b4 c
  a4 \stopTextSpan

  \override TextSpanner.style = #'line
  \once \override TextSpanner.bound-details.left.stencil-align-dir-y = #CENTER
  a4 \startTextSpan
  b4 c
  a4 \stopTextSpan

  \override TextSpanner.style = #'dashed-line
  \override TextSpanner.bound-details.left.text =
    \markup { \draw-line #'(0 . 1) }
  \override TextSpanner.bound-details.right.text =
    \markup { \draw-line #'(0 . -2) }
  \once \override TextSpanner.bound-details.right.padding = #-2

  a4 \startTextSpan
  b4 c
  a4 \stopTextSpan

  \set Staff.middleCPosition = #-13
  \override TextSpanner.dash-period = #10
  \override TextSpanner.dash-fraction = #0.5
  \override TextSpanner.thickness = #10
  a4 \startTextSpan
  b4 c
  a4 \stopTextSpan
}

[image of music]


Objecte personalitzat d’extensió de text de matisos dinàmics, postfix

Funcions postfix per a la creació d’objectes d’extensió de text personalitzats. Els objectes d’extensió han de començar en la primera nota del compàs. Cal utilitzar -\mycresc, en cas contrari el començament de l’objecte d’extensió s’assignarà a la nota següent.

% Two functions for (de)crescendo spanners where you can explicitly
% give the spanner text.
mycresc =
#(define-music-function (mymarkup) (markup?)
   (make-music 'CrescendoEvent
               'span-direction START
               'span-type 'text
               'span-text mymarkup))
mydecresc =
#(define-music-function (mymarkup) (markup?)
   (make-music 'DecrescendoEvent
               'span-direction START
               'span-type 'text
               'span-text mymarkup))

\relative c' {
  c4-\mycresc "custom cresc" c4 c4 c4 |
  c4 c4 c4 c4 |
  c4-\mydecresc "custom decresc" c4 c4 c4 |
  c4 c4\! c4 c4
}

[image of music]


Objectes extensors de text postfix per a dinàmica

Els objectes d’extensió \cresc, \dim i \decresc ara es poden redefinir com a operadors postfix i produir un sols objecte d’extensió de text. La definició d’extensores personalitzats també és fàcil. Es poden barrejar amb facilitat els crescendi textuals i en forma de reguladors. \< i \> produeixen reguladors gràfics de forma predeterminada, \cresc etc. produeixen elements extensors de text de forma predeterminada.

% Some sample text dynamic spanners, to be used as postfix operators
crpoco =
#(make-music 'CrescendoEvent
             'span-direction START
             'span-type 'text
             'span-text "cresc. poco a poco")

\relative c' {
  c4\cresc d4 e4 f4 |
  g4 a4\! b4\crpoco c4 |
  c4 d4 e4 f4 |
  g4 a4\! b4\< c4 |
  g4\dim a4 b4\decresc c4\!
}

[image of music]


Glissando per sota d’una objecte gràfic

Els objectes gràfics de columna de nota (els grobs NoteColumn) poder ser sobrepassats pels glissandos.

\relative c' {
  a2 \glissando
  \once \override NoteColumn.glissando-skip = ##t
  f''4 d,
}

[image of music]


Reguladors amb diferents estils de línia

Els reguladors poden imprimir-se en qualsevol dels estils de line-interface: discontinu, puntejat, línia, tri o zig-zag.

\relative c' {
  c2\< c\!
  \override Hairpin.style = #'dashed-line
  c2\< c\!
  \override Hairpin.style = #'dotted-line
  c2\< c\!
  \override Hairpin.style = #'line
  c2\< c\!
  \override Hairpin.style = #'trill
  c2\< c\!
  \override Hairpin.style = #'zigzag
  c2\< c\!
  \revert Hairpin.style
  c2\< c\!
}

[image of music]


Ocultar la línia d’extensió de les expressions textuals de dinàmica

Els canvis de dinàmica amb estil de text (com cresc. i dim.) es graven amb una línia intermitent que mostra el seu abast. Aquesta línia es pot suprimir de la manera següent:

\relative c'' {
  \override DynamicTextSpanner.style = #'none
  \crescTextCresc
  c1\< | d | b | c\!
}

[image of music]


Alinear horitzontalment indicacions dinàmiques personalitzades (per exemple "sempre pp""piu f""subito p")

Algunes expressions de matís dinàmic porten text addicional, com "sempre pp". Considerant que els matisos solen anar centrats sota la nota, el \p s’imprimiria molt després de la nota a la qual s’aplica el matís.

Per alinear correctament el "sempre pp" en sentit horitzontal, de manera que s’alineï com si estigués solament el \pp, hi h a diversos enfocaments:

* Senzillament usar \once\override DynamicText.X-offset = #-9.2 abans de la nota que porta el matís, per desplaçar-lo manualment a la posició correcta. Inconvenient: cal fer-ho manualment cada cop que usem aquesta indicació dinàmica.

* Afegir una mica de farciment (#:hspace 7.1) dins de la definició de la nostra indicació dinàmica personalitzada, de forma que després que el LilyPond l’hagi centrat, ja estigui alineada correctament. Inconvenient: el farciment realment ocupa aquest espai i no permet que es gravi cap altre element de marcatge o matís dinàmic en aquesta posició.

* Desplaçar la inscripció dinàmica \once\override ... .X-offset = ... Inconvenient: ¡cal \once\override per a cada una de les invocacions!

* Fixar les dimensions del text addicional a zero (usant #:with-dimensions '(0 . 0) '(0 . 0)). Inconvenient: per al LilyPond "sempre" no té dimensions, per la qual cosa podria gravar altres elements en el seu mateix lloc i produir col·lisions (que no serien advertides pel mecanisme de detecció de col·lisions). Així mateix, aparentment hi ha algun espai, i per tant no és exactament la mateixa alineació que sense el text addicional.

* Afegir un desplaçament explicit directament dins de la funció de l’Scheme que produeix l’element dynamic-script.

* Fixar una alineació explícita dins del dynamic-script. De forma predeterminada, això no tindria cap efecte, a no ser que fixéssim un valor per a X-offset. Inconvenient: hem de donar un valor a DynamicText.X-offset que s’aplicaria a tots els textos de dinàmica. A més a més, s’alinea amb l’extrem dret del text addicional, no amb el centre del pp.

\paper {
  ragged-right = ##f
  indent = 2.5\cm
  tagline = ##f
}

% Solution 1: Using a simple markup with a particular halign value
% Drawback: It's a markup, not a dynamic command, so \dynamicDown
%           etc. will have no effect
semppMarkup = \markup { \halign #1.4 \italic "sempre" \dynamic "pp" }

% Solution 2: Using a dynamic script & shifting with
%             \once \override ...X-offset = ..
% Drawback: \once \override needed for every invocation
semppK =
#(make-dynamic-script
  (markup #:line
          (#:normal-text
           #:italic "sempre"
           #:dynamic "pp")))

% Solution 3: Padding the dynamic script so the center-alignment
%             puts it at the correct position
% Drawback: the padding really reserves the space, nothing else can be there
semppT =
#(make-dynamic-script
  (markup #:line
          (#:normal-text
           #:italic "sempre"
           #:dynamic "pp"
           #:hspace 7.1)))

% Solution 4: Dynamic, setting the dimensions of the additional text to 0
% Drawback: To lilypond "sempre" has no extent, so it might put
%           other stuff there => collisions
% Drawback: Also, there seems to be some spacing, so it's not exactly the
%           same alignment as without the additional text
semppM =
#(make-dynamic-script
  (markup #:line
          (#:with-dimensions '(0 . 0) '(0 . 0)
                             #:right-align
                             #:normal-text
                             #:italic "sempre"
                             #:dynamic "pp")))

% Solution 5: Dynamic with explicit shifting inside the scheme function
semppG =
#(make-dynamic-script
  (markup #:hspace 0
          #:translate '(-18.85 . 0)
          #:line (#:normal-text
                  #:italic "sempre"
                  #:dynamic "pp")))

% Solution 6: Dynamic with explicit alignment. This has only effect
%             if one sets X-offset!
% Drawback: One needs to set DynamicText.X-offset!
% Drawback: Aligned at the right edge of the additional text,
%           not at the center of pp
semppMII =
#(make-dynamic-script
  (markup #:line (#:right-align
                  #:normal-text
                  #:italic "sempre"
                  #:dynamic "pp")))

\new StaffGroup <<
  \new Staff = "s" \with { instrumentName = \markup \column { Normal } }
  <<
    \relative c'' {
      \key es \major
      c4\pp c\p c c | c\ff c c\pp c
    }
  >>
  \new Staff = "sMarkup" \with {
    instrumentName = \markup \column { Normal markup }
  }
  <<
    \relative c'' {
      \key es \major
      c4-\semppMarkup c\p c c | c\ff c c-\semppMarkup c
    }
  >>
  \new Staff = "sK" \with {
    instrumentName = \markup \column { Explicit shifting }
  }
  <<
    \relative c'' {
      \key es \major
      \once \override DynamicText.X-offset = #-9.2
      c4\semppK c\p c c
      c4\ff c
      \once \override DynamicText.X-offset = #-9.2
      c4\semppK c
    }
  >>
  \new Staff = "sT" \with {
    instrumentName = \markup \column { Right padding }
  }
  <<
    \relative c'' {
      \key es \major
      c4\semppT c\p c c | c\ff c c\semppT c
    }
  >>
  \new Staff = "sM" \with {
    instrumentName = \markup \column { Set dimension "to zero" }
  }
  <<
    \relative c'' {
      \key es \major
      c4\semppM c\p c c | c\ff c c\semppM c
    }
  >>
  \new Staff = "sG" \with {
    instrumentName = \markup \column { Shift inside dynamics}
  }
  <<
    \relative c'' {
      \key es \major
      c4\semppG c\p c c | c\ff c c\semppG c
    }
  >>
  \new Staff = "sMII" \with {
    instrumentName = \markup \column { Alignment inside dynamics }
  }
  <<
    \relative c'' {
      \key es \major
      % Setting to ##f (false) gives the same result
      \override DynamicText.X-offset = #0
      c4\semppMII c\p c c | c\ff c c\semppMII c
    }
  >>
>>

\layout { \override Staff.InstrumentName.self-alignment-X = #LEFT }

[image of music]


Inserir una cesura

Les marques de cesura es poden crear sobreescrivint la propietat 'text de l’objecte BreathingSign. També està disponible una marca de cesura corba.

\relative c'' {
  \override BreathingSign.text = \markup {
    \musicglyph "scripts.caesura.straight"
  }
  c8 e4. \breathe g8. e16 c4

  \override BreathingSign.text = \markup {
    \musicglyph "scripts.caesura.curved"
  }
  g8 e'4. \breathe g8. e16 c4
}

[image of music]


Lligaduras “Laissez vibrer”

Les lligadures “Laissez vibrer” (deixar vibrar) tenen una mida fixa. Es pot ajustar el seu format usant 'tie-configuration.

\relative c' {
  <c e g>4\laissezVibrer r <c f g>\laissezVibrer r
  <c d f g>4\laissezVibrer r <c d f g>4.\laissezVibrer r8

  <c d e f>4\laissezVibrer r
  \override LaissezVibrerTieColumn.tie-configuration
     = #`((-7 . ,DOWN)
          (-5 . ,DOWN)
          (-3 . ,UP)
          (-1 . ,UP))
  <c d e f>4\laissezVibrer r
}

[image of music]


Puntes de fletxa per a les línies

Es poden aplicar puntes de fletxa als elements d’extensió de text i de línia (com el Glissando).

\relative c'' {
  \override TextSpanner.bound-padding = #1.0
  \override TextSpanner.style = #'line
  \override TextSpanner.bound-details.right.arrow = ##t
  \override TextSpanner.bound-details.left.text = #"fof"
  \override TextSpanner.bound-details.right.text = #"gag"
  \override TextSpanner.bound-details.right.padding = #0.6

  \override TextSpanner.bound-details.right.stencil-align-dir-y = #CENTER
  \override TextSpanner.bound-details.left.stencil-align-dir-y = #CENTER

  \override Glissando.bound-details.right.arrow = ##t
  \override Glissando.arrow-length = #0.5
  \override Glissando.arrow-width = #0.25

  a8\startTextSpan gis a4 b\glissando b,
  g'4 c\stopTextSpan c2
}

[image of music]


Fer lligadures d’expressió amb estructura complexa de discontinuïtat

Les lligadures d’expressió es poden construir amb patrons de discontinuïtat complexos mitjançant la definició de la propietat dash-definition. dash-definition és una llista de paràmetres que defineixen el comportament de discontinuïtat d’un segment de la lligadura d’expressió.

La lligadura es defineix en termes del paràmetre de bezier t el rang del qual va de 0 a l’esquerra de la lligadura fins a 1 a l’extrem dret de la lligadura. cada element de discontinuïtat és una llista (t-inici t-final fracció-discontinuïtat període-discontinuitat). La regió de la lligadura des de t-inici fins a t-final tindrà una fracció fracció-discontinuitat de cada període-discontinuïtat de color negre. període-discontinuïtat es defineix en termes d’espais de pentagrama. fracció-discontinuïtat s’estableix al valor d’1 per a una lligadura contïnua.

\relative c' {
  \once \override
    Slur.dash-definition = #'((0 0.3 0.1 0.75)
                                (0.3 0.6 1 1)
                                (0.65 1.0 0.4 0.75))
  c4( d e f)
  \once \override
    Slur.dash-definition = #'((0 0.25 1 1)
                                (0.3 0.7 0.4 0.75)
                                (0.75 1.0 1 1))
  c4( d e f)
}

[image of music]


Modificació dels valors predeterminats per a la notació abreviada de les articulacions

Les abreviatures es troben definides dins del fitxer ly/script-init.ly, on les variablesdashHat, dashPlus, dashDash, dashBar, dashLarger, dashDot i dashUnderscore reben valors predeterminats. Es poden modificar aquests valors predeterminats per a les abreviatures. Per exemple, per associar l’abraviatura -+ (dashPlus) amb el símbol de semitrí en cmptes del símbol predeterminat +, assigneu el valor trill a la variable dashPlus:

\paper { tagline = ##f }

\relative c'' { c1-+ }

dashPlus = \trill

\relative c'' { c1-+ }

[image of music]


Desplaçament de les lligadures d’expressió verticalment

Es pot ajustar la posició vertical d’una lligadura d’expressió utilitzant la propietat positions de l’objecte Slur. La propietat de dos paràmetres, on el primer es refereix a l’extrem esquerre de la lligadura i el segon al dret. Els valors dels paràmetres no s’utilitzen per part del LilyPond per produir un desplaçament exacte de la lligadura: més bé selecciona la col·locació que té un aspecte millor, tenint en compte els valors dels paràmetres. Els valors positius desplacen la lligadura cap amunt, i són adequats a notes que tenen les pliques cap avall. Els valors negatius desplacen les lligadures baixes encara més cap avall.

\relative c' {
  \stemDown
  e4( a)
  \override Slur.positions = #'(1 . 1)
  e4( a)
  \override Slur.positions = #'(2 . 2)
  e4( a)
  \override Slur.positions = #'(3 . 3)
  e4( a)
  \override Slur.positions = #'(4 . 4)
  e4( a)
  \override Slur.positions = #'(5 . 5)
  e4( a)
  \override Slur.positions = #'(0 . 5)
  e4( a)
  \override Slur.positions = #'(5 . 0)
  e4( a)
  \stemUp
  \override Slur.positions = #'(-5 . -5)
  e4( a)
  \stemDown
  \revert Slur.positions
  e4( a)
}

[image of music]


Moving the ends of hairpins

The ends of hairpins may be offset by setting the shorten-pair property of the Hairpin object. Positive values move endpoints to the right, negative to the left. Unlike the minimum-length property, this property only affects the appearance of the hairpin; it does not adjust horizontal spacing (including the position of bounding dynamics). This method is thus suitable for fine-tuning a hairpin within its allotted space.

{
  c'1~\<
  c'2~ c'\!
  \once \override Hairpin.shorten-pair = #'(2 . 2)
  c'1~\<
  c'2~ c'\!
  \once \override Hairpin.shorten-pair = #'(-2 . -2)
  c'1~\<
  c'2~ c'\!
  c'1~\p-\tweak shorten-pair #'(2 . 0)\<
  c'2~ c'\ffff
}

[image of music]


Posicionar símbols d’arpegi

Si cal fer més llargs o més curts un símbol d’arpegi, es pot modificar independentment els extrems superior i inferior.

\relative c' {
  <c e g b>1\arpeggio
  \once \override Arpeggio.positions = #'(-5 . 0)
  <c e g b>1\arpeggio
  \once \override Arpeggio.positions = #'(0 . 5)
  <c e g b>1\arpeggio
  \once \override Arpeggio.positions = #'(-5 . 5)
  <c e g b>1\arpeggio
}

[image of music]


Situar els elements de marcatge de text por dins de les lligadures

Els elements de marcatge de text han de tenir la propietat outside-staff-priority establerta al valor fals perquè s’imprimeixin per dins de les lligadures d’expressió.

\relative c'' {
  \override TextScript.avoid-slur = #'inside
  \override TextScript.outside-staff-priority = ##f
  c2(^\markup { \halign #-10 \natural } d4.) c8
}

[image of music]


Impressió de reguladors en diversos estils

Els reguladors es poden crear en una àmplia varietat d’estils.

\paper { tagline = ##f }

\relative c'' {
  \override Hairpin.stencil = #flared-hairpin
  a4\< a a a\f
  a4\p\< a a a\ff
  a4\sfz\< a a a\!
  \override Hairpin.stencil = #constante-hairpin
  a4\< a a a\f
  a4\p\< a a a\ff
  a4\sfz\< a a a\!
  \override Hairpin.stencil = #flared-hairpin
  a4\> a a a\f
  a4\p\> a a a\ff
  a4\sfz\> a a a\!
  \override Hairpin.stencil = #constante-hairpin
  a4\> a a a\f
  a4\p\> a a a\ff
  a4\sfz\> a a a\!
}

[image of music]


Impressió de reguladors utilitzant la notació «al niente»

Es poden imprimir reguladores amb un cercle en la punta (notació «al niente») establint la propietat circled-tip de l’objecte Hairpin al valor #t.

\relative c'' {
  \override Hairpin.circled-tip = ##t
  c2\< c\!
  c4\> c\< c2\!
}

[image of music]


Impressió d’indicacions de metrònom i lletres d’assaig a sota del pentagrama

De forma predeterminada, les indicacions de metrònom i les lletres d’assaig s’imprimeixen a sobre del pentagrama. Per col·locar-les a sota del pentagrama, simplement ajustem adequadament la propietat direction de MetronomeMark o de RehearsalMark.

\layout {
  indent = 0
  ragged-right = ##f
}

{
  % Metronome marks below the staff
  \override Score.MetronomeMark.direction = #DOWN
  \tempo 8. = 120
  c''1

  % Rehearsal marks below the staff
  \override Score.RehearsalMark.direction = #DOWN
  \mark \default
  c''1
}

[image of music]


Establir el comportament dels reguladors a les barres de compàs

Si la nota que acaba un regulador cau sobre la primera part d’un compàs, el regulador s’atura en la línia divisòria immediatament precedent. Es pot controlar aquest comportament sobreescrivint la propietat 'to-barline.

\relative c'' {
  e4\< e2.
  e1\!
  \override Hairpin.to-barline = ##f
  e4\< e2.
  e1\!
}

[image of music]


Ajustament de la longitud mínima dels reguladors

Si els reguladors són massa curts, es poden allargar modificant la propietat minimum-length de l’objecte Hairpin.

<<
  {
    \after 4 \< \after 2 \> \after 2. \! f'1
    \override Hairpin.minimum-length = 8
    \after 4 \< \after 2 \> \after 2. \! f'1
  }
  {
    \repeat unfold 8 c'4
  }
>>

[image of music]


Impressió de la mateixa articulació a sobre i a sota de la mateixa nota o acord

De forma predeterminada, el LilyPond no permet posar la mateixa articulació (per exemple un accent, un calderó, un cercle d’harmònic, etc.) a sobre i a sota de la nota. Per exemple, c4_\fermata^\fermata imprimeix sols el calderó inferior. El calderó superior senzillament s’ignora. No obstant, es poden adjuntar inscripcions (de igual forma que les digitacions) dins d’un acord, soca que significa que és possible tenir tantes articulacions com es vulgui. Aquest enfocament té l’avantatge que ignora la plica i posiciona l’articulació de forma relativa al cap de la nota. Pot veure’s això en el cas dels flageolets (indicacions d’harmònic)) que apareixen en el fragment de codi. Per recrear el comportament de les inscripcions fora de l’acord, es requereix ’add-stem-support. D’aquesta manera la solució consisteix en escriure la nota com un acord i afegir les articulacions dins dels parèntesis en angle <...>. La direcció sempre serà cap a dalt, però podem retocar això per mitjà d’una ordre \tweak: <c-\tweak direcció #DOWN-\fermata^\fermata>

\relative c' {
  <>^"Wrong"
  c2_\fermata^\fermata % The second fermata is ignored!
  <e d'>2^\flageolet_\flageolet

  \stopStaff s1 \startStaff

  <>^"Works if written inside a chord"
  <e_\flageolet d'^\flageolet>2
  <e_\flageolet d'^\flageolet>2
  <e_\flageolet^\flageolet>2
  <e_\fermata^\fermata>2
}

[image of music]


Pizzicato “snap” o pizzicato de Bartók

El “snap-pizzicato” (pizzicato de pessigada, conegut també com “pizzicato de Bartók”) és un “pizzicato fort en el qual la corda es polsa verticalment pessigant-la i fent que reboti contra el diapasó de l’instrument” (Wikipedia). Es doneta mitjançant un cercle com una línia vertical que surt del centre del cercla cap amunt.

\relative c' {
  c4\snappizzicato
  <c' e g>4\snappizzicato
  <c' e g>4^\snappizzicato
  <c, e g>4_\snappizzicato
}

[image of music]


Usar una ratlla curta com a símbol de respiració

La música vocal i de vent usa amb freqüència una ratlla curta com a signe de respiració. Això indica una respiració que treu una mica de temps a la nota anterior enlloc de produir una pausa curta, cosa que s’indica amb la marca de respiració en forma de coma. La marca es pot moure lleugerament cap a dalt per allunyar-la del pentagrama.

\relative c'' {
  c2
  \breathe
  d2
  \override BreathingSign.Y-offset = #2.6
  \override BreathingSign.text =
    \markup { \musicglyph "scripts.tickmark" }
  c2
  \breathe
  d2
}

[image of music]


Ús de arpeggioBracket per fer més visible un divisi

El corxet d’arpegis arpeggioBracket es pot usar per indicar la divisió de veus quan no hi ha pliques que puguin oferir aquesta informació. Se sol trobar a la múśica coral.

\include "english.ly"

\score {
  \relative c'' {
    \key a \major
    \time 2/2
    <<
      \new Voice = "upper"
      <<
        { \voiceOne \arpeggioBracket
          a2( b2
          <b d>1\arpeggio)
          <cs e>\arpeggio ~
          <cs e>4
        }
        \addlyrics { \lyricmode { A -- men. } }
      >>
      \new Voice = "lower"
      { \voiceTwo
        a1 ~
        a
        a ~
        a4 \bar "|."
      }
    >>
  }
  \layout { ragged-right = ##t }
}

[image of music]


Utilitzar lligadures dobles per acords legato

Alguns compositors escriuen dues lligadures quan volen acords legato. Això es pot aconseguir establint doubleSlurs.

\relative c' {
  \set doubleSlurs = ##t
  <c e>4( <d f> <c e> <d f>)
}

[image of music]


Ús de la propietat whiteout

Es pot imprimir qualsevol objecte gràfic sobre un fons blanc per ocultar part dels objectes que estan a sota. Això pot ser útil per millorar l’aspecte de les col·lisions en situaciones complexes quan no es pràctic tornar a col·locar els objectes. Cal establir explícitament la propietat de capa (layer) per controlar quins objectes resulten ocultats pel fons blanc.

En aquest exemple, la col·lisió de la lligadura d’unió amb la indicació de compàs resulta millorada ocultant la part de la lligadura que creua la indicació de compàs mitjançant l’establiment de la propietat whiteout de TimeSignature. per fer això, es mou TimeSignature a una capa per sobre de Tie, que es deixa a la capa predeterminada d’1, i StaffSymbol es mou a una capa per sobre de TimeSignature de manera que no resulti ocultada.

{
  \override Score.StaffSymbol.layer = 4
  \override Staff.TimeSignature.layer = 3
  b'2 b'~
  \once \override Staff.TimeSignature.whiteout = ##t
  \time 3/4
  b' r4
}

[image of music]


Línia vertical com una articulació barroca

Aquesta línia curta vertical a sobre de la nota és d’ús comú en la música barroca. El seu significat varia, però en general indica notes que s’han de tocar amb més “pes”. L’exemple següent mostra com aconseguir aquesta notació.

upline =
\tweak stencil
  #(lambda (grob)
    (grob-interpret-markup grob #{ \markup \draw-line #'(0 . 1) #}))
  \stopped

\relative c' {
  a'4^\upline a( c d')_\upline
}

[image of music]


Alinear verticalment expressions dinàmiques que abasten diverses notes

Les expressions dinàmiques que es comencen, acaben o es produeixen a la mateixa nota, s’alineen verticalment. Per assegurar que les expressions dinàmiques s’alineen quan no es produeixen sobre la mateixa nota, incrementeu la propietat staff-padding de l’objecte DynamicLineSpanner.

\relative c' {
  \override DynamicLineSpanner.staff-padding = #4
  c2\p f\mf
  g2\< b4\> c\!
}

[image of music]


Repeats

Repeats


Afegir claus de repetició i segona vegada a més pentagrames

El gravador Volta_engraver resideix de forma predeterminada dins del context de Score, i les claus de repetició‘s’imprimeixen així normalment sols a sobre el pentagrama superior. Aixo es pot ajustar afegint el gravador Volta_engraver al context de Staff el el qual han d’aparèixer les claus; vegeu també el fragment de codi “Volta multi staff”.

<<
  \new Staff { \repeat volta 2 { c'1 } \alternative { c' } }
  \new Staff { \repeat volta 2 { c'1 } \alternative { c' } }
  \new Staff \with { \consists "Volta_engraver" } { c'2 g' e' a' }
  \new Staff { \repeat volta 2 { c'1 } \alternative { c' } }
>>

[image of music]


Nombres de compàs centrats

Sovint, les partitures d’obres per a conjunts grnas tenen els nombres de compàs a sota del sistems i centrats horitzontalment sobre l’amplada del compàs. Aquest fragment de codi mostra com pot usar-se el gravador Measure_counter_engraver per simular aquesta pràctica de notació. Aquí hem afegit el gravador a un context Dynamics.

\layout {
  \context {
    \Dynamics
    \consists #Measure_counter_engraver
    \override MeasureCounter.direction = #DOWN
    \override MeasureCounter.font-encoding = #'latin1
    \override MeasureCounter.font-shape = #'italic
    % to control the distance of the Dynamics context from the staff:
    \override VerticalAxisGroup.nonstaff-relatedstaff-spacing.padding = #2
  }
  \context {
    \Score
    \remove "Bar_number_engraver"
  }
}

pattern = \repeat unfold 7 { c'4 d' e' f' }

\new StaffGroup <<
  \new Staff {
    \pattern
  }
  \new Staff {
    \pattern
  }
  \new Dynamics {
    \startMeasureCount
    s1*7
    \stopMeasureCount
  }
>>

[image of music]


Changing the default bar lines

Default bar lines can be changed when re-defined in a score context.

% http://lsr.di.unimi.it/LSR/Item?id=964
%%=> http://lists.gnu.org/archive/html/lilypond-user/2014-03/msg00126.html
%%=> http://lilypond.1069038.n5.nabble.com/Changing-the-default-end-repeat-bracket-tc169357.html

\layout {
  \context {
    \Score
    %% Changing the defaults from engraver-init.ly
    measureBarType = "!"
    startRepeatBarType = "[|:"
    endRepeatBarType = ":|]"
    doubleRepeatBarType = ":|][|:"
  }
}

%% example:
{
  c'1
  \repeat volta 2 { \repeat unfold 2 c' }
  \repeat volta 2 { \repeat unfold 2 c' }
  \alternative {
    { c' }
    {
      %% v2.18 workaround
      \once\override Score.VoltaBracket.shorten-pair = #'(1 . -1)
      c'
    }
  }
  \bar "|."
}

[image of music]


Controlling the appearance of tremolo slashes

Using various properties of the StemTremolo grob it is possible to control the appearance of tremolo slashes.

music = {
  a''4:32 a':
  e''8: \noBeam e':
  a'':[ a':]
  f':[ g':]
  d':[ d':]
}

\new Staff {
  <>^\markup "default"
  \music
}

\new Staff {
  <>^\markup \typewriter "style = #'constant"
  \override StemTremolo.style = #'constant
  \music
}

\new Staff {
  <>^\markup \typewriter "shape = #'rectangle"
  \override StemTremolo.shape = #'rectangle
  \music
}

\new Staff {
  <>^\markup \typewriter "shape = #'beam-like"
  \override StemTremolo.shape = #'beam-like
  \music
}

\new Staff {
  <>^\markup \typewriter "slope = -0.2"
  \override StemTremolo.slope = -0.2
  \music
}

\paper {
  indent = 0
  tagline = ##f
}

[image of music]


Trèmolos de pentagrama creuat

Atès que \repeat tremolo espera exactament dos arguments musicals per als trèmolos d’acord, la nota o acord que canvia de pentagrama a un trèmolo que creua el pentagrama s’ha de col·locar dins de claus corbes junt a la seva ordre \change Staff.

\new PianoStaff <<
  \new Staff = "up" \relative c'' {
    \key a \major
    \time 3/8
    s4.
  }
  \new Staff = "down" \relative c'' {
    \key a \major
    \time 3/8
    \voiceOne
    \repeat tremolo 6 {
      <a e'>32
      {
        \change Staff = "up"
        \voiceTwo
        <cis a' dis>32
      }
    }
  }
>>

[image of music]


Trèmols amb barres flotants

Si la duració total d’un trèmol és menor d’una negra, o exactament d’una blanca, normalment es grava amb totes les barres de corxera tocant les pliques. Certs estils de notació de partitures composen algunes d’aquestes barres com a barres flotants centrades que no toquen les pliques de les figures. El nombre de barres flotants en aquest tipus de trèmol està controlat per la propietat 'gap-count del l’objecte Beam i la separació entre les barres i les pliques es fixa amb la propietat 'gap.

\relative c'' {
  \repeat tremolo 8 { a32 f }
  \override Beam.gap-count = #1
  \repeat tremolo 8 { a32 f }
  \override Beam.gap-count = #2
  \repeat tremolo 8 { a32 f }
  \override Beam.gap-count = #3
  \repeat tremolo 8 { a32 f }

  \override Beam.gap-count = #3
  \override Beam.gap = #1.33
  \repeat tremolo 8 { a32 f }
  \override Beam.gap = #1
  \repeat tremolo 8 { a32 f }
  \override Beam.gap = #0.67
  \repeat tremolo 8 { a32 f }
  \override Beam.gap = #0.33
  \repeat tremolo 8 { a32 f }
}

[image of music]


Símbols de percentatge aïllats

També es poden imprimir símbols de percentatge aïllats.

makePercent =
#(define-music-function (note) (ly:music?)
   "Make a percent repeat the same length as NOTE."
   (make-music 'PercentEvent
               'length (ly:music-length note)))

\relative c'' {
  \makePercent s1
}

[image of music]


Comptador de compassos

Aquest fragment de codi proporciona una solució alternativa a la producció de comptadors de compàs utilitzant repeticions transparents de tipus percentatge.

<<
  \context Voice = "foo" {
    \clef bass
    c4 r g r
    c4 r g r
    c4 r g r
    c4 r g r
  }
  \context Voice = "foo" {
    \set countPercentRepeats = ##t
    \hide PercentRepeat
    \override PercentRepeatCounter.staff-padding = #1
    \repeat percent 4 { s1 }
  }
>>

[image of music]


Numerar grups de compassos

Aquest fragment de codi mostra l’ús del gravador Measure_counter_engraver per numerar grups de compassos successius. Es pot numerar qualsevol període de compassos tant si té repeticions com si no.

S’ha d’afegir el gravador al context adequat. Aquí s’usa un context Staff; una altra possibilitat seria un context Dynamics.

El comptador s’inicia amb \startMeasureCount i finalitza amb \stopMeasureCount. La numeració comença amb 1, de forma predeterminada, però es pot modificar aquest comportament sobreescrivint la propietat count-from.

Quan un compàs s’estén més enllà d’un salt de línia, el número apareix dues vegades, la segona vegada entre parèntesi.

\layout {
  \context {
    \Staff
    \consists #Measure_counter_engraver
  }
}

\new Staff {
  \startMeasureCount
  \repeat unfold 7 {
    c'4 d' e' f'
  }
  \stopMeasureCount
  \bar "||"
  g'4 f' e' d'
  \override Staff.MeasureCounter.count-from = #2
  \startMeasureCount
  \repeat unfold 5 {
    g'4 f' e' d'
  }
  g'4 f'
  \bar ""
  \break
  e'4 d'
  \repeat unfold 7 {
    g'4 f' e' d'
  }
  \stopMeasureCount
}

\paper { tagline = ##f }

[image of music]


Visibilitat del comptador de repeticions de tipus percentatge

Es poden mostrar els comptadors de les repeticions del tipus percentatge a intervals regulars mitjançant l’establiment de la propietat de context repeatCountVisibility.

\relative c'' {
  \set countPercentRepeats = ##t
  \set repeatCountVisibility = #(every-nth-repeat-count-visible 5)
  \repeat percent 10 { c1 } \break
  \set repeatCountVisibility = #(every-nth-repeat-count-visible 2)
  \repeat percent 6 { c1 d1 }
}

[image of music]


Comptador de repeticions de tipus percentatge

Les repeticions de compassos complets de més en dues repeticions poden portar un comptador si s’activa la propietat adequada, com es veu en aquest exemple:

\relative c'' {
  \set countPercentRepeats = ##t
  \repeat percent 4 { c1 }
}

[image of music]


Posicionar els símbols de repetició segno i coda (amb salts de línia)

Si volem col·locar un símbol de segno de sortida i afegir text com “D.S. al Coda” al costat on normalment estan les línies del pentagrama, podem usar aquest codi. La coda continua en una línia nova. Hi ha una variant documentada en el fragment de codi, on la coda es manté en la mateixa línia.

{
  \relative c'' {
    c4 c c c c c c c c c c c
    \repeat segno 2 {
      c4 c c c c c c c
      \alternative {
        \volta 1 {
          c4 c c c c c c c c c c c
          % If you don't use \break at Coda, use \noBreak here
          % and after \bar "" below.
          \noBreak
          \section % double bar line
          \cadenzaOn % pause bar count
          \stopStaff % remove staff lines
          % Increasing the unfold counter will expand the staff-free space
          \repeat unfold 6 {
            s1
            \bar ""
          }
          % Place JumpScript where the staff would normally be.
          \once \override Score.JumpScript.outside-staff-priority = ##f
          \once \override Score.JumpScript.Y-offset = 0
          \startStaff % resume bar count
          \cadenzaOff % show staff lines again
        }
      }
    }
    \sectionLabel "Coda"
    % Show Coda on a new line
    \break
    \repeat unfold 8 { c4 c c c }
    \fine
  }
}

\paper { tagline = ##f }

[image of music]


Establiment del tipus de repetició doble predeterminat per a la primera i la segona vegada

Hi ha tres estils diferents de repeticions dobles per a la primera i la segona vegada, que es poden ajustar utilitzant doubleRepeatType.

\relative c'' {
  \repeat volta 2 { c1 }
  \set Score.doubleRepeatBarType = ":..:"
  \repeat volta 2 { c1 }
  \set Score.doubleRepeatBarType = ":|.|:"
  \repeat volta 2 { c1 }
  \set Score.doubleRepeatBarType = ":|.:"
  \repeat volta 2 { c1 }
}

[image of music]


Fer més curts els corxets de primer i segona vegada

De forma predeterminada, els corxets de primera i segona vegada es tracen a sobre els finals alternatius complets, però és possible fer-los més curts establint un valor cer per a voltaSpannerDuration. A l’exemple següent, el corxet sols dura un compàs, que correspon a una duració de 3/4.

\relative c'' {
  \time 3/4
  c4 c c
  \set Score.voltaSpannerDuration = \musicLength 2.
  \repeat volta 5 {
    d4 d d
    \alternative {
      \volta 1,2,3,4 {
        e4 e e
        f4 f f }
      \volta 5 {
        g4 g g } } }
}

[image of music]


Corxets de primera i segona vegada a sota dels acords

Mitjançant l’addició del gravador Volta_engraver al pentagrama pertinent, es poden posar els corxets de primera i segona veu a sota dels acords.

\score {
  <<
    \chords {
      c1
      c1
    }
    \new Staff \with {
      \consists "Volta_engraver"
    }
    {
      \repeat volta 2 { c'1 }
      \alternative { c' }
    }
  >>
  \layout {
    \context {
      \Score
      \remove "Volta_engraver"
    }
  }
}

[image of music]


Caselles de repetició de diversos pentagrames

Mitjançant l’addició del gravador Volta_engraver al pentagrama adequat, les caselles de primera i segona vegada es poden posar sobre algun pentagrama diferent al més alt de la partitura.

voltaMusic = \relative c'' {
  \repeat volta 2 {
    c1
    \alternative {
      \volta 1 { d1 }
      \volta 2 { e1 }
    }
  }
}

<<
  \new StaffGroup <<
    \new Staff \voltaMusic
    \new Staff \voltaMusic
  >>
  \new StaffGroup <<
    \new Staff \with { \consists "Volta_engraver" }
      \voltaMusic
    \new Staff \voltaMusic
  >>
>>

[image of music]


Elements de marcatge per al text de les caselles de repetició usant repeatCommands

Tot i que les caselles de repetició s’especifiquen de forma òptima usant \repeat volta, s’ha d’usar la propietat de context repeatCommands en cas que el text de la casella requereixi un format més avançat amb \markup.

Atès que repeatCommands admet una llista, el mètode més senzill d’incloure elements de marcatge és usar un identificador per al text i inserir-lo a la llista d’ordres usant la sintaxi de l’Scheme #(list (list 'volta textIdentifier)). Les ordres de principi i fi de repetició es poden afegir com elements de llista independents:

voltaAdLib = \markup { \volta-number { 1. 2. 3... } \italic { ad lib. } }

\relative c'' {
  c1
  \set Score.repeatCommands = #(list (list 'volta voltaAdLib) 'start-repeat)
  c4 b d e
  \set Score.repeatCommands = #'((volta #f) (volta "4.") end-repeat)
  f1
  \set Score.repeatCommands = #'((volta #f))
}

[image of music]


Simultaneous notes

Simultaneous notes


Veus addicionals per evitar col·lisions

En certs casos de polifonia complexa, calen veus addicionals per evitar col·lisions entre les notes. Si calen més de quatre veus paral·leles, les veus addicionals s’afegeixen definint una variable que utilitza la funció de l’Scheme context-spec-music.

voiceFive = #(context-spec-music (make-voice-props-set 4) 'Voice)

\relative c'' {
  \time 3/4
  \key d \minor
  \partial 2
  <<
    \new Voice  {
      \voiceOne
      a4. a8
      e'4 e4. e8
      f4 d4. c8
    }
    \new Voice {
      \voiceTwo
      d,2
      d4 cis2
      d4 bes2
    }
    \new Voice {
      \voiceThree
      f'2
      bes4 a2
      a4 s2
    }
    \new Voice {
      \voiceFive
      s2
      g4 g2
      f4 f2
    }
  >>
}

[image of music]


Changing \partCombine texts

When using the automatic part combining feature, the printed text for the solo and unison sections may be changed.

\new Staff <<
  \set Staff.soloText = "girl"
  \set Staff.soloIIText = "boy"
  \set Staff.aDueText = "together"
  \partCombine
    \relative c'' {
      g4 g r r
      a2 g
    }
    \relative c'' {
      r4 r a( b)
      a2 g
    }
>>

[image of music]


Modificar la mida d’una nota solta d’una acord

Es poden modificar notes individuals d’un acord amb l’ordre \tweak, alterant la propietat font-size.

Dins d’un acord (entre angles simples < >), abans de la nota que volem alterar, situem l’ordre \tweak seguida per #'font-size i definim la mida adequada com #-2 (un cap petit).

\relative c' {
  <\tweak font-size #+2 c e g c
   \tweak font-size #-2 e>1
   ^\markup { A tiny e }_\markup { A big c }
}

[image of music]


Clusters («raïms»)

Els «clusters» o raïms són un mecanisme per indicar la interpretació d’un àmbit de notes al mateix temps.

fragment = \relative c' {
  c4 f <e d'>4
  <g a>8 <e a> a4 c2 <d b>4
  e2 c
}

<<
  \new Staff \fragment
  \new Staff \makeClusters \fragment
>>

[image of music]


Combinar dues parts sobre el mateix pentagrama

L’eina de combinació de parts (ordre \partcombine) permet la combinació de diverses parts diferents sobre el mateix pentagrama. Les indicacions textuals com ara “solo” o “a2” s’afegeixen de forma predeterminada; per treure-les, senzillament heu d’establir la propietat printPartCombineTexts al valor “fals”. Per a partitures vocals (com himnes), no cal afegir els textos “solo” o “a2”, per la qual cosa s’han de deshabilitar. No obstant, podria ser millor no usar-lo si hi ha solos, perquè no s’indicaran. En aquests casos podria ser preferible la notació polifònica estàndard.

Aquest fragment de codi presenta les tres formes en las quals es poden imprimir dues parts sobre un sol pentagrama: polifonia estàndard, \partcombine sense textos, i \partcombine amb texts.

musicUp = \relative c'' {
  \time 4/4
  a4 c4.( g8) a4 |
  g4 e' g,( a8 b) |
  c b a2.
}

musicDown = \relative c'' {
  g4 e4.( d8) c4 |
  r2 g'4( f8 e) |
  d2 \stemDown a
}

\score {
  <<
    \new Staff \with {
      instrumentName = "standard polyphony"
    } << \musicUp \\ \musicDown >>

    \new Staff \with {
      instrumentName =
        \markup { \typewriter "\\partCombine" without text}
      printPartCombineTexts = ##f
    } \partCombine \musicUp \musicDown

    \new Staff \with {
      instrumentName =
        \markup { \typewriter "\\partCombine" with text}
    } \partCombine \musicUp \musicDown
  >>

  \layout {
    indent = 6.0\cm
    \context {
      \Score
      % Setting this to a large value avoids a bar line at the
      % beginning that would connect the three staves otherwise.
      \override SystemStartBar.collapse-height = 30
    }
  }
}

[image of music]


Impressió d’acords complexos

Aquí es presenta una forma d’imprimir un acord en la qual sona la mateixa nota dues vegades amb diferents alteracions.

fixA = {
  \once \override Stem.length = #11
}

fixB = {
  \once \override NoteHead.X-offset = #1.7
  \once \override Stem.length = #7
  \once \override Stem.rotation = #'(45 0 0)
  \once \override Stem.extra-offset = #'(-0.1 . -0.2)
  \once \override Flag.style = #'no-flag
  \once \override Accidental.extra-offset = #'(4 . -.1)
}


\relative c' {
  << { \fixA <b d!>8 } \\ { \voiceThree \fixB dis } >> s
}

[image of music]


Forçar el desplaçament horitzontal de les notes

Quan el motor de gravat no és capaç de tot, es pot usar la sintaxi següent per sobreescriure les decisions de tipografia. Les unitats de mesura que s’usen aquí són espais de pentagrama.

\relative c' <<
  {
    <d g>2 <d g>
  }
  \\
  {
    <b f'>2
    \once \override NoteColumn.force-hshift = 1.7
    <b f'>2
  }
>>

[image of music]


Fer invisible un objecte amb la propietat ’transparent

Si s’ajusta la propietat transparent d’un objecte, s’imprimeix en “tinta invisible”: l’objecte no s’imprimeix però es retenen tots els seus altres comportaments. L’objecte encara ocupa espai, participa en les col·lisions i se li poden afegir lligadures d’expressió, lligadures d’unió i barres de corxera.

Aquest fragment de codi mostra com connectar diferents veus usant lligadures d’únió. Normalment les lligadures d’unió sols connecten dues notes que estiguin a la mateixa veu. Mitjançant la introducció d’una lligadura en una veu diferent i pintant de color blanc la primera plica cap a amunt dins d’aquesta veu, la lligadura sembla creuar d’una veu a l’altra.

\relative {
  \time 2/4
  <<
    {
      \once \hide Stem
      \once \override Stem.length = #8
      b'8 ~ 8\noBeam
      \once \hide Stem
      \once \override Stem.length = #8
      g8 ~ 8\noBeam
    }
    \\
    {
      b8 g g e
    }
  >>
}

[image of music]


Desplaçament de les notes amb puntet en polifonia

Quan una nota amb puntet a la veu superior es mou per evitar la col·lisió amb una nota de una altra veu, el comportament predeterminat és desplaçar la nota superior a la dreta. Es pot canviar usant la propietat prefer-dotted-right de NoteCollision.

\new Staff \relative c' <<
  {
    f2. f4
    \override Staff.NoteCollision.prefer-dotted-right = ##f
    f2. f4
    \override Staff.NoteCollision.prefer-dotted-right = ##t
    f2. f4
  }
  \\
  { e4 e e e e e e e e e e e }
>>

[image of music]


Evitar els advertiments sobre columnes de notes que xoquen

Si es col·loquen sobre la mateixa posició notes de dues veus diferents amb les pliques en la mateixa direcció, i cap de les veus té un desplaçament o ambdues tenen el mateix desplaçament, apareix el missatge d’error ‘advertiment: massa columnes de notes en col·lisió, s'ignora’ en compilar el fitxer del LilyPond. Aquest missatge es pot evitar fixant la propietat 'ignore-collision de l’objecte NoteColumn al valor #t. Observeu que això no elimina sols els advertiments, sinó que fa que el LilyPond deixi d’intentar resoldre les col·lisions en absolut, per la qual cosa poden obtenir-se resultats diferents dels esperats si no s’usa amb prudència.

ignore = \override NoteColumn.ignore-collision = ##t

\relative c' {
  \new Staff <<
    \new Voice { \ignore \stemDown f2 g }
    \new Voice { c2 \stemDown c, }
  >>
}

[image of music]


Two \partCombine pairs on one staff

The \partCombine function takes two music expressions each containing a part, and distributes them among four Voices named “two”, “one”, “solo”, and “chords” depending on when and how the parts are merged into a common voice. The voices output from \partCombine can have their layout properties adjusted in the usual way. Here we define extensions of \partCombine to make it easier to put four voices on a staff.

soprano = { d'4 | cis'  b  e'  d'8 cis' | cis'2 b }
alto = { fis4 | e8 fis gis ais b4 b | b ais fis2 }
tenor = { a8 b | cis' dis' e'4 b8 cis' d'4 | gis cis' dis'2 }
bass = { fis8 gis | a4 gis g fis | eis fis b,2 }

\new Staff <<
  \key b\minor
  \clef alto
  \partial 4
  \transpose b b'
  \partCombineUp \soprano \alto
  \partCombineDown \tenor \bass
>>
\layout {
  \context {
    \Staff
    \accepts "VoiceBox"
  }
  \context {
    \name "VoiceBox"
    \type "Engraver_group"
    \defaultchild "Voice"
    \accepts "Voice"
    \accepts "NullVoice"
  }
}

customPartCombineUp =
#(define-music-function (partOne partTwo)
  (ly:music? ly:music?)
"Take the music in @var{partOne} and @var{partTwo} and return
a @code{VoiceBox} named @q{Up} containing @code{Voice}s
that contain @var{partOne} and @var{partTwo} merged into one
voice where feasible.  This variant sets the default voicing
in the output to use upward stems."
#{
  \new VoiceBox = "Up" <<
    \context Voice = "one" { \voiceOne }
    \context Voice = "two" { \voiceThree }
    \context Voice = "shared" { \voiceOne }
    \context Voice = "solo" { \voiceOne }
    \context NullVoice = "null" {}
    \partCombine #partOne #partTwo
  >>
#})

customPartCombineDown = #
(define-music-function (partOne partTwo)
  (ly:music? ly:music?)
"Take the music in @var{partOne} and @var{partTwo} and return
a @code{VoiceBox} named @q{Down} containing @code{Voice}s
that contain @var{partOne} and @var{partTwo} merged into one
voice where feasible.  This variant sets the default voicing
in the output to use downward stems."
#{
  \new VoiceBox = "Down" <<
    \set VoiceBox.soloText = #"Solo III"
    \set VoiceBox.soloIIText = #"Solo IV"
    \context Voice ="one" { \voiceFour }
    \context Voice ="two" { \voiceTwo }
    \context Voice ="shared" { \voiceFour }
    \context Voice ="solo" { \voiceFour }
    \context NullVoice = "null" {}
    \partCombine #partOne #partTwo
  >>
#})

soprano = { d'4 | cis'  b  e'  d'8 cis' | cis'2 b }
alto = { fis4 | e8 fis gis ais b4 b | b ais fis2 }
tenor = { a8 b | cis' dis' e'4 b8 cis' d'4 | gis cis' dis'2 }
bass = { fis8 gis | a4 gis g fis | eis fis b,2 }

\new Staff <<
  \key b\minor
  \clef alto
  \partial 4
  \transpose b b'
  \customPartCombineUp \soprano \alto
  \customPartCombineDown \tenor \bass
>>

[image of music]


Staff notation

Staff notation


Afegir un àmbit per veu

Es pot afegir un àmbit per cada veu. En aquest cas, l’àmbit s’ha de desplaçar manualment per evitar col·lisions.

\new Staff <<
  \new Voice \with {
    \consists "Ambitus_engraver"
  } \relative c'' {
    \override Ambitus.X-offset = 2.0
    \voiceOne
    c4 a d e
    f1
  }
  \new Voice \with {
    \consists "Ambitus_engraver"
  } \relative c' {
    \voiceTwo
    es4 f g as
    b1
  }
>>

[image of music]


Afegir un pentagrama nou

Es pot afegir (possiblement de forma temporal) un pentagrama nou un cop la peça ha començat.

\score {
  <<
    \new Staff \relative c'' {
      c1 | c | c | c | c
    }
    \new StaffGroup \relative c'' {
      \new Staff {
        c1 | c
        <<
          {
            c1 | d
          }
          \new Staff {
            \once \omit Staff.TimeSignature
            c1 | b
          }
        >>
        c1
      }
    }
  >>
}

[image of music]


Afegir un pentagrama addicional a un salt de línia

En afegir un pentagrama nou a un salt de línia, per desgràcia s’afegeix un espai addicional al final de la línia abans del salt (reservat per fer lloc a un canvi d’armadura que de totes formes no s’imprimirà). La solució alternativa és afegir un ajustament per a Staff.explicitKeySignatureVisibility com es mostra a l’exemple.

\paper { tagline = ##f }

\score {
  \new StaffGroup \relative c'' {
    \new Staff
    \key f \major
    c1 c^"Unwanted extra space" \break
    << { c1 | c }
       \new Staff {
         \key f \major
         \once \omit Staff.TimeSignature
         c1 | c
       }
    >>
    c1 | c^"Fixed here" \break
    << { c1 | c }
       \new Staff {
         \once \set Staff.explicitKeySignatureVisibility = #end-of-line-invisible
         \key f \major
         \once \omit Staff.TimeSignature
         c1 | c
       }
    >>
  }
}

[image of music]


Afegir indicadors als pentagrames que es divideixen després d’un salt de línia

Aquest fragment de codi defineix les ordres \splitStaffBarLine, convUpStaffBarLine i convDownStaffBarLine, que afegeix una fletxa doble a l’últim compàs d’un pentagrama, indicant que les diverses veus disposaran d’un pentagrama propi a la línia següent.

#(define-markup-command (arrow-at-angle layout props angle-deg length fill)
   (number? number? boolean?)
   (let* (
           (PI-OVER-180 (/ (atan 1 1) 34))
           (degrees->radians (lambda (degrees) (* degrees PI-OVER-180)))
           (angle-rad (degrees->radians angle-deg))
           (target-x (* length (cos angle-rad)))
           (target-y (* length (sin angle-rad))))
     (interpret-markup layout props
       (markup
        #:translate (cons (/ target-x 2) (/ target-y 2))
        #:rotate angle-deg
        #:translate (cons (/ length -2) 0)
        #:concat (#:draw-line (cons length 0)
                   #:arrow-head X RIGHT fill)))))


splitStaffBarLineMarkup = \markup \with-dimensions #'(0 . 0) #'(0 . 0) {
  \combine
  \arrow-at-angle #45 #(sqrt 8) ##t
  \arrow-at-angle #-45 #(sqrt 8) ##t
}

splitStaffBarLine = {
  \once \override Staff.BarLine.stencil =
  #(lambda (grob)
     (ly:stencil-combine-at-edge
      (ly:bar-line::print grob)
      X RIGHT
      (grob-interpret-markup grob splitStaffBarLineMarkup)
      0))
  \break
}

convDownStaffBarLine = {
  \once \override Staff.BarLine.stencil =
  #(lambda (grob)
     (ly:stencil-combine-at-edge
      (ly:bar-line::print grob)
      X RIGHT
      (grob-interpret-markup grob #{
        \markup\with-dimensions #'(0 . 0) #'(0 . 0) {
          \translate #'(0 . -.13)\arrow-at-angle #-45 #(sqrt 8) ##t
        }#})
      0))
  \break
}

convUpStaffBarLine = {
  \once \override Staff.BarLine.stencil =
  #(lambda (grob)
     (ly:stencil-combine-at-edge
      (ly:bar-line::print grob)
      X RIGHT
      (grob-interpret-markup grob #{
        \markup\with-dimensions #'(0 . 0) #'(0 . 0) {
          \translate #'(0 . .14)\arrow-at-angle #45 #(sqrt 8) ##t
        }#})
      0))
  \break
}


\header { tagline = ##f }

\paper {
  ragged-right = ##t
  short-indent = 10\mm
}

separateSopranos = {
  \set Staff.instrumentName = "AI AII"
  \set Staff.shortInstrumentName = "AI AII"
  \splitStaffBarLine
  \change Staff = "up"
}
convSopranos = {
  \convDownStaffBarLine
  \change Staff = "shared"
  \set Staff.instrumentName = "S A"
  \set Staff.shortInstrumentName = "S A"
}

sI = {
  \voiceOne
  \repeat unfold 4 f''2
  \separateSopranos
  \repeat unfold 4 g''2
  \convSopranos
  \repeat unfold 4 c''2
}
sII = {
  s1*2
  \voiceTwo
  \change Staff = "up"
  \repeat unfold 4 d''2
}
aI = {
  \voiceTwo
  \repeat unfold 4 a'2
  \voiceOne
  \repeat unfold 4 b'2
  \convUpStaffBarLine
  \voiceTwo
  \repeat unfold 4 g'2
}
aII = {
  s1*2
  \voiceTwo
  \repeat unfold 4 g'2
}
ten = {
  \voiceOne
  \repeat unfold 4 c'2
  \repeat unfold 4 d'2
  \repeat unfold 4 c'2
}
bas = {
  \voiceTwo
  \repeat unfold 4 f2
  \repeat unfold 4 g2
  \repeat unfold 4 c2
}

\score {
  <<
    \new ChoirStaff <<
      \new Staff = up \with {
        instrumentName = "SI SII"
        shortInstrumentName = "SI SII"
      } {
        s1*4
      }

      \new Staff = shared \with {
        instrumentName = "S A"
        shortInstrumentName = "S A"
      } <<
        \new Voice = sopI \sI
        \new Voice = sopII \sII
        \new Voice = altI \aI
        \new Voice = altII \aII
      >>
      \new Lyrics \with {
        alignBelowContext = up
      }
      \lyricsto sopII { e f g h }
      \new Lyrics \lyricsto altI { a b c d e f g h i j k l }

      \new Staff = men \with {
        instrumentName = "T B"
        shortInstrumentName = "T B"
      } <<
        \clef F
        \new Voice = ten \ten
        \new Voice = bas \bas
      >>
      \new Lyrics \lyricsto bas { a b c d e f g h i j k l }
    >>
  >>
  \layout {
    \context {
      \Staff \RemoveEmptyStaves
      \override VerticalAxisGroup.remove-first = ##t
    }
  }
}

[image of music]


Afegir notes guia orquestrals a una partitura vocal

Aquest exemple mostra una forma de simplificar l’addició de moltes notes guia orquestrals a la reducció de piano a una partitura vocal. La funció musical \cueWhile agafa quatre arguments: la música de la qual es pren la citació, com ve definida per \addQuote, el nom a inserir abans de la notes guia, i després #UP o #DOWN per especificar \voiceOne amb el nom a sobre del pentagrama o bé \voiceTwo amb el nom a sota del pentagrama, i finalment la música de piano amb la qual les notes guia han d’aparèixer en paral·lel. El nom de l’instrument citat es posiciona a l’esquerra de les notes guia. Es poden citar molts passatges com a guia, però no es poden superposar en el temps entre ells.

cueWhile =
#(define-music-function
   (instrument name dir music)
   (string? string? ly:dir? ly:music?)
   #{
     \cueDuring $instrument #dir {
       \once \override TextScript.self-alignment-X = #RIGHT
       \once \override TextScript.direction = $dir
       <>-\markup { \tiny #name }
       $music
     }
   #})

flute = \relative c'' {
  \transposition c'
  s4 s4 e g
}
\addQuote "flute" { \flute }

clarinet = \relative c' {
  \transposition bes
  fis4 d d c
}
\addQuote "clarinet" { \clarinet }

singer = \relative c'' { c4. g8 g4 bes4 }
words = \lyricmode { here's the lyr -- ics }

pianoRH = \relative c'' {
  \transposition c'
  \cueWhile "clarinet" "Clar." #DOWN { c4. g8 }
  \cueWhile "flute" "Flute" #UP { g4 bes4 }
}
pianoLH = \relative c { c4 <c' e> e, <g c> }

\score {
  <<
    \new Staff {
      \new Voice = "singer" {
        \singer
      }
    }
    \new Lyrics {
      \lyricsto "singer"
      \words
    }
    \new PianoStaff <<
      \new Staff {
        \new Voice {
          \pianoRH
        }
      }
      \new Staff {
        \clef "bass"
        \pianoLH
      }
    >>
  >>
}

[image of music]


Afegir marques de temps a glissandos llargs

Els temps que se salten a glissandos molt llargs s’indiquen a vegades mitjançant marques de temps, que sovint consisteixen en figures sense cap. Aquestes pliques es poden usar també per allotjar indicacions expressives intermèdies.

Si les pliques no queden ben alineades amb el glissando, podria caldre recol·locar-les lleugerament.

glissandoSkipOn = {
  \override NoteColumn.glissando-skip = ##t
  \hide NoteHead
  \override NoteHead.no-ledgers = ##t
}

glissandoSkipOff = {
  \revert NoteColumn.glissando-skip
  \undo \hide NoteHead
  \revert NoteHead.no-ledgers
}

\relative c'' {
  r8 f8\glissando
  \glissandoSkipOn
  f4 g a a8\noBeam
  \glissandoSkipOff
  a8

  r8 f8\glissando
  \glissandoSkipOn
  g4 a8
  \glissandoSkipOff
  a8 |

  r4 f\glissando \<
  \glissandoSkipOn
  a4\f \>
  \glissandoSkipOff
  b8\! r |
}

[image of music]


Numeració de compassos alternativa

Es poden seleccionar dos mètodes alternatius per a la numeració de compassos, especials quan hi ha repeticions.

music = \relative c' {
  \repeat volta 3 {
    c4 d e f |
    \alternative {
      \volta 1 { c4 d e f | c2 d \break }
      \volta 2 { f4 g a b | f4 g a b | f2 a | \break }
      \volta 3 { c4 d e f | c2 d } } }
  c1 \bar "|."
}

\markup "default"
{
  \music
}

\markup \typewriter "'numbers"
{
  \set Score.alternativeNumberingStyle = #'numbers
  \music
}

\markup \typewriter "'numbers-with-letters"
{
  \set Score.alternativeNumberingStyle = #'numbers-with-letters
  \music
}

\paper { tagline = ##f }

[image of music]


Ambitus after key signature

By default, ambitus are positioned at the left of the clef. The \ambitusAfter function allows for changing this placement. Syntax is \ambitusAfter grob-interface (see Graphical Object Interfaces for a list of possible values for grob-interface.)

A common use case is printing the ambitus between key signature and time signature.

\new Staff \with {
  \consists Ambitus_engraver
} \relative {
  \ambitusAfter key-signature
  \key d \major
  es'8 g bes cis d2
}

[image of music]


Nombres de compàs centrats

Sovint, les partitures d’obres per a conjunts grnas tenen els nombres de compàs a sota del sistems i centrats horitzontalment sobre l’amplada del compàs. Aquest fragment de codi mostra com pot usar-se el gravador Measure_counter_engraver per simular aquesta pràctica de notació. Aquí hem afegit el gravador a un context Dynamics.

\layout {
  \context {
    \Dynamics
    \consists #Measure_counter_engraver
    \override MeasureCounter.direction = #DOWN
    \override MeasureCounter.font-encoding = #'latin1
    \override MeasureCounter.font-shape = #'italic
    % to control the distance of the Dynamics context from the staff:
    \override VerticalAxisGroup.nonstaff-relatedstaff-spacing.padding = #2
  }
  \context {
    \Score
    \remove "Bar_number_engraver"
  }
}

pattern = \repeat unfold 7 { c'4 d' e' f' }

\new StaffGroup <<
  \new Staff {
    \pattern
  }
  \new Staff {
    \pattern
  }
  \new Dynamics {
    \startMeasureCount
    s1*7
    \stopMeasureCount
  }
>>

[image of music]


Changing the default bar lines

Default bar lines can be changed when re-defined in a score context.

% http://lsr.di.unimi.it/LSR/Item?id=964
%%=> http://lists.gnu.org/archive/html/lilypond-user/2014-03/msg00126.html
%%=> http://lilypond.1069038.n5.nabble.com/Changing-the-default-end-repeat-bracket-tc169357.html

\layout {
  \context {
    \Score
    %% Changing the defaults from engraver-init.ly
    measureBarType = "!"
    startRepeatBarType = "[|:"
    endRepeatBarType = ":|]"
    doubleRepeatBarType = ":|][|:"
  }
}

%% example:
{
  c'1
  \repeat volta 2 { \repeat unfold 2 c' }
  \repeat volta 2 { \repeat unfold 2 c' }
  \alternative {
    { c' }
    {
      %% v2.18 workaround
      \once\override Score.VoltaBracket.shorten-pair = #'(1 . -1)
      c'
    }
  }
  \bar "|."
}

[image of music]


Canvi del nombre de línies d’una pauta

El nombre de línies d’una pauta es pot modificar sobreescrivint la propietat line-count de l’objecte StaffSymbol.

upper = \relative c'' {
  c4 d e f
}

lower = \relative c {
  \clef bass
  c4 b a g
}

\score {
  \context PianoStaff <<
    \new Staff {
      \upper
    }
    \new Staff {
      \override Staff.StaffSymbol.line-count = #4
      \lower
    }
  >>
}

[image of music]


Modificar la mida de la pauta

Tot i que la manera més senzilla de redimensionar els pentagrames és usar #(set-global-staff-size xx), la mida d’una pauta individual es pot canviar escalant les propietats de 'staff-space i de fontSize.

<<
  \new Staff {
    \relative c'' {
      \dynamicDown
      c8\ff c c c c c c c
    }
  }
  \new Staff \with {
    fontSize = #-3
    \override StaffSymbol.staff-space = #(magstep -3)
  } {
    \clef bass
    c8 c c c c\f c c c
  }
>>

[image of music]


Crear pentagrames en blanc

Per crear pentagrames en blanc, genereu compassos buits i després elimineu el gravador de números de compàs Bar_number_engraver del context Score, i els gravadors de la indicacó de compàs Time_signature_engraver, de la clau Clef_engraver i dels compassos Bar_engraver del context de Staff.

#(set-global-staff-size 20)

\score {
  {
    \repeat unfold 12 { s1 \break }
  }
  \layout {
    indent = 0\in
    \context {
      \Staff
      \remove "Time_signature_engraver"
      \remove "Clef_engraver"
      \remove "Bar_engraver"
    }
    \context {
      \Score
      \remove "Bar_number_engraver"
    }
  }
}

% uncomment these lines for "letter" size
%{
\paper {
  #(set-paper-size "letter")
  ragged-last-bottom = ##f
  line-width = 7.5\in
  left-margin = 0.5\in
  bottom-margin = 0.25\in
  top-margin = 0.25\in
}
%}

% uncomment these lines for "A4" size
%{
\paper {
  #(set-paper-size "a4")
  ragged-last-bottom = ##f
  line-width = 180
  left-margin = 15
  bottom-margin = 10
  top-margin = 10
}
%}

[image of music]


Creació d’armadures personalitzades

El LilyPond accepta armadures personalitzades. En aquest exemple, es mostra l’armadura de re menor amb una rang estès de bemolls.

\new Staff \with {
  \override StaffSymbol.line-count = #8
  \override KeySignature.flat-positions = #'((-7 . 6))
  \override KeyCancellation.flat-positions = #'((-7 . 6))
  % presumably sharps are also printed in both octaves
  \override KeySignature.sharp-positions = #'((-6 . 7))
  \override KeyCancellation.sharp-positions = #'((-6 . 7))

  \override Clef.stencil = #
  (lambda (grob)(grob-interpret-markup grob
  #{ \markup\combine
    \musicglyph "clefs.C"
    \translate #'(-3 . -2)
    \musicglyph "clefs.F"
   #}))
    clefPosition = #3
    middleCPosition = #3
    middleCClefPosition = #3
}

{
  \key d\minor
  f bes, f bes,
}

[image of music]


Crear digitacions de dues xifres

És possible crear digitacions amb el nombre més gran de 5.

\relative c' {
  c1-10
  c1-50
  c1-36
  c1-29
}

[image of music]


Pliques de pentagrama creuat

Aquest fragment de codi mostra l’ús del gravador Span_stem_engraver i de \crossStaff per connectar automàticament pliques d’un pentagrama a un altre. No cal especificar la longitud de la plica perquè la distància variable entre els caps de les notes i els pentagrames es calcula automàticament.

\layout {
  \context {
    \PianoStaff
    \consists "Span_stem_engraver"
  }
}

\new PianoStaff <<
  \new Staff {
    <b d'>4 r d'16\> e'8. g8 r\! |
    e'8 f' g'4
      \voiceTwo \autoBeamOff
      % Down to lower staff
      \crossStaff { e'8 e'8 } e'4 |
  }

  \new Staff {
    \clef bass
    \voiceOne \autoBeamOff
    % Up to upper staff
    \crossStaff { <e g>4 e, g16 a8. c8 } d |
    \autoBeamOn g8 f g4 \voiceTwo g8 g g4 |
    }
>>

[image of music]


Mostrar claudàtor o clau en grups d’un sol pentagrama

Si hi ha un sols pentagrama en un dels tipus de sistema ChoirStaff o StaffGroup, el comportament predeterminat és que no s’imprimeixi el claudàtor a la barra inicial. Això es pot canviar sobreescrivint collapse-height per fixar el seu valor de manera que sigui menor que el nombre de línies a la pauta.

Observeu que en contextos com PianoStaff i GrandStaff en els quals els sistemes comencen amb una clau en comptes d’un claudàtor, s’ha d’establir el valor d’una propietat diferent, com es veu al segon sistema de l’exemple.

\score {
  \new StaffGroup <<
    % Must be lower than the actual number of staff lines
    \override StaffGroup.SystemStartBracket.collapse-height = 4
    \override Score.SystemStartBar.collapse-height = 4
    \new Staff {
      c'1
    }
  >>
}
\score {
  \new PianoStaff <<
    \override PianoStaff.SystemStartBrace.collapse-height = 4
    \override Score.SystemStartBar.collapse-height = 4
    \new Staff {
      c'1
    }
  >>
}

\paper { tagline = ##f }

[image of music]


Extending a TrillSpanner

For TrillSpanner, the minimum-length property becomes effective only if the set-spacing-rods procedure is called explicitly.

To do this, the springs-and-rods property should be set to ly:spanner::set-spacing-rods.

\relative c' {
  \key c\minor
  \time 2/4
  c16( as') c,-. des-.
  \once\override TrillSpanner.minimum-length = #15
  \once\override TrillSpanner.springs-and-rods = #ly:spanner::set-spacing-rods
  \afterGrace es4
  \startTrillSpan { d16[( \stopTrillSpan es)] }
  c( c' g es c g' es d
  \hideNotes
  c8)
}

[image of music]


Estendre glissandos sobre repeticions

Es pot simular un glissando que s’estén fins a l’interior de diversos blocs \alternative de primera i segona vegada mitjançant l’addició d’una nota d’adorn oculta amb un glissando al començament de cada bloc \alternative. La nota d’adorn ha d’estar a la mateixa alçada que la nota que dona inici al primer glissando., Això s’implementa aquí amb una funció musical que agafa com a argument l’altura de la nota d’adorn.

Observeu que a la música polifònica la nota d’adorn ha de coincidir amb les notes d’adorn corresponents en totes les altres veus.

repeatGliss = #(define-music-function (grace)
  (ly:pitch?)
  #{
    % the next two lines ensure the glissando is long enough
    % to be visible
    \once \override Glissando.springs-and-rods
      = #ly:spanner::set-spacing-rods
    \once \override Glissando.minimum-length = 3.5
    \once \hideNotes
    \grace $grace \glissando
  #})

\score {
  \relative c'' {
    \repeat volta 3 { c4 d e f\glissando }
    \alternative {
      { g2 d }
      { \repeatGliss f g2 e }
      { \repeatGliss f e2 d }
    }
  }
}

music =  \relative c' {
  \voiceOne
  \repeat volta 2 {
    g a b c\glissando
  }
  \alternative {
    { d1 }
    { \repeatGliss c \once \omit StringNumber e1\2 }
  }
}

\score {
  \new StaffGroup <<
    \new Staff <<
      \new Voice { \clef "G_8" \music }
    >>
    \new TabStaff  <<
      \new TabVoice { \clef "moderntab" \music }
    >>
  >>
}

\paper { tagline = ##f }

[image of music]


Flat Ties

The function takes the default Tie.stencil as an argument, calculating the result relying on the extents of this default.

Further tweaking is possible by overriding Tie.details.height-limit or with \shape. It’s also possible to change the custom-definition on the fly.

%% http://lsr.di.unimi.it/LSR/Item?id=1031

#(define ((flared-tie coords) grob)

  (define (pair-to-list pair)
     (list (car pair) (cdr pair)))

  (define (normalize-coords goods x y dir)
    (map
      (lambda (coord)
        ;(coord-scale coord (cons x (* y dir)))
        (cons (* x (car coord)) (* y dir (cdr coord))))
      goods))

  (define (my-c-p-s points thick)
    (make-connected-path-stencil
      points
      thick
      1.0
      1.0
      #f
      #f))

  ;; outer let to trigger suicide
  (let ((sten (ly:tie::print grob)))
    (if (grob::is-live? grob)
        (let* ((layout (ly:grob-layout grob))
               (line-thickness (ly:output-def-lookup layout 'line-thickness))
               (thickness (ly:grob-property grob 'thickness 0.1))
               (used-thick (* line-thickness thickness))
               (dir (ly:grob-property grob 'direction))
               (xex (ly:stencil-extent sten X))
               (yex (ly:stencil-extent sten Y))
               (lenx (interval-length xex))
               (leny (interval-length yex))
               (xtrans (car xex))
               (ytrans (if (> dir 0)(car yex) (cdr yex)))
               (uplist
                 (map pair-to-list
                      (normalize-coords coords lenx (* leny 2) dir))))

   (ly:stencil-translate
       (my-c-p-s uplist used-thick)
     (cons xtrans ytrans)))
   '())))

#(define flare-tie
  (flared-tie '((0 . 0)(0.1 . 0.2) (0.9 . 0.2) (1.0 . 0.0))))

\layout {
  \context {
    \Voice
    \override Tie.stencil = #flare-tie
  }
}

\paper {
  ragged-right = ##f
  tagline = ##f
}

\relative c' {
  a4~a
  \override Tie.height-limit = 4
  a'4~a
  a'4~a
  <a,, c e a c e a c e>~ q

  \break

  a'4~a
  \once \override Tie.details.height-limit = 14
  a4~a

  \break

  a4~a
  \once \override Tie.details.height-limit = 0.5
  a4~a

  \break

  a4~a
  \shape #'((0 . 0) (0 . 0.4) (0 . 0.4) (0 . 0)) Tie
  a4~a

  \break

  a4~a
  \once \override Tie.stencil =
    #(flared-tie '((0 . 0)(0.1 . 0.4) (0.9 . 0.4) (1.0 . 0.0)))
  a4~a

  a4~a
  \once \override Tie.stencil =
    #(flared-tie '((0 . 0)(0.06 . 0.1) (0.94 . 0.1) (1.0 . 0.0)))
  a4~a
}

[image of music]


Forçar l’amplada dels compassos perquè s’adaptin a l’amplada de les indicacions metronòmiques

De forma predeterminada, les indicacions metronòmiques no influeixen l’espaiat horitzontal. Això es pot resoldre per mitjà d’una senzilla sobreescriptura, com pot veure’s a la segona meitat de l’exemple.

example = {
  \tempo "Allegro"
  R1*6
  \tempo "Rall."
  R1*2
  \tempo "A tempo"
  R1*8
}

{
  \compressMMRests {
    \example
    R1
    R1
    \override Score.MetronomeMark.extra-spacing-width = #'(-3 . 0)
    \example
  }
}

[image of music]


Glissando per sota d’una objecte gràfic

Els objectes gràfics de columna de nota (els grobs NoteColumn) poder ser sobrepassats pels glissandos.

\relative c' {
  a2 \glissando
  \once \override NoteColumn.glissando-skip = ##t
  f''4 d,
}

[image of music]


Incipit

En transcriure música mensural, és útil posar un incipit al començament de la peça per indicar la tonalitat i el compàs originals. Actualment els músics estan acostumats a les línies del pentagrama, però en el període de la música mensural encara no s’utilitzaven. Com a compromís, amb freqüència s’imprimeixen línies divisòries entre els pentagrames, un estil de disseny conegut com mensurstriche.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% A short excerpt from the Jubilate Deo by Orlande de Lassus
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\header { tagline = ##f }

global = {
  \set Score.skipBars = ##t
  \key g \major
  \time 4/4

  % the actual music
  \skip 1*8

  % let finis bar go through all staves
  \override Staff.BarLine.transparent = ##f

  % finis bar
  \bar "|."
}

discantusIncipit = {
  \clef "neomensural-c1"
  \key f \major
  \time 2/2
  c''1.
}

discantusNotes = {
  \transpose c' c'' {
    \clef "treble"
    d'2. d'4 |
    b e' d'2 |
    c'4 e'4.( d'8 c' b |
    a4) b a2 |
    b4.( c'8 d'4) c'4 |
    \once \hide NoteHead
    c'1 |
    b\breve |
  }
}

discantusLyrics = \lyricmode {
  Ju -- bi -- la -- te De -- o,
  om -- nis ter -- ra, __ om-
  "..."
  -us.
}

altusIncipit = {
  \clef "neomensural-c3"
  \key f \major
  \time 2/2
  r1 f'1.
}

altusNotes = {
  \transpose c' c'' {
    \clef "treble"
    r2 g2. e4 fis g |
    a2 g4 e |
    fis g4.( fis16 e fis4) |
    g1 |
    \once \hide NoteHead
    g1 |
    g\breve |
  }
}

altusLyrics = \lyricmode {
  Ju -- bi -- la -- te
  De -- o, om -- nis ter -- ra,
  "..."
  -us.
}

tenorIncipit = {
  \clef "neomensural-c4"
  \key f \major
  \time 2/2
  r\longa
  r\breve
  r1 c'1.
}

tenorNotes = {
  \transpose c' c' {
    \clef "treble_8"
    R1 |
    R1 |
    R1 |
    % two measures
    r2 d'2. d'4 b e' |
    \once \hide NoteHead
    e'1 |
    d'\breve |
  }
}

tenorLyrics = \lyricmode {
  Ju -- bi -- la -- te
  "..."
  -us.
}

bassusIncipit = {
  \clef "mensural-f"
  \key f \major
  \time 2/2
  r\maxima
  f1.
}

bassusNotes = {
  \transpose c' c' {
    \clef "bass"
    R1 |
    R1 |
    R1 |
    R1 |
    g2. e4 |
    \once \hide NoteHead
    e1 |
    g\breve |
  }
}

bassusLyrics = \lyricmode {
  Ju -- bi-
  "..."
  -us.
}

\score {
  <<
    \new StaffGroup = choirStaff <<
      \new Voice = "discantusNotes" <<
        \set Staff.instrumentName = "Discantus"
        \incipit \discantusIncipit
        \global
        \discantusNotes
      >>
      \new Lyrics \lyricsto discantusNotes { \discantusLyrics }
      \new Voice = "altusNotes" <<
        \set Staff.instrumentName = "Altus"
        \global
        \incipit \altusIncipit
        \altusNotes
      >>
      \new Lyrics \lyricsto altusNotes { \altusLyrics }
      \new Voice = "tenorNotes" <<
        \set Staff.instrumentName = "Tenor"
        \global
        \incipit \tenorIncipit
        \tenorNotes
      >>
      \new Lyrics \lyricsto tenorNotes { \tenorLyrics }
      \new Voice = "bassusNotes" <<
        \set Staff.instrumentName = "Bassus"
        \global
        \incipit \bassusIncipit
        \bassusNotes
      >>
      \new Lyrics \lyricsto bassusNotes { \bassusLyrics }
    >>
  >>
  \layout {
    \context {
      \Score
      %% no bar lines in staves or lyrics
      \hide BarLine
    }
    %% the next two instructions keep the lyrics between the bar lines
    \context {
      \Lyrics
      \consists "Bar_engraver"
      \consists "Separating_line_group_engraver"
    }
    \context {
      \Voice
      %% no slurs
      \hide Slur
      %% Comment in the below "\remove" command to allow line
      %% breaking also at those bar lines where a note overlaps
      %% into the next measure.  The command is commented out in this
      %% short example score, but especially for large scores, you
      %% will typically yield better line breaking and thus improve
      %% overall spacing if you comment in the following command.
      %%\remove "Forbid_line_break_engraver"
    }
    indent = 6\cm
    incipit-width = 4\cm
  }
}

[image of music]


Inserir fragments de partitures a sobre del pentagrama com elements de marcatge

L’ordre \markup és molt versàtil. En aquest fragment de codi, hi ha un bloc \score amb una partitura completa en comptes de textos o altra marcatge.

tuning = \markup {
  \score {
    \new Staff \with { \remove "Time_signature_engraver" }
    {
      \clef bass
      <c, g, d g>1
    }
    \layout { ragged-right = ##t  indent = 0\cm }
  }
}

\header {
  title = "Solo Cello Suites"
  subtitle = "Suite IV"
  subsubtitle = \markup { Originalstimmung: \raise #0.5 \tuning }
  tagline = ##f
}

\layout { ragged-right = ##f }

\relative c'' {
  \time 4/8
  \tuplet 3/2 { c8 d e } \tuplet 3/2 { c d e }
  \tuplet 3/2 { c8 d e } \tuplet 3/2 { c d e }
  g8 a g a
  g8 a g a
}

[image of music]


Let TabStaff print the topmost string at bottom

In tablatures usually the first string is printed topmost. If you want to have it at the bottom change the stringOneTopmost-context-property. For a context-wide setting this could be done in layout as well.

%\layout {
%  \context {
%    \Score
%    stringOneTopmost = ##f
%  }
%  \context {
%    \TabStaff
%    tablatureFormat = #fret-letter-tablature-format
%  }
%}

m = {
  \cadenzaOn
  e, b, e gis! b e'
  \bar "||"
}

<<
  \new Staff { \clef "G_8" <>_"default" \m <>_"italian (historic)"\m }
  \new TabStaff
  {
    \m
    \set Score.stringOneTopmost = ##f
    \set TabStaff.tablatureFormat = #fret-letter-tablature-format
    \m
  }
>>

[image of music]


Donar format a tabulatures amb lletres

Es pot donar format a la tabulatura usant lletres en comptes de nombres.

music = \relative c {
  c4 d e f
  g4 a b c
  d4 e f g
}

<<
  \new Staff {
    \clef "G_8"
    \music
  }
  \new TabStaff \with {
    tablatureFormat = #fret-letter-tablature-format
  }
  {
    \music
  }
>>

[image of music]


Making glissandi breakable

Si s’ajusta la propietat breakable al valor #t en combinació amb after-line-breaking, podem fer que un glissando es divideixi en el salt de línia:

\paper { tagline = ##f }

glissandoSkipOn = {
  \override NoteColumn.glissando-skip = ##t
  \hide NoteHead
  \override NoteHead.no-ledgers = ##t
}

\relative c'' {
  \override Glissando.breakable = ##t
  \override Glissando.after-line-breaking = ##t
  f1\glissando |
  \break
  a4 r2. |
  f1\glissando
  \once \glissandoSkipOn
  \break
  a2 a4 r4 |
}

[image of music]


Fer unes línies del pentagrama més gruixudes que les altres

Es pot fer una línia de pentagrama més gruixuda amb fins pedagògics (per exemple la tercera línia o la de la clau de sol). Això es pot aconseguir afegint més línies molt a prop de la línia que es vol destacar, utilitzant la propietat line-positions de l’objecte StaffSymbol.

{
  \override Staff.StaffSymbol.line-positions =
    #'(-4 -2 -0.2 0 0.2 2 4)
  d'4 e' f' g'
}

[image of music]


Comptador de compassos

Aquest fragment de codi proporciona una solució alternativa a la producció de comptadors de compàs utilitzant repeticions transparents de tipus percentatge.

<<
  \context Voice = "foo" {
    \clef bass
    c4 r g r
    c4 r g r
    c4 r g r
    c4 r g r
  }
  \context Voice = "foo" {
    \set countPercentRepeats = ##t
    \hide PercentRepeat
    \override PercentRepeatCounter.staff-padding = #1
    \repeat percent 4 { s1 }
  }
>>

[image of music]


Disposició Mensurstriche (línies divisòries entre pentagrames)

La disposició «mensurstriche» en els quals les línies divisòries no estan dibuixades sobre els pentagrames, sinó entre ells, es pot aconseguir amb un StaffGroup en comptes d’un ChoirStaff. La línia divisòria sobre els pentagrames s’esborra usant \hide.

\layout {
  \context {
    \Staff
    measureBarType = "-span|"
  }
}

music = \fixed c'' {
  c1
  d2 \section e2
  f1 \fine
}

\new StaffGroup <<
  \new Staff \music
  \new Staff \music
>>

[image of music]


Modifying the Ottava spanner slope

It is possible to change the slope of the Ottava spanner.

\relative c'' {
  \override Staff.OttavaBracket.stencil = #ly:line-spanner::print
  \override Staff.OttavaBracket.bound-details =
    #`((left . ((Y . 0)
                (attach-dir . ,LEFT)
                (padding . 0)
                (stencil-align-dir-y . ,CENTER)))
       (right . ((Y . 5.0) ; Change the number here
                 (padding . 0)
                 (attach-dir . ,RIGHT)
                 (text . ,(make-draw-dashed-line-markup
                           (cons 0 -1.2))))))
  \override Staff.OttavaBracket.left-bound-info =
     #ly:horizontal-line-spanner::calc-left-bound-info-and-text
  \override Staff.OttavaBracket.right-bound-info =
     #ly:horizontal-line-spanner::calc-right-bound-info
  \ottava 1
  c1
  c'''1
}

[image of music]


Niuat de grups de pentagrames

Es pot utilitzar la propietat systemStartDelimiterHierarchy per crear grups de pentagrames niuats de forma més complexa. L’ordre \set StaffGroup.systemStartDelimiterHierarchy pren una llista alfabètic del nombre de pentagrames produïts. Es pot proporcionar abans de cada pentagrama un delimitador de començament del sistema. Es pot envoltar entre corxets i admetre tants pentagrames com envoltin els corxets. Es poden ometre els elements de la llista, però el primer corxet sempre abasta tots els pentagrames. Les possibilitat són SystemStartBar, SystemStartBracket, SystemStartBrace SystemStartSquare.

\new StaffGroup
\relative c'' <<
  \override StaffGroup.SystemStartSquare.collapse-height = 4
  \set StaffGroup.systemStartDelimiterHierarchy
    = #'(SystemStartSquare (SystemStartBrace (SystemStartBracket a
                             (SystemStartSquare b)  ) c ) d)
  \new Staff { c1 }
  \new Staff { c1 }
  \new Staff { c1 }
  \new Staff { c1 }
  \new Staff { c1 }
>>

[image of music]


Armadures de tonalitat no tradicional

La molt utilitzada ordre \key estableix la propietat keyAlterations, dins del context Staff.

Per crear armadures de tonalitat no estàndard, ajusteu aquesta propietat directament. El format d’aquesta ordre és una llista:

\set Staff.keyAlterations = #`(((octava . pas) . alteració) on, per cada element dins de la llista octava especifica l’octava (sent zero l’octava des del Do central fins al Si per sobre), pas especifica la nota dins de l’octava (zero significa Do i 6 significa Si), i alteració és ,SHARP ,FLAT ,DOUBLE-SHARP etc. (observeu la coma precedent).

De forma alternativa, per a cada element de la llista l’ús del format més concís (pas. alteració) especifica que la mateixa alteració ha d’estar en totes les octaves.

Vet aquí un exemple d’una possible armadura per generar una escala exàtona:

\include "arabic.ly"
\relative do' {
  \set Staff.keyAlterations = #`((0 . ,SEMI-FLAT)
                                 (1 . ,SEMI-FLAT)
                                 (2 . ,FLAT)
                                 (5 . ,FLAT)
                                 (6 . ,SEMI-FLAT))
%\set Staff.extraNatural = ##f
  re reb \dwn reb resd
  dod dob dosd \dwn dob |
  dobsb dodsd do do |
}

[image of music]


Numerar grups de compassos

Aquest fragment de codi mostra l’ús del gravador Measure_counter_engraver per numerar grups de compassos successius. Es pot numerar qualsevol període de compassos tant si té repeticions com si no.

S’ha d’afegir el gravador al context adequat. Aquí s’usa un context Staff; una altra possibilitat seria un context Dynamics.

El comptador s’inicia amb \startMeasureCount i finalitza amb \stopMeasureCount. La numeració comença amb 1, de forma predeterminada, però es pot modificar aquest comportament sobreescrivint la propietat count-from.

Quan un compàs s’estén més enllà d’un salt de línia, el número apareix dues vegades, la segona vegada entre parèntesi.

\layout {
  \context {
    \Staff
    \consists #Measure_counter_engraver
  }
}

\new Staff {
  \startMeasureCount
  \repeat unfold 7 {
    c'4 d' e' f'
  }
  \stopMeasureCount
  \bar "||"
  g'4 f' e' d'
  \override Staff.MeasureCounter.count-from = #2
  \startMeasureCount
  \repeat unfold 5 {
    g'4 f' e' d'
  }
  g'4 f'
  \bar ""
  \break
  e'4 d'
  \repeat unfold 7 {
    g'4 f' e' d'
  }
  \stopMeasureCount
}

\paper { tagline = ##f }

[image of music]


Plantilla d’orquestra amb cor i piano

Aquesta plantilla mostra l’ús de contextos StaffGroup i GrandStaff niuats per sub-agrupar instruments del mateix tipus, i una forma d’usar \transpose de manera que unes variables continguin la música per a instruments transpositors en afinació de concert.

#(set-global-staff-size 17)

\paper {
  indent = 3.0\cm  % add space for instrumentName
  short-indent = 1.5\cm  % add less space for shortInstrumentName
}

\header { tagline = ##f }


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

[image of music]


Print ChordNames with same root and different bass as slash and bass-note

To print subsequent ChordNames only differing in its bass note as slash and bass note use the here defined engraver. The behaviour may be controlled in detail by the chordChanges context property.

#(define Bass_changes_equal_root_engraver
  (lambda (ctx)
  "For sequential @code{ChordNames} with same root, but different bass, the root
markup is dropped: D D/C D/B  -> D /C /B
The behaviour may be controlled by setting the @code{chordChanges}
context-property."
    (let ((chord-pitches '())
          (last-chord-pitches '())
          (bass-pitch #f))
      (make-engraver
        ((initialize this-engraver)
          (let ((chord-note-namer (ly:context-property ctx 'chordNoteNamer)))
            ;; Set 'chordNoteNamer, respect user setting if already done
            (ly:context-set-property! ctx 'chordNoteNamer
              (if (procedure? chord-note-namer)
                  chord-note-namer
                  note-name->markup))))
        (listeners
          ((note-event this-engraver event)
            (let* ((pitch (ly:event-property event 'pitch))
                   (pitch-name (ly:pitch-notename pitch))
                   (pitch-alt (ly:pitch-alteration pitch))
                   (bass (ly:event-property event 'bass #f))
                   (inversion (ly:event-property event 'inversion #f)))
            ;; Collect notes of the chord
            ;;  - to compare inversed chords we need to collect the bass note
            ;;    as usual member of the chord, whereas an added bass must be
            ;;    treated separate from the usual chord-notes
            ;;  - notes are stored as pairs containing their
            ;;    pitch-name (an integer), i.e. disregarding their octave and
            ;;    their alteration
            (cond (bass (set! bass-pitch pitch))
                  (inversion
                    (set! bass-pitch pitch)
                    (set! chord-pitches
                          (cons (cons pitch-name pitch-alt) chord-pitches)))
                  (else
                    (set! chord-pitches
                          (cons (cons pitch-name pitch-alt) chord-pitches)))))))
        (acknowledgers
          ((chord-name-interface this-engraver grob source-engraver)
            (let ((chord-changes (ly:context-property ctx 'chordChanges #f)))
              ;; If subsequent chords are equal apart from their bass,
              ;; reset the 'text-property.
              ;; Equality is done by comparing the sorted lists of this chord's
              ;; elements and the previous chord. Sorting is needed because
              ;; inverted chords may have a different order of pitches.
              ;; `chord-changes' needs to be true
              (if (and bass-pitch
                       chord-changes
                       (equal?
                         (sort chord-pitches car<)
                         (sort last-chord-pitches car<)))
                  (ly:grob-set-property! grob 'text
                    (make-line-markup
                      (list
                        (ly:context-property ctx 'slashChordSeparator)
                        ((ly:context-property ctx 'chordNoteNamer)
                         bass-pitch
                         (ly:context-property ctx 'chordNameLowercaseMinor))))))
              (set! last-chord-pitches chord-pitches)
              (set! chord-pitches '())
              (set! bass-pitch #f))))
        ((finalize this-engraver)
          (set! last-chord-pitches '()))))))

myChords = \chordmode {
  %\germanChords

  \set chordChanges = ##t
  d2:m d:m/cis

  d:m/c
  \set chordChanges = ##f
  d:m/b

  e1:7
  \set chordChanges = ##t
  e
  \break
  \once \set chordChanges = ##f
  e1/f
  e2/gis e/+gis e e:m/f d:m d:m/cis d:m/c
  \set chordChanges = ##f
  d:m/b
}

<<
  \new ChordNames
    \with { \consists #Bass_changes_equal_root_engraver }
    \myChords
  \new Staff \myChords
>>

[image of music]


Posar lletra dins del pentagrama

Es poden moure les línies de lletra verticalment per imprimir-les dins del pentagrama. Les lletres es mouen amb \override LyricText.extra-offset = #'(0 . dy) i hi ha instruccions per moure les línies d’extensió i els guions. El desplaçament necessari s’estableix mitjançant un procés d’assaig i error.

<<
  \new Staff <<
    \new Voice = "voc" \relative c' { \stemDown a bes c8 b c4 }
  >>
  \new Lyrics \with {
    \override LyricText.extra-offset = #'(0 . 8.6)
    \override LyricExtender.extra-offset = #'(0 . 8.6)
    \override LyricHyphen.extra-offset = #'(0 . 8.6)
  } \lyricsto "voc" { La la -- la __ _ la }
>>

[image of music]


Citació d’una altra veu

La propietat quotedEventTypes determina els tipus d’esdeveniments musicals que resulten citats. El valor predeterminat és (note-event rest-event tie-event beam-event tuplet-span-event), que significa que sols apareixen en l’expressió \quoteDuring les notes, silencis, lligadures, barres i grups especials. A l’exemple següent, el silenci de semicorxera no apareix en el fragment citat perquè rest-event no està dins quotedEventTypes.

Per veure una llista dels tipus d’esdeveniment, consulteu la secció “Music classes” de la Referència de funcionament intern.

quoteMe = \relative c' {
  fis4 r16 a8.-> b4\ff c
}
\addQuote quoteMe \quoteMe

original = \relative c'' {
  c8 d s2
  \once \override NoteColumn.ignore-collision = ##t
  es8 gis8
}

<<
  \new Staff \with { instrumentName = "quoteMe" }
  \quoteMe

  \new Staff \with { instrumentName = "orig" }
  \original

  \new Staff \with {
    instrumentName = "orig+quote"
    quotedEventTypes = #'(note-event articulation-event)
  }
  \relative c''
  <<
    \original
    \new Voice {
      s4
      \set fontSize = #-4
      \override Stem.length-fraction = #(magstep -4)
      \quoteDuring "quoteMe" { \skip 2. }
    }
  >>
>>

[image of music]


Citació d’una altra veu amb transposició

Els passatges citats tenen en compte la trasnposició de la font tant com la del destí. En aquest exemple, tots els instruments interpreten una nota amb el so de Do central; el destí d’un instrument transpositor en Fa. La part de destí es pot transportar utilitzant \transpose. En aquest cas les notes citades romanen sense canvis.

\addQuote clarinet {
  \transposition bes
  \repeat unfold 8 { d'16 d' d'8 }
}

\addQuote sax {
  \transposition es'
  \repeat unfold 16 { a8 }
}

quoteTest = {
  % french horn
  \transposition f
  g'4
  << \quoteDuring "clarinet" { \skip 4 } s4^"clar." >>
  << \quoteDuring "sax" { \skip 4 } s4^"sax." >>
  g'4
}

{
  \new Staff \with {
    instrumentName = \markup { \column { Horn "in F" } }
  }
  \quoteTest
  \transpose c' d' << \quoteTest s4_"up a tone" >>
}

[image of music]


Removing brace on first line of piano score

This snippet removes the first brace from a PianoStaff or a GrandStaff, together with the clefs.

It may be useful when cutting and pasting the engraved image into existing music.

It uses \alterBroken.

someMusic =  {
  \once \override Staff.Clef.stencil = ##f
  \once \override Staff.TimeSignature.stencil = ##f
  \repeat unfold 3 c1 \break
  \repeat unfold 5 c1 \break
  \repeat unfold 5 c1
}

\score {
  \new PianoStaff
  <<
    \new Staff = "right" \relative c'' \someMusic
    \new Staff = "left" \relative c' { \clef F \someMusic }
  >>
  \layout {
    indent=75
    \context {
      \PianoStaff
      \alterBroken transparent #'(#t) SystemStartBrace
    }
  }
}

\paper { tagline = ##f }

[image of music]


Supressió de la primera línia buida

El primer pentagrama buit també es pot suprimir de la partitura establint la propietat remove-first de VerticalAxisGroup. Això es pot fer globalment dins del bloc \layout, o localment dins del pentagrama concret que es vol suprimir. En aquest últim cas, hem d’especificar el contex (Staff s’aplica sols al pentagrama actual) davant de la propietat.

El pentagrama inferior del segon grup no s’elimina, perquè l’ajustament sols s’aplica al pentagraa concret dins del que s’escriu.

\layout {
  \context {
    \Staff \RemoveEmptyStaves
    % To use the setting globally, uncomment the following line:
    % \override VerticalAxisGroup.remove-first = ##t
  }
}
\new StaffGroup <<
  \new Staff \relative c' {
    e4 f g a \break
    c1
  }
  \new Staff {
    % To use the setting globally, comment this line,
    % uncomment the line in the \layout block above
    \override Staff.VerticalAxisGroup.remove-first = ##t
    R1 \break
    R
  }
>>
\new StaffGroup <<
  \new Staff \relative c' {
    e4 f g a \break
    c1
  }
  \new Staff {
    R1 \break
    R
  }
>>

\paper { tagline = ##f }

[image of music]


Fixació d’un separador entre els sistemes

Es poden inserir separadors de sistema entre els sistemes d’una pàgina. Es pot usar qualsevol element de marcatge, però hi ha \slashSeparator com una elecció predeterminada adequada.

\paper {
  system-separator-markup = \slashSeparator
  line-width = 120
  tagline = ##f
}

notes = \relative c' {
  c1 | c \break
  c1 | c \break
  c1 | c
}

\book {
  \score {
    \new GrandStaff <<
      \new Staff \notes
      \new Staff \notes
    >>
  }
}

[image of music]


Barres de compàs en forma de ratlla curta

Freqüentment, s’usen barres de compàs en forma de ’tick’ o ratlla curta on la línia divisòria s’emplea sols a efectes de coordinació i no es vol impliar amb ella cap èmfasi ritmic.

\relative c' {
  \set Score.measureBarType = #"'"
  c4 d e f
  g4 f e d
  c4 d e f
  g4 f e d
  \bar "|."
}

[image of music]


Time signature in brackets

The time signature can be enclosed within brackets.

\relative c'' {
  \override Staff.TimeSignature.stencil = #(lambda (grob)
    (bracketify-stencil (ly:time-signature::print grob) Y 0.1 0.2 0.1))
  \time 2/4
  a4 b8 c
}

[image of music]


Compàs entre parèntesis

La indicació de compàs pot envoltar-se entre parèntesi.

\relative c'' {
  \override Staff.TimeSignature.stencil = #(lambda (grob)
    (parenthesize-stencil (ly:time-signature::print grob) 0.1 0.4 0.4 0.1))
  \time 2/4
  a4 b8 c
}

[image of music]


Ajustament de les propietats de clau

La modificació del glif de la clau, la seva posició o octava, no canvien ’per se’ la posició de les notes següents del pentagrama. Per aconseguir armadures adequades de tonalitat sobre les línies del pentagrama, s’ha d’especificar també middleCClefPosition, amb valor positius o negatius que moguin Do central cap amunt o cap avall, respectivament, en relació amb la línia central del pentagrama (usualment la tercera).

Per exemple, l’ordre \clef "treble_8" equival a un ajustament de clefGlyph, clefPosition (que controla la posició vertical de la clau sobre el pentagrama), middleCPosition i clefTransposition. Se imprimeix la clau cada cop que es modifica qualsevol de les propietats excepte middleCPosition.

Els exemple següents mostren les possibilitats quan s’ajusten aquestes propietats manualment. En la primera línia, els canvis manuals preserven la posició relativa estàndard de les clau i les notes, però no ho fan a la segona línia.

{
  % The default treble clef
  \key f \major
  c'1
  % The standard bass clef
  \set Staff.clefGlyph = "clefs.F"
  \set Staff.clefPosition = 2
  \set Staff.middleCPosition = 6
  \set Staff.middleCClefPosition = 6
  \key g \major
  c'1
  % The baritone clef
  \set Staff.clefGlyph = "clefs.C"
  \set Staff.clefPosition = 4
  \set Staff.middleCPosition = 4
  \set Staff.middleCClefPosition = 4
  \key f \major
  c'1
  % The standard choral tenor clef
  \set Staff.clefGlyph = "clefs.G"
  \set Staff.clefPosition = -2
  \set Staff.clefTransposition = -7
  \set Staff.middleCPosition = 1
  \set Staff.middleCClefPosition = 1
  \key f \major
  c'1
  % A non-standard clef
  \set Staff.clefPosition = 0
  \set Staff.clefTransposition = 0
  \set Staff.middleCPosition = -4
  \set Staff.middleCClefPosition = -4
  \key g \major
  c'1 \break

  % The following clef changes do not preserve
  % the normal relationship between notes, key signatures
  % and clefs:

  \set Staff.clefGlyph = "clefs.F"
  \set Staff.clefPosition = 2
  c'1
  \set Staff.clefGlyph = "clefs.G"
  c'1
  \set Staff.clefGlyph = "clefs.C"
  c'1
  \set Staff.clefTransposition = 7
  c'1
  \set Staff.clefTransposition = 0
  \set Staff.clefPosition = 0
  c'1

  % Return to the normal clef:

  \set Staff.middleCPosition = 0
  c'1
}

\paper { tagline = ##f }

[image of music]


Two \partCombine pairs on one staff

The \partCombine function takes two music expressions each containing a part, and distributes them among four Voices named “two”, “one”, “solo”, and “chords” depending on when and how the parts are merged into a common voice. The voices output from \partCombine can have their layout properties adjusted in the usual way. Here we define extensions of \partCombine to make it easier to put four voices on a staff.

soprano = { d'4 | cis'  b  e'  d'8 cis' | cis'2 b }
alto = { fis4 | e8 fis gis ais b4 b | b ais fis2 }
tenor = { a8 b | cis' dis' e'4 b8 cis' d'4 | gis cis' dis'2 }
bass = { fis8 gis | a4 gis g fis | eis fis b,2 }

\new Staff <<
  \key b\minor
  \clef alto
  \partial 4
  \transpose b b'
  \partCombineUp \soprano \alto
  \partCombineDown \tenor \bass
>>
\layout {
  \context {
    \Staff
    \accepts "VoiceBox"
  }
  \context {
    \name "VoiceBox"
    \type "Engraver_group"
    \defaultchild "Voice"
    \accepts "Voice"
    \accepts "NullVoice"
  }
}

customPartCombineUp =
#(define-music-function (partOne partTwo)
  (ly:music? ly:music?)
"Take the music in @var{partOne} and @var{partTwo} and return
a @code{VoiceBox} named @q{Up} containing @code{Voice}s
that contain @var{partOne} and @var{partTwo} merged into one
voice where feasible.  This variant sets the default voicing
in the output to use upward stems."
#{
  \new VoiceBox = "Up" <<
    \context Voice = "one" { \voiceOne }
    \context Voice = "two" { \voiceThree }
    \context Voice = "shared" { \voiceOne }
    \context Voice = "solo" { \voiceOne }
    \context NullVoice = "null" {}
    \partCombine #partOne #partTwo
  >>
#})

customPartCombineDown = #
(define-music-function (partOne partTwo)
  (ly:music? ly:music?)
"Take the music in @var{partOne} and @var{partTwo} and return
a @code{VoiceBox} named @q{Down} containing @code{Voice}s
that contain @var{partOne} and @var{partTwo} merged into one
voice where feasible.  This variant sets the default voicing
in the output to use downward stems."
#{
  \new VoiceBox = "Down" <<
    \set VoiceBox.soloText = #"Solo III"
    \set VoiceBox.soloIIText = #"Solo IV"
    \context Voice ="one" { \voiceFour }
    \context Voice ="two" { \voiceTwo }
    \context Voice ="shared" { \voiceFour }
    \context Voice ="solo" { \voiceFour }
    \context NullVoice = "null" {}
    \partCombine #partOne #partTwo
  >>
#})

soprano = { d'4 | cis'  b  e'  d'8 cis' | cis'2 b }
alto = { fis4 | e8 fis gis ais b4 b | b ais fis2 }
tenor = { a8 b | cis' dis' e'4 b8 cis' d'4 | gis cis' dis'2 }
bass = { fis8 gis | a4 gis g fis | eis fis b,2 }

\new Staff <<
  \key b\minor
  \clef alto
  \partial 4
  \transpose b b'
  \customPartCombineUp \soprano \alto
  \customPartCombineDown \tenor \bass
>>

[image of music]


Us del corxet recte al començament d’un grup de pentagrames

Es pot usar el delimitador de començament d’un sistema SystemStartSquare establint-lo explícitament dins d’un context StaffGroup o ChoirStaffGroup.

\score {
  \new StaffGroup { <<
  \set StaffGroup.systemStartDelimiter = #'SystemStartSquare
    \new Staff { c'4 d' e' f' }
    \new Staff { c'4 d' e' f' }
  >> }
}

[image of music]


Usar canvi automàtic de pentagrama amb més d’una veu

Utilització de autochange amb més d’una veu.

\score {
  \new PianoStaff
  <<
    \new Staff = "up" {
      <<
        \set Timing.beamExceptions = #'()
        \set Timing.beatStructure = #'(4)
        \new Voice {
          \voiceOne
          \autoChange
          \relative c' {
            g8 a b c d e f g
            g,8 a b c d e f g
          }
        }

        \new Voice {
          \voiceTwo
          \autoChange
          \relative c' {
            g8 a b c d e f g
            g,,8 a b c d e f g
          }
        }
      >>
    }

    \new Staff = "down" {
      \clef bass
    }
  >>
}

[image of music]


Using marklines in a Frenched score

Using MarkLine contexts (such as in LSR1010) in a Frenched score can be problematic if all the staves between two MarkLines are removed in one system. The Keep_alive_together_engraver can be used within each StaffGroup to keep the MarkLine alive only as long as the other staves in the group stay alive.

bars = {
  \tempo "Allegro" 4=120
  s1*2
  \repeat unfold 5 { \mark \default s1*2 }
  \bar "||"
  \tempo "Adagio" 4=40
  s1*2
  \repeat unfold 8 { \mark \default s1*2 }
  \bar "|."
}
winds = \repeat unfold 120 { c''4 }
trumpet = { \repeat unfold 8 g'2 R1*16 \repeat unfold 4 g'2 R1*8 }
trombone = { \repeat unfold 4 c'1 R1*8 d'1 R1*17 }
strings = \repeat unfold 240 { c''8 }

#(set-global-staff-size 16)
\paper {
  systems-per-page = 5
  ragged-last-bottom = ##f
}

\layout {
  indent = 15\mm
  short-indent = 5\mm
  \context {
    \name MarkLine
    \type Engraver_group
    \consists Output_property_engraver
    \consists Axis_group_engraver
    \consists Mark_engraver
    \consists Metronome_mark_engraver
    \consists Staff_collecting_engraver
    \override VerticalAxisGroup.remove-empty = ##t
    \override VerticalAxisGroup.remove-layer = #'any
    \override VerticalAxisGroup.staff-affinity = #DOWN
    \override VerticalAxisGroup.nonstaff-relatedstaff-spacing.padding = 1
    keepAliveInterfaces = #'()
  }
  \context {
    \Staff
    \override VerticalAxisGroup.remove-empty = ##t
    \override VerticalAxisGroup.remove-layer = ##f
  }
  \context {
    \StaffGroup
    \accepts MarkLine
    \consists Keep_alive_together_engraver
  }
  \context {
    \Score
    \remove Mark_engraver
    \remove Metronome_mark_engraver
    \remove Staff_collecting_engraver
  }
}

\score {
  <<
    \new StaffGroup = "winds" \with {
      instrumentName = "Winds"
      shortInstrumentName = "Winds"
    } <<
      \new MarkLine \bars
      \new Staff \winds
    >>
    \new StaffGroup = "brass" <<
      \new MarkLine \bars
      \new Staff = "trumpet" \with {
        instrumentName = "Trumpet"
        shortInstrumentName = "Tpt"
      } \trumpet
      \new Staff = "trombone" \with {
        instrumentName = "Trombone"
        shortInstrumentName = "Tbn"
      } \trombone
    >>
    \new StaffGroup = "strings" \with {
      instrumentName = "Strings"
      shortInstrumentName = "Strings"
    } <<
      \new MarkLine \bars
      \new Staff = "strings" { \strings }
    >>
  >>
}

[image of music]


Vertically aligned StaffGroups without connecting SystemStartBar

This snippet shows how to achieve vertically aligned StaffGroups with a SystemStartBar for each StaffGroup, but without connecting them.

#(set-global-staff-size 18)

\header { tagline = ##f }

\paper {
  indent = 0
  ragged-right = ##f
  print-all-headers = ##t
}

\layout {
  \context {
    \StaffGroup
    \consists Text_mark_engraver
    \consists Staff_collecting_engraver
    systemStartDelimiterHierarchy =
      #'(SystemStartBrace (SystemStartBracket a b))
  }

  \context {
    \Score
    \remove Text_mark_engraver
    \remove Staff_collecting_engraver
    \override SystemStartBrace.style = #'bar-line
    \omit SystemStartBar
    \override SystemStartBrace.padding = #-0.1
    \override SystemStartBrace.thickness = #1.6
    \override StaffGrouper.staffgroup-staff-spacing.basic-distance = #15
  }
}

%%%% EXAMPLE

txt =
\lyricmode {
  Wer4 nur den lie -- ben Gott läßt wal2 -- ten4
  und4 hof -- fet auf ihn al -- le Zeit2.
}

% First StaffGroup "exercise"

eI =
\relative c' {
  \textMark \markup {
          \bold Teacher:
          This is a simple setting of the choral. Please improve it.
          }
  \key a \minor
  \time 4/4
  \voiceOne

  \partial 4
  e4
  a b c b
  a b gis2
  e4\fermata g! g f
  e a a gis
  a2.\fermata
  \bar ":|."
}

eII =
\relative c' {
  \key a \minor
  \time 4/4
  \voiceTwo
  \partial 4
  c4
  e e e gis
  a f e2
  b4 b d d
  c c d d
  c2.
  \bar ":|."
}

eIII =
\relative c' {
  \key a \minor
  \time 4/4
  \clef bass
  \voiceOne

  \partial 4
  a4
  c b a b
  c d b2
  gis4 g g b
  c a f e
  e2.
}

eIV =
\relative c' {
  \key a \minor
  \time 4/4
  \clef bass
  \voiceTwo

  \partial 4
  a,4
  a' gis a e
  a, d e2
  e,4\fermata e' b g
  c f d e
  a,2.\fermata
  \bar ":|."
}

exercise =
\new StaffGroup = "exercise"
<<

  \new Staff
    <<
      \new Voice \eI
      \new Voice \eII
    >>

  \new Lyrics \txt

  \new Staff
    <<
      \new Voice \eIII
      \new Voice \eIV
    >>
>>

% Second StaffGroup "simple Bach"

sbI =
\relative c' {
  \textMark \markup { \bold" Pupil:" Here's my version! }
  \key a \minor
  \time 4/4
  \voiceOne

  \partial 4
  e4
  a b c b
  a b gis2
  e4\fermata g! g f
  e a a gis
  a2.\fermata
  \bar ":|."
}

sbII =
\relative c' {
  \key a \minor
  \time 4/4
  \voiceTwo
  \partial 4
  c8 d
  e4 e e8 f g4
  f f e2
  b4 b8 c d4 d
  e8 d c4 b8 c d4
  c2.
  \bar ":|."
}

sbIII =
\relative c' {
  \key a \minor
  \time 4/4
  \clef bass
  \voiceOne

  \partial 4
  a8 b
  c4 b a b8 c
  d4 d8 c b2
  gis4 g g8 a b4
  b a8 g f4 e
  e2.
}

sbIV =
\relative c' {
  \key a \minor
  \time 4/4
  \clef bass
  \voiceTwo

  \partial 4
  a,4
  a' gis a e
  f8 e d4 e2
  e,4\fermata e' b a8 g
  c4 f8 e d4 e
  a,2.\fermata
  \bar ":|."
}

simpleBach =
\new StaffGroup = "simple Bach"
<<

  \new Staff
    <<
      \new Voice \sbI
      \new Voice \sbII
    >>

  \new Lyrics \txt

  \new Staff
    <<
      \new Voice \sbIII
      \new Voice \sbIV
    >>
>>

% Third StaffGroup "chromatic Bach"

cbI =
\relative c' {
  \textMark \markup {
    \bold "Teacher:"
    \column {
      "Well, you simply copied and transposed a version of J.S.Bach."
      "Do you know this one?"
    }
  }
  \key a \minor
  \time 4/4
  \voiceOne

  \partial 4
  e4
  a b c b
  a b gis4. fis8
  e4\fermata g! g f
  e a a8 b gis4
  a2.\fermata
  \bar ":|."
}

cbII =
\relative c' {
  \key a \minor
  \time 4/4
  \voiceTwo
  \partial 4
  c8 d
  e4 e e8 fis gis4
  a8 g! f!4 e2
  b4 e e d
  d8[ cis] d dis e fis e4
  e2.
  \bar ":|."
}

cbIII =
\relative c' {
  \key a \minor
  \time 4/4
  \clef bass
  \voiceOne

  \partial 4
  a8 b
  c[ b] a gis8 a4 d,
  e8[ e'] d c b4. a8
  gis4 b c d8 c
  b[ a] a b c b b c16 d
  c2.
}

cbIV =
\relative c' {
  \key a \minor
  \time 4/4
  \clef bass
  \voiceTwo

  \partial 4
  a4
  c, e a, b
  c d e2
  e4\fermata e a b8 c
  gis[ g] fis f e dis e4
  a,2.\fermata
  \bar ":|."
}

chromaticBach =
\new StaffGroup = "chromatic Bach"
<<

  \new Staff
    <<
      \new Voice \cbI
      \new Voice \cbII
    >>

  \new Lyrics \txt

  \new Staff
    <<
      \new Voice \cbIII
      \new Voice \cbIV
    >>
>>


% Score

\score {
  <<
    \exercise
    \simpleBach
    \chromaticBach
  >>

  \header {
    title = \markup
               \column {
                 \combine \null \vspace #1
                 "Exercise: Improve the given choral"
                 " "
                }
  }
  \layout {
    \context {
      \Lyrics
      \override LyricText.X-offset = #-1
    }
  }
}

[image of music]


Corxets de primera i segona vegada a sota dels acords

Mitjançant l’addició del gravador Volta_engraver al pentagrama pertinent, es poden posar els corxets de primera i segona veu a sota dels acords.

\score {
  <<
    \chords {
      c1
      c1
    }
    \new Staff \with {
      \consists "Volta_engraver"
    }
    {
      \repeat volta 2 { c'1 }
      \alternative { c' }
    }
  >>
  \layout {
    \context {
      \Score
      \remove "Volta_engraver"
    }
  }
}

[image of music]


Caselles de repetició de diversos pentagrames

Mitjançant l’addició del gravador Volta_engraver al pentagrama adequat, les caselles de primera i segona vegada es poden posar sobre algun pentagrama diferent al més alt de la partitura.

voltaMusic = \relative c'' {
  \repeat volta 2 {
    c1
    \alternative {
      \volta 1 { d1 }
      \volta 2 { e1 }
    }
  }
}

<<
  \new StaffGroup <<
    \new Staff \voltaMusic
    \new Staff \voltaMusic
  >>
  \new StaffGroup <<
    \new Staff \with { \consists "Volta_engraver" }
      \voltaMusic
    \new Staff \voltaMusic
  >>
>>

[image of music]


Editorial annotations

Editorial annotations


Afegir digitacions a la partitura

Es poden escriure ordre de digitació usant una sintaxi molt senzilla.

\relative c'' {
  c4-1 d-2 f-4 e-3
}

[image of music]


Afegir enllaços als objectes

Per afegir un enllaç al segell d’un objecte gràfic, podem usar add-link tal i com es defineix aquí. Funciona amb \override i amb \tweak. Inconvenient: point-and-click (apuntar i clicar) quedarà obstaculitzat pels objectes gràfics enllaçats.

Limitació: funciona sols per a PDF.

Els objectes enllaçats s’acoloreixen amb una ordre a part.

#(define (add-link url-strg)
  (lambda (grob)
    (let* ((stil (ly:grob-property grob 'stencil)))
      (if (ly:stencil? stil)
          (let* ((x-ext (ly:stencil-extent stil X))
                 (y-ext (ly:stencil-extent stil Y))
                 (url-expr `(url-link ,url-strg ,x-ext ,y-ext))
                 (new-stil
                   (ly:stencil-add
                     (ly:make-stencil url-expr x-ext y-ext)
                     stil)))
          (ly:grob-set-property! grob 'stencil new-stil))))))

%%%% test

%% For easier maintenance of this snippet the URL is formatted to use the
%% actually used LilyPond version.
%% Of course a literal URL would work as well.

#(define major.minor-version
  (string-join (take (string-split (lilypond-version) #\.) 2) "."))

urlI =
#(format #f
  "http://lilypond.org/doc/v~a/Documentation/notation/writing-pitches"
  major.minor-version)

urlII =
#(format #f
  "http://lilypond.org/doc/v~a/Documentation/notation/rhythms"
  major.minor-version)

urlIII =
#(format #f
  "http://lilypond.org/doc/v~a/Documentation/notation/note-heads"
  major.minor-version)

urlIV =
#(format #f
  "http://lilypond.org/doc/v~a/Documentation/notation/beams"
  major.minor-version)

urlV =
#(format #f
  "http://lilypond.org/doc/v~a/Documentation/notation/note-head-styles"
  major.minor-version)

urlVI =
#(format #f
  "http://lilypond.org/doc/v~a/Documentation/notation/writing-pitches"
  major.minor-version)

\relative c' {
   \key cis \minor

   \once \override Staff.Clef.color = #green
   \once \override Staff.Clef.after-line-breaking =
     #(add-link urlI)

   \once \override Staff.TimeSignature.color = #green
   \once \override Staff.TimeSignature.after-line-breaking =
     #(add-link urlII)

   \once \override NoteHead.color = #green
   \once \override NoteHead.after-line-breaking =
     #(add-link urlIII)

   cis'1
   \once \override Beam.color = #green
   \once \override Beam.after-line-breaking =
     #(add-link urlIV)
   cis8 dis e fis gis2
   <gis,
    \tweak Accidental.color #green
    \tweak Accidental.after-line-breaking #(add-link urlVI)
    \tweak color #green
    \tweak after-line-breaking #(add-link urlV)
    \tweak style #'harmonic
    bis
    dis
    fis
   >1
   <cis, cis' e>
}

[image of music]


Adding markups in a tablature

By default markups does not show in a tablature.

To make them appear, simply use the command \revert TabStaff.TextScript.stencil

%% http://lsr.di.unimi.it/LSR/Item?id=919
% by P.P.Schneider on June 2014

high  = { r4 r8 <g c'> q r8 r4 }

low = { c4 r4 c8 r8 g,8 b, }

pulse = { s8^"1" s^"&" s^"2" s^"&" s^"3" s^"&" s^"4" s^"&" }

\score {
 \new TabStaff {
   \repeat unfold 2 << \high \\ \low \\ \pulse >>
  }
  \layout {
    \context {
      \TabStaff
      \clef moderntab
      \revert TextScript.stencil
      \override TextScript.font-series = #'bold
      \override TextScript.font-size = #-2
      \override TextScript.color = #red

    }
    \context {
      \Score
      proportionalNotationDuration = \musicLength 8
    }
  }
}

[image of music]


Permetre que les digitacions s’imprimeixen del pentagrama

Les xifres de digitació orientades verticalment es col·loquen de forma predeterminada fora del pentagrama. Malgrat això, aquest comportament es pot desactivar. Nota: s’ha d’usar una construcció d’acord <>, tot i que sigui una sola nota.

\relative c' {
  <c-1 e-2 g-3 b-5>2
  \override Fingering.staff-padding = #'()
  <c-1 e-2 g-3 b-5>4 g'-0
  a8[-1 b]-2 g-0 r
  \override Fingering.add-stem-support = ##f
  a[-1 b]-2 g-0 r
  \override Fingering.add-stem-support = ##t
  a[-1 b]-2 g-0 r
  \override Fingering.add-stem-support = #only-if-beamed
  a[-1 b]-2 g-0 r
}

[image of music]


Numeració de compassos alternativa

Es poden seleccionar dos mètodes alternatius per a la numeració de compassos, especials quan hi ha repeticions.

music = \relative c' {
  \repeat volta 3 {
    c4 d e f |
    \alternative {
      \volta 1 { c4 d e f | c2 d \break }
      \volta 2 { f4 g a b | f4 g a b | f2 a | \break }
      \volta 3 { c4 d e f | c2 d } } }
  c1 \bar "|."
}

\markup "default"
{
  \music
}

\markup \typewriter "'numbers"
{
  \set Score.alternativeNumberingStyle = #'numbers
  \music
}

\markup \typewriter "'numbers-with-letters"
{
  \set Score.alternativeNumberingStyle = #'numbers-with-letters
  \music
}

\paper { tagline = ##f }

[image of music]


Claus d’anàlisis a sobre del pentagrama

De forma predeterminada s’afegeixen claus d’anàlisis senzills a sota del pentagrama. L’exemple següent mostra una manera de col·locar-los a sobre.

\layout {
  \context {
    \Voice
    \consists "Horizontal_bracket_engraver"
  }
}

\relative c'' {
  \once \override HorizontalBracket.direction = #UP
  c2\startGroup
  d2\stopGroup
}

[image of music]


Analysis brackets with labels

Text markup may be added to analysis brackets through the text property of the HorizontalBracketText grob. Adding different texts to brackets beginning at the same time requires the \tweak command.

Bracket text will be parenthesized after a line break.

\paper { tagline = ##f }

\layout {
  \context {
    \Voice
    \consists "Horizontal_bracket_engraver"
    \override HorizontalBracket.direction = #UP
  }
}

{
  \once\override HorizontalBracketText.text = "a"
    c''\startGroup d''\stopGroup
    \once\override HorizontalBracketText.text = "a'"
    e''\startGroup d''\stopGroup |
  c''-\tweak HorizontalBracketText.text
        \markup \bold \huge "b" \startGroup
     -\tweak HorizontalBracketText.text "a" \startGroup
    d''\stopGroup
    e''-\tweak HorizontalBracketText.text "a'" \startGroup
    d''\stopGroup\stopGroup |
  c''-\tweak HorizontalBracketText.text foo \startGroup
    d'' e'' f'' | \break
  g'' a'' b'' c'''\stopGroup
}

[image of music]


Aplicar estils de cap segons la nota de l’escala

La propietat shapeNoteStyles es pot usar per definir diversos estils de caps de nota per a cada grau de l’escala (segons estigui establert per l’armadura o per la propietat tonic). Aquesta propietat requereix un conjunt de símbols, que poden ser purament arbitraris (es permeten expressions geomètriques com triangle, triangle, cross, aspes, i xcircle, cercle amb aspes) o basats en una antiga tradició americana de gravat (també es permeten certs noms de nota llatins).

Dit això, per imitar antics cançoners americans, hi ha diversos estils predefinits de caps de nota disponibles mitjançant ordres d’abreviatura com \aikenHeads o \sacredHarpHeads.

Aquest exemple mostra diferents formes d’obtenir caps de nota amb forma i mostra la capacitat de transportar una melodia sense perdre la correspondència entre les funcions harmòniques i els estils de caps de nota.

fragment = {
  \key c \major
  c2 d
  e2 f
  g2 a
  b2 c
}

\new Staff {
  \transpose c d
  \relative c' {
    \set shapeNoteStyles = ##(do re mi fa
                               #f la ti)
    \fragment
  }

  \break

  \relative c' {
    \set shapeNoteStyles = ##(cross triangle fa #f
                               mensural xcircle diamond)
    \fragment
  }
}

[image of music]


Posar en blanc les línies del utilitzant l’ordre \whiteout

L’ordre \whiteout intercala un rectangle blanc a sota d’un element de marcatge. Aquest rectangle blanc no tapa a cap altre objecte gràfic, atès que les línies del pentagrama estan en una capa inferior a la de la major part dels altres objectes.

\layout {
  ragged-right = ##f
}

\relative c' {
  \override TextScript.extra-offset = #'(2 . 4)
  c2-\markup { \whiteout \pad-markup #0.5 "middle C" } c
}

[image of music]


Modificar la mida d’una nota solta d’una acord

Es poden modificar notes individuals d’un acord amb l’ordre \tweak, alterant la propietat font-size.

Dins d’un acord (entre angles simples < >), abans de la nota que volem alterar, situem l’ordre \tweak seguida per #'font-size i definim la mida adequada com #-2 (un cap petit).

\relative c' {
  <\tweak font-size #+2 c e g c
   \tweak font-size #-2 e>1
   ^\markup { A tiny e }_\markup { A big c }
}

[image of music]


Modificar l’aspecte continu d’una lligadura d’expressió a puntejat o intermitent

Es pot canviar l’aspecte de les lligadures d’expressió de contínues a puntejades o intermitents.

\relative c' {
  c4( d e c)
  \slurDotted
  c4( d e c)
  \slurSolid
  c4( d e c)
  \slurDashed
  c4( d e c)
  \slurSolid
  c4( d e c)
}

[image of music]


Acolorir les notes segons la seva alçada

És possible acolorir el cap de les notes depenent de la seva alçada i/o del seu nom: la funció que s’usa en aquest exemple fa possible fins i tot distingir els harmònics.

%Association list of pitches to colors.
#(define color-mapping
   (list
    (cons (ly:make-pitch 0 0 NATURAL) (x11-color 'red))
    (cons (ly:make-pitch 0 0 SHARP) (x11-color 'green))
    (cons (ly:make-pitch 0 1 FLAT) (x11-color 'green))
    (cons (ly:make-pitch 0 2 NATURAL) (x11-color 'red))
    (cons (ly:make-pitch 0 2 SHARP) (x11-color 'green))
    (cons (ly:make-pitch 0 3 FLAT) (x11-color 'red))
    (cons (ly:make-pitch 0 3 NATURAL) (x11-color 'green))
    (cons (ly:make-pitch 0 4 SHARP) (x11-color 'red))
    (cons (ly:make-pitch 0 5 NATURAL) (x11-color 'green))
    (cons (ly:make-pitch 0 5 FLAT) (x11-color 'red))
    (cons (ly:make-pitch 0 6 SHARP) (x11-color 'red))
    (cons (ly:make-pitch 0 1 NATURAL) (x11-color 'blue))
    (cons (ly:make-pitch 0 3 SHARP) (x11-color 'blue))
    (cons (ly:make-pitch 0 4 FLAT) (x11-color 'blue))
    (cons (ly:make-pitch 0 5 SHARP) (x11-color 'blue))
    (cons (ly:make-pitch 0 6 FLAT) (x11-color 'blue))))

%Compare pitch and alteration (not octave).
#(define (pitch-equals? p1 p2)
   (and
    (= (ly:pitch-alteration p1) (ly:pitch-alteration p2))
    (= (ly:pitch-notename p1) (ly:pitch-notename p2))))

#(define (pitch-to-color pitch)
   (let ((color (assoc pitch color-mapping pitch-equals?)))
     (if color
         (cdr color))))

#(define (color-notehead grob)
   (pitch-to-color
    (ly:event-property (event-cause grob) 'pitch)))

\score {
  \new Staff \relative c' {
    \override NoteHead.color = #color-notehead
    c8 b d dis ees f g aes
  }
}

[image of music]


Controlar la col·locación de les digitacions d’acords

Es pot controlar amb precisió la col·locació dels números de digitació. Perquè es tingui en compte l’orientació de les digitacions, es pot utilitzar una construcció d’acord <> tot i que siguin una sola nota.

\relative c' {
  \set fingeringOrientations = #'(left)
  <c-1 e-3 a-5>4
  \set fingeringOrientations = #'(down)
  <c-1 e-3 a-5>4
  \set fingeringOrientations = #'(down right up)
  <c-1 e-3 a-5>4
  \set fingeringOrientations = #'(up)
  <c-1 e-3 a-5>4
  \set fingeringOrientations = #'(left)
  <c-1>2
  \set fingeringOrientations = #'(down)
  <e-3>2
  \set stringNumberOrientations = #'(up left down)
  <f\3 a\2 c\1>1
  \set strokeFingerOrientations = #'(down right up)
  <c\rightHandFinger 1 e\rightHandFinger 2 c'\rightHandFinger 4 >
}

[image of music]


Crear un grupet d’anticipació

La creació d’un grupet circular d’anticipació entre dues notes, on la nota inferior del grupet utilitza una alteració, requereix diverses sobreescriptures de propietats. La propietat outside-staff-priority es pot establir al valor #f, atès que en aquest cas tindria prioritat sobre la propietat avoid-slur property. Canviant les fraccions 2/3 i 1/3 pot ajustar-se la posició horitzontal.

\relative c'' {
  \after 2*2/3 \turn c2( d4) r |
  \after 4 \turn c4.( d8)
  \after 4
  {
    \once \set suggestAccidentals = ##t
    \once \override AccidentalSuggestion.outside-staff-priority = ##f
    \once \override AccidentalSuggestion.avoid-slur = #'inside
    \once \override AccidentalSuggestion.font-size = -3
    \once \override AccidentalSuggestion.script-priority = -1
    \once \hideNotes
    cis8\turn \noBeam
  }
  d4.( e8)
}

[image of music]


Crear pentagrames en blanc

Per crear pentagrames en blanc, genereu compassos buits i després elimineu el gravador de números de compàs Bar_number_engraver del context Score, i els gravadors de la indicacó de compàs Time_signature_engraver, de la clau Clef_engraver i dels compassos Bar_engraver del context de Staff.

#(set-global-staff-size 20)

\score {
  {
    \repeat unfold 12 { s1 \break }
  }
  \layout {
    indent = 0\in
    \context {
      \Staff
      \remove "Time_signature_engraver"
      \remove "Clef_engraver"
      \remove "Bar_engraver"
    }
    \context {
      \Score
      \remove "Bar_number_engraver"
    }
  }
}

% uncomment these lines for "letter" size
%{
\paper {
  #(set-paper-size "letter")
  ragged-last-bottom = ##f
  line-width = 7.5\in
  left-margin = 0.5\in
  bottom-margin = 0.25\in
  top-margin = 0.25\in
}
%}

% uncomment these lines for "A4" size
%{
\paper {
  #(set-paper-size "a4")
  ragged-last-bottom = ##f
  line-width = 180
  left-margin = 15
  bottom-margin = 10
  top-margin = 10
}
%}

[image of music]


Crear digitacions de dues xifres

És possible crear digitacions amb el nombre més gran de 5.

\relative c' {
  c1-10
  c1-50
  c1-36
  c1-29
}

[image of music]


Direcció predeterminada de las pliques sobre la tercera línia del pentagrama

La direcció predeterminada de les pliques sobre la tercera línia està determinada per la propietat neutral-direction de l’objecte Stem.

\relative c'' {
  a4 b c b
  \override Stem.neutral-direction = #up
  a4 b c b
  \override Stem.neutral-direction = #down
  a4 b c b
}

[image of music]


Different font size settings for instrumentName and shortInstrumentName

Choose different font sizes for instrumentName and shortInstrumentName as a context override.

InstrumentNameFontSize =
#(define-music-function (font-size-pair)(pair?)
"Sets the @code{font-size} of @code{InstrumentName}.
The font-size for the initial @code{instrumentName} is taken from the first
value in @var{font-size-pair}.  @code{shortInstrumentName} will get the second
value of @var{font-size-pair}.
"

;; This code could be changed/extended to set different values for each
;; occurance of `shortInstrumentName'

#{
  \override InstrumentName.after-line-breaking =
    #(lambda (grob)
       (let* ((orig (ly:grob-original grob))
              (siblings (if (ly:grob? orig)
                            (ly:spanner-broken-into orig)
                            '())))
         (if (pair? siblings)
             (begin
               (ly:grob-set-property!
                 (car siblings)
                 'font-size
                 (car font-size-pair))
               (for-each
                 (lambda (g)
                   (ly:grob-set-property! g 'font-size (cdr font-size-pair)))
                 (cdr siblings))))))
#})

\paper { tagline = ##f }

\layout {
  \context {
    \Staff
    \InstrumentNameFontSize #'(6 . -3)
  }
}

\new StaffGroup <<
  \new Staff
     \with {
       instrumentName = "Flute"
       shortInstrumentName = "Fl."
     }
     { c''1 \break c'' \break c'' }
  \new Staff
   \with {
     instrumentName = "Violin"
     shortInstrumentName = "Vl."
   }
   { c''1 \break c'' \break c'' }
>>

[image of music]


Rodejar els objectes gràfics amb rectangles

Es pot sobreescriure la funció print-function per traçar un rectangle al voltant d’un objecte gràfic arbitrari.

\relative c'' {
  \override TextScript.stencil =
    #(make-stencil-boxer 0.1 0.3 ly:text-interface::print)
  c'4^"foo"

  \override Stem.stencil =
    #(make-stencil-boxer 0.05 0.25 ly:stem::print)
  \override Score.RehearsalMark.stencil =
    #(make-stencil-boxer 0.15 0.3 ly:text-interface::print)
  b8

  \revert Stem.stencil
  \revert Flag.stencil
  c4. c4
  \mark \default
  c1
}

[image of music]


Traçar circumferències al voltant del cap de les notes

Aquí es presenta com rodejar una nota amb una circumferència.

circle =
\once \override NoteHead.stencil = #(lambda (grob)
    (let* ((note (ly:note-head::print grob))
           (combo-stencil (ly:stencil-add
               note
               (circle-stencil note 0.1 0.8))))
          (ly:make-stencil (ly:stencil-expr combo-stencil)
            (ly:stencil-extent note X)
            (ly:stencil-extent note Y))))

{ \circle c'' }

[image of music]


Rodejar diversos objectes amb una circumferència

L’ordre de marcatge \circle traça circumferències al voltant de diversos objectes, per exemple les indicacions de digitació. Per a d’altres objectes es poden requerir ajustament específics: aquest exemple mostra dues estratègies per a lletres d’assaig i els números de compàs.

\relative c' {
  c1
  \set Score.rehearsalMarkFormatter =
    #(lambda (mark context)
             (make-circle-markup (format-mark-numbers mark context)))
  \mark \default

  c2 d^\markup {
    \override #'(thickness . 3) {
      \circle \finger 2
    }
  }
  \override Score.BarNumber.break-visibility = #all-visible
  \override Score.BarNumber.stencil =
    #(make-stencil-circler 0.1 0.25 ly:text-interface::print)
}

[image of music]


Inserir PostScript nadiu dins d’un bloc \markup

Es pot inserir codi PostScript directament dins d’un bloc \markup.

% PostScript is a registered trademark of Adobe Systems Inc.

\relative c'' {
  a4-\markup { \postscript "3 4 moveto 5 3 rlineto stroke" }
  -\markup { \postscript "[ 0 1 ] 0 setdash 3 5 moveto 5 -3 rlineto stroke " }

  b4-\markup { \postscript "3 4 moveto 0 0 1 2 8 4 20 3.5 rcurveto stroke" }
  s2
  a'1
}

[image of music]


Línies de reixeta: modificar el seu aspecte

Es pot canviar l’aspecte de les línies de reixeta sobreescrivint algunes de les seves propietats.

\score {
  \new ChoirStaff <<
    \new Staff {
      \relative c'' {
        \stemUp
        c'4. d8 e8 f g4
      }
    }
    \new Staff {
      \relative c {
        % this moves them up one staff space from the default position
        \override Score.GridLine.extra-offset = #'(0.0 . 1.0)
        \stemDown
        \clef bass
        \once \override Score.GridLine.thickness = 5.0
        c4
        \once \override Score.GridLine.thickness = 1.0
        g'4
        \once \override Score.GridLine.thickness = 3.0
        f4
        \once \override Score.GridLine.thickness = 5.0
        e4
      }
    }
  >>
  \layout {
    \context {
      \Staff
      % set up grids
      \consists "Grid_point_engraver"
      % set the grid interval to one quarter note
      gridInterval = \musicLength 4
    }
    \context {
      \Score
      \consists "Grid_line_span_engraver"
      % this moves them to the right half a staff space
      \override NoteColumn.X-offset = -0.5
    }
  }
}

[image of music]


Línies de reixeta: destacar ritmes i la relació temporal entre notes

Es poden traçar línies verticals normals entre pentagrames per mostrar la relació entre notes; malgrat això, en cas de música monofònica, podem fer invisible el segon pentagrama, i que les línies siguin més curtes, com en aquest fragment de codi.

\score {
  \new ChoirStaff {
    \relative c'' <<
      \new Staff {
        \time 12/8
        \stemUp
        c4. d8 e8 f g4 f8 e8. d16 c8
      }
      \new Staff {
        % hides staff and notes so that only the grid lines are visible
        \hideNotes
        \hide Staff.BarLine
        \override Staff.StaffSymbol.line-count = #0
        \hide Staff.TimeSignature
        \hide Staff.Clef

        % dummy notes to force regular note spacing
        \once  \override Score.GridLine.thickness = #4.0
        c8 c c
        \once  \override Score.GridLine.thickness = #3.0
        c8 c c
        \once  \override Score.GridLine.thickness = #4.0
        c8 c c
        \once  \override Score.GridLine.thickness = #3.0
        c8 c c
      }
    >>
  }
  \layout {
    \context {
      \Score
      \consists "Grid_line_span_engraver"
      % center grid lines horizontally below note heads
      \override NoteColumn.X-offset = #-0.5
    }
    \context {
      \Staff
      \consists "Grid_point_engraver"
      gridInterval = \musicLength 8
      % set line length and positioning:
      % two staff spaces above center line on hidden staff
      % to four spaces below center line on visible staff
      \override GridPoint.Y-extent = #'(2 . -4)
    }
    ragged-right = ##t
  }
}

[image of music]


Hammer on and pull off

Hammer-on and pull-off can be obtained using slurs.

\new TabStaff {
  \relative c' {
    d4( e\2)
    a( g)
  }
}

[image of music]


Hammer on and pull off using chords

When using hammer-on or pull-off with chorded notes, only a single arc is drawn. However “double arcs” are possible by setting the doubleSlurs property to #t.

\new TabStaff {
  \relative c' {
    % chord hammer-on and pull-off
    \set doubleSlurs = ##t
    <g' b>8( <a c> <g b>)
  }
}

[image of music]


Hammer on and pull off using voices

The arc of hammer-on and pull-off is upwards in voices one and three and downwards in voices two and four:

\new TabStaff {
  \relative c' {
    << { \voiceOne g2( a) }
    \\ { \voiceTwo a,( b) }
    >> \oneVoice
  }
}

[image of music]


Fer unes línies del pentagrama més gruixudes que les altres

Es pot fer una línia de pentagrama més gruixuda amb fins pedagògics (per exemple la tercera línia o la de la clau de sol). Això es pot aconseguir afegint més línies molt a prop de la línia que es vol destacar, utilitzant la propietat line-positions de l’objecte StaffSymbol.

{
  \override Staff.StaffSymbol.line-positions =
    #'(-4 -2 -0.2 0 0.2 2 4)
  d'4 e' f' g'
}

[image of music]


Marking notes of spoken parts with a cross on the stem (Sprechstimme)

This example shows how to put crosses on stems. Mark the beginning of a spoken section with the \speakOn keyword, and end it with the \speakOff keyword.

speakOn = {
  \override Stem.stencil =
    #(lambda (grob)
       (let* ((x-parent (ly:grob-parent grob X))
              (is-rest? (ly:grob? (ly:grob-object x-parent 'rest))))
         (if is-rest?
             empty-stencil
             (ly:stencil-combine-at-edge
              (ly:stem::print grob)
              Y
              (- (ly:grob-property grob 'direction))
              (grob-interpret-markup grob
                                     (markup #:center-align #:fontsize -4
                                             #:musicglyph "noteheads.s2cross"))
              -2.3))))
}

speakOff = {
  \revert Stem.stencil
  \revert Flag.stencil
}

\score {
  \new Staff {
    \relative c'' {
      a4 b a c
      \speakOn
      g4 f r g
      b4 r d e
      \speakOff
      c4 a g f
    }
  }
}

[image of music]


Comptador de compassos

Aquest fragment de codi proporciona una solució alternativa a la producció de comptadors de compàs utilitzant repeticions transparents de tipus percentatge.

<<
  \context Voice = "foo" {
    \clef bass
    c4 r g r
    c4 r g r
    c4 r g r
    c4 r g r
  }
  \context Voice = "foo" {
    \set countPercentRepeats = ##t
    \hide PercentRepeat
    \override PercentRepeatCounter.staff-padding = #1
    \repeat percent 4 { s1 }
  }
>>

[image of music]


Measure spanner

Measure spanners are an alternate way to print annotated brackets. As opposed to horizontal brackets, they extend between two bar lines rather than two notes. The text is displayed in the center of the bracket.

\paper { tagline = ##f }

\layout {
  \context {
    \Staff
    \consists Measure_spanner_engraver
  }
}

<<
  \new Staff \relative c'' {
    \key d \minor
    R1*2
    \tweak text "Answer"
    \startMeasureSpanner
    \tuplet 3/2 8 {
      a16[ b c] d[ c b]  c[ d e] f[ e d]
    }
    e8 a gis g
    fis f e d~ d c b e
    \stopMeasureSpanner
  }
  \new Staff \relative c' {
    \key d \minor
    \tweak text "Subject"
    \tweak direction #DOWN
    \startMeasureSpanner
    \tuplet 3/2 8 {
      d16[ e f] g[ f e] f[ g a] bes[ a g]
    }
    a8 d cis c
    b bes a g~ g f e a
    \stopMeasureSpanner
    \tweak text "Counter-subject"
    \tweak direction #DOWN
    \startMeasureSpanner
    f8 e a r r16 b, c d e fis g e
    a gis a b c fis, b a gis e a4 g8
    \stopMeasureSpanner
  }
>>

[image of music]


Numerar grups de compassos

Aquest fragment de codi mostra l’ús del gravador Measure_counter_engraver per numerar grups de compassos successius. Es pot numerar qualsevol període de compassos tant si té repeticions com si no.

S’ha d’afegir el gravador al context adequat. Aquí s’usa un context Staff; una altra possibilitat seria un context Dynamics.

El comptador s’inicia amb \startMeasureCount i finalitza amb \stopMeasureCount. La numeració comença amb 1, de forma predeterminada, però es pot modificar aquest comportament sobreescrivint la propietat count-from.

Quan un compàs s’estén més enllà d’un salt de línia, el número apareix dues vegades, la segona vegada entre parèntesi.

\layout {
  \context {
    \Staff
    \consists #Measure_counter_engraver
  }
}

\new Staff {
  \startMeasureCount
  \repeat unfold 7 {
    c'4 d' e' f'
  }
  \stopMeasureCount
  \bar "||"
  g'4 f' e' d'
  \override Staff.MeasureCounter.count-from = #2
  \startMeasureCount
  \repeat unfold 5 {
    g'4 f' e' d'
  }
  g'4 f'
  \bar ""
  \break
  e'4 d'
  \repeat unfold 7 {
    g'4 f' e' d'
  }
  \stopMeasureCount
}

\paper { tagline = ##f }

[image of music]


Posicionament precís d’indicacions de digitació

Generalment, les opcions disponibles per a la digitació dels acords funciona bé de forma predeterminada, però si una de les indicacions precisa col·locar-se de forma més exacta pot usar-se l’ajustament següent. Això és especialment útil per corregir el posicionat quan hi ha intervals de segona.

\relative c' {
  \set fingeringOrientations = #'(left)
  <c-1 d-2 a'-5>4
  <c-1 d-\tweak extra-offset #'(0 . 0.2)-2 a'-5>4
  \set fingeringOrientations = #'(down)
  <c-1 d-2 a'-5>4
  <c-\tweak extra-offset #'(0 . -1.1)-1
   d-\tweak extra-offset #'(-1.2 . -1.8)-2 a'-5>4
  \set fingeringOrientations = #'(down right up)
  <c-1 d-\tweak extra-offset #'(-0.3 . 0)-2 a'-5>4
  <c-1 d-\tweak extra-offset #'(-1 . 1.2)-2 a'-5>4
  \set fingeringOrientations = #'(up)
  <c-1 d-\tweak extra-offset #'(0 . 1.1)-2
   a'-\tweak extra-offset #'(0 . 1)-5>4
  <c-1 d-\tweak extra-offset #'(-1.2 . 1.5)-2
   a'-\tweak extra-offset #'(0 . 1.4)-5>4
}

[image of music]


Situar els elements de marcatge de text por dins de les lligadures

Els elements de marcatge de text han de tenir la propietat outside-staff-priority establerta al valor fals perquè s’imprimeixin per dins de les lligadures d’expressió.

\relative c'' {
  \override TextScript.avoid-slur = #'inside
  \override TextScript.outside-staff-priority = ##f
  c2(^\markup { \halign #-10 \natural } d4.) c8
}

[image of music]


Impressió de text de dreta a esquerra

És possible imprimir text de dreta a esquerra en un element de marcatge, com es mostra aquí.

{
  b1^\markup {
    \line { i n g i r u m i m u s n o c t e }
  }
  f'_\markup {
    \override #'(text-direction . -1)
    \line { i n g i r u m i m u s n o c t e }
  }
}

[image of music]


Línies d’extensió per a nombre de corda

Fem una línia extensora per a les indicacions de nombre de corda, mostrant que una sèrie de notes s’han de tocar sobre la mateixa corda.

stringNumberSpanner =
  #(define-music-function (StringNumber) (string?)
    #{
      \override TextSpanner.style = #'solid
      \override TextSpanner.font-size = #-5
      \override TextSpanner.bound-details.left.stencil-align-dir-y = #CENTER
      \override TextSpanner.bound-details.left.text =
        \markup { \circle \number $StringNumber }
    #})


\relative c {
  \clef "treble_8"
  \stringNumberSpanner "5"
  \textSpannerDown
  a8\startTextSpan
  b c d e f\stopTextSpan
  \stringNumberSpanner "4"
  g\startTextSpan a
  bes4 a g2\stopTextSpan
}

[image of music]


Ús del llenguatge PostSript per generar caps de nota de formes especials

Quan el cap d’una nota amb una forma especial no es pot generar fàcilment mitjançant elements de marcatge gràfic, es pot usar codi de Postscript per generar la forma. Aquest exemple mostra com es genera un cap en forma de paral·lelogram.

%% Updaters remark:
%% For unkown reasons this snippet returns a gs-error, but only, if compiled
%% with multiple others like: lilypond *.ly
%% Thus changing to a path-stencil.
%% TODO description needs to get adjusted  --harm

parallelogram =
  #(ly:make-stencil
    '(path 0.1
        (rmoveto 0 0.25
         lineto 1.3125 0.75
         lineto 1.3125 -0.25
         lineto 0 -0.75)
         round
         round
         #t)
    (cons 0 1.3125)
    (cons -.75 .75))

myNoteHeads = \override NoteHead.stencil = \parallelogram
normalNoteHeads = \revert NoteHead.stencil

\relative c'' {
  \myNoteHeads
  g4 d'
  \normalNoteHeads
  <f, \tweak stencil \parallelogram b e>4 d
}

[image of music]


Ús de la propietat whiteout

Es pot imprimir qualsevol objecte gràfic sobre un fons blanc per ocultar part dels objectes que estan a sota. Això pot ser útil per millorar l’aspecte de les col·lisions en situaciones complexes quan no es pràctic tornar a col·locar els objectes. Cal establir explícitament la propietat de capa (layer) per controlar quins objectes resulten ocultats pel fons blanc.

En aquest exemple, la col·lisió de la lligadura d’unió amb la indicació de compàs resulta millorada ocultant la part de la lligadura que creua la indicació de compàs mitjançant l’establiment de la propietat whiteout de TimeSignature. per fer això, es mou TimeSignature a una capa per sobre de Tie, que es deixa a la capa predeterminada d’1, i StaffSymbol es mou a una capa per sobre de TimeSignature de manera que no resulti ocultada.

{
  \override Score.StaffSymbol.layer = 4
  \override Staff.TimeSignature.layer = 3
  b'2 b'~
  \once \override Staff.TimeSignature.whiteout = ##t
  \time 3/4
  b' r4
}

[image of music]


Text

Text


[OBSOLETE] Adding a QR code

This snippet lets you draw a QR-code, for example to provide a link to the composer’s, or the music editor’s website.

Actually encoding the URL into a QR-code is not done here (this just draws the QR-code from a grid of "black" or "white" values), but see the code for a short Python snippet you can use to avoid having to fill for each small square if it’s black or white.

This snippet is obsolete starting from LilyPond 2.25.3, which adds a \qr-code markup command that takes a URL directly instead of a grid of "black" and "white" values. It is used like \markup \qr-code #10 "https://lilypond.org".

%% Original thread: https://lists.gnu.org/archive/html/lilypond-user-fr/2022-07/msg00005.html
%% (snippet author: Jean Abou Samra <jean@abou-samra.fr>)

\paper { tagline = ##f }

#(define (index-map f . lsts)
"Applies @code{f} to corresponding elements of @code{lists}, just as @code{map},
providing an additional counter starting at zero.  @code{f} needs to have the
counter in its arguments like @code{(index-map (lambda (i arg) <body>) lists)}"
   (let loop ((lsts lsts)
              (acc '())
              (i 0))
     (if (any null? lsts)
         (reverse! acc)
         (loop (map cdr lsts)
               (cons (apply f i (map car lsts))
                     acc)
               (1+ i)))))

#(define-markup-command (qr-code layout props data) (string?)
   #:properties ((width 10))
   (let* (;; Return lines in reversed order, since translating in Y-axis
          ;; uses increasing values. Meaning lines will be stacked upwards.
          (lines (reverse
                   (remove
                     string-null?
                     (map string-trim-both (string-split data #\newline)))))
          (n (length lines))
          (square-width (/ width n))
          (box (make-filled-box-stencil `(0 . ,square-width)
                                        `(0 . ,square-width))))

     ;; Build the final qr-code-stencil from line-stencils list
     (apply ly:stencil-add
            ;; Get a list of line-stencils
            (index-map
             (lambda (i line)
               ;; Build a line-stencil from square-stencils list
               (apply ly:stencil-add
                      ;; Get a list of (already translated) square-stencils
                      ;; per line
                      (index-map
                       (lambda (j char)
                         (ly:stencil-translate
                          (stencil-with-color
                           box
                           (case char
                            ((#\0)
                             white)
                            ((#\1)
                             black)
                            (else
                             (ly:warning
                               "unrecognized character ~a, should be 0 or 1"
                               char)
                             red)))
                          (cons (* j square-width)
                                (* i square-width))))
                      (string->list line))))
             lines))))


%{
A string representation of the QR code.  0 means white, 1 means black.
You can generate this automatically using Python and the pyqrcode module
("pip install pyqrcode").  Use this line of code in a Python prompt:

>>> import pyqrcode; print(pyqrcode.create("https://lilypond.org").text(quiet_zone=0))
%}

lilypondDotOrg =
"11111110011100011110101111111
10000010010000010111101000001
10111010010110001000101011101
10111010001010111101001011101
10111010110100000111001011101
10000010011100011001101000001
11111110101010101010101111111
00000000111000111110100000000
00110011101100001000111010000
10101001111000001000001111101
00110111010100000110001011010
01010001100110010111000110001
01111011110010011110010100111
01111101001101010001001101101
01111011000001000011001111011
11001001001011001000111011010
11100110111011011001110111000
00001100010001001011100100100
10111111011001010011001000100
00001100001000101011011011100
01010010000011000000111111111
00000000110011100010100011001
11111110101001101011101010110
10000010000110111110100010011
10111010011010111100111111111
10111010110001101111000011110
10111010100101101010100101001
10000010001001000100000010010
11111110010100110010111100010"

\markup \qr-code \lilypondDotOrg

\markup \vspace #5

\markup \override #'(width . 15) \qr-code \lilypondDotOrg

[image of music]


Adding markups in a tablature

By default markups does not show in a tablature.

To make them appear, simply use the command \revert TabStaff.TextScript.stencil

%% http://lsr.di.unimi.it/LSR/Item?id=919
% by P.P.Schneider on June 2014

high  = { r4 r8 <g c'> q r8 r4 }

low = { c4 r4 c8 r8 g,8 b, }

pulse = { s8^"1" s^"&" s^"2" s^"&" s^"3" s^"&" s^"4" s^"&" }

\score {
 \new TabStaff {
   \repeat unfold 2 << \high \\ \low \\ \pulse >>
  }
  \layout {
    \context {
      \TabStaff
      \clef moderntab
      \revert TextScript.stencil
      \override TextScript.font-series = #'bold
      \override TextScript.font-size = #-2
      \override TextScript.color = #red

    }
    \context {
      \Score
      proportionalNotationDuration = \musicLength 8
    }
  }
}

[image of music]


Afegir la data actual a una partitura

Amb quelcom de codi de l’Scheme, es pot afegir fàcilment la data actual a una partitura.

\paper { tagline = ##f }

% first, define a variable to hold the formatted date:
date = #(strftime "%d-%m-%Y" (localtime (current-time)))

% use it in the title block:
\header {
  title = "Including the date!"
  subtitle = \date
}

\score {
  \relative c'' {
    c4 c c c
  }
}
% and use it in a \markup block:
\markup {
  \date
}

[image of music]


Ajustament de l’espaiat vertical de la lletra

Aquest fragment de codi mostra com situar la línia de base de la lletra més a prop del pentagrama.

% Default layout:
<<
  \new Staff \new Voice = melody \relative c' {
    c4 d e f
    g4 f e d
    c1
  }
  \new Lyrics \lyricsto melody { aa aa aa aa aa aa aa aa aa }

  \new Staff {
    \new Voice = melody \relative c' {
      c4 d e f
      g4 f e d
      c1
    }
  }
  % Reducing the minimum space below the staff and above the lyrics:
  \new Lyrics \with {
    \override VerticalAxisGroup.nonstaff-relatedstaff-spacing =
      #'((basic-distance . 1))
  }
  \lyricsto melody { aa aa aa aa aa aa aa aa aa }
>>

[image of music]


Alinear i centrar els noms dels instruments

L’alineació horitzontal dels noms d’instruments es pot ajustar modificant la propietat Staff.InstrumentName #'self-alignment-X. Les variables de \layout, indent i short-indent defineixen l’espai en el qual s’alineen els noms d’instrument abans del primer sistema i dels següents, respectivament.

\paper { left-margin = 3\cm }

\score {
  \new StaffGroup <<

    \new Staff \with {
      \override InstrumentName.self-alignment-X = #LEFT
      instrumentName = \markup \left-column {
        "Left aligned"
        "instrument name"
        }
        shortInstrumentName = "Left"
      }

      {  c''1 \break c''1 }

    \new Staff \with {
      \override InstrumentName.self-alignment-X = #CENTER
      instrumentName = \markup \center-column {
        Centered
        "instrument name"
        }
      shortInstrumentName = "Centered"
    }

    { g'1 g'1}

    \new Staff \with {
      \override InstrumentName.self-alignment-X = #RIGHT
      instrumentName = \markup \right-column {
        "Right aligned"
        "instrument name"
      }
      shortInstrumentName = "Right"
    }

    { e'1 e'1 }

  >>

  \layout {
    ragged-right = ##t
    indent = 4\cm
    short-indent = 2\cm
  }
}

[image of music]


Alineació de síl·labes amb melisma

De forma predeterminada, les síl·labes de la lletra que comencen un melisma s’alineen a l’esquerra sobre la seva nota corresponent. Es pot alterar l’alineació usant la propietat lyricMelismaAlignment.

\score {
  <<
    \new Staff {
      \relative c''
      \new Voice = "vocal" {
        c d~^\markup default  d e
        c d~^\markup "right aligned" d e
        c d~^\markup "center aligned" d e
        c d~^\markup "reset to default" d e
      }
    }
    \new Lyrics \lyricsto "vocal" {
      word word word
      \set lyricMelismaAlignment = #RIGHT
      word word word
      \set lyricMelismaAlignment = #CENTER
      word word word
      \unset lyricMelismaAlignment
      word word word
    }
  >>
}

[image of music]


Posar en blanc les línies del utilitzant l’ordre \whiteout

L’ordre \whiteout intercala un rectangle blanc a sota d’un element de marcatge. Aquest rectangle blanc no tapa a cap altre objecte gràfic, atès que les línies del pentagrama estan en una capa inferior a la de la major part dels altres objectes.

\layout {
  ragged-right = ##f
}

\relative c' {
  \override TextScript.extra-offset = #'(2 . 4)
  c2-\markup { \whiteout \pad-markup #0.5 "middle C" } c
}

[image of music]


Centrar text a sota d’un regulador

Aquest exemple proporciona una funció per escriure un regulador amb text a sota, com “molto” o “poco”. El text afegit canvia la direcció d’acord amb la del regulador. L’objecte hairpin està alineat amb DynamicText.

L’exemple il·lustra també com modificar la manera en la qual s’imprimeix normalment un object, utilitzat codi de l’Scheme.

\paper { tagline = ##f }

hairpinWithCenteredText =
#(define-music-function (text) (markup?)
  #{
    \once \override Voice.Hairpin.after-line-breaking =
      #(lambda (grob)
        (let* ((stencil (ly:hairpin::print grob))
               (par-y (ly:grob-parent grob Y))
               (dir (ly:grob-property par-y 'direction))
               (staff-line-thickness
                 (ly:output-def-lookup (ly:grob-layout grob) 'line-thickness))
               (new-stencil (ly:stencil-aligned-to
                 (ly:stencil-combine-at-edge
                   (ly:stencil-aligned-to stencil X CENTER)
                   Y dir
                   (ly:stencil-aligned-to
                     (grob-interpret-markup
                       grob
                       (make-fontsize-markup
                         (magnification->font-size
                           (+ (ly:staff-symbol-staff-space grob)
                              (/ staff-line-thickness 2)))
                           text)) X CENTER))
                 X LEFT))
               (staff-space (ly:output-def-lookup
                 (ly:grob-layout grob) 'staff-space))
               (par-x (ly:grob-parent grob X))
               (dyn-text (grob::has-interface par-x 'dynamic-text-interface))
               (dyn-text-stencil-x-length
                 (if dyn-text
                   (interval-length
                     (ly:stencil-extent (ly:grob-property par-x 'stencil) X))
                   0))
               (x-shift
                 (if dyn-text
                   (-
                     (+ staff-space dyn-text-stencil-x-length)
                     (* 0.5 staff-line-thickness)) 0)))

        (ly:grob-set-property! grob 'Y-offset 0)
        (ly:grob-set-property! grob 'stencil
           (ly:stencil-translate-axis
            new-stencil
            x-shift X))))
  #})

hairpinMolto =
\hairpinWithCenteredText \markup { \italic molto }

hairpinMore =
\hairpinWithCenteredText \markup { \larger moltissimo }

\layout { ragged-right = ##f }

\relative c' {
  \hairpinMolto
  c2\< c\f
  \hairpinMore
  c2\ppppp\< c\f
  \break
  \hairpinMolto
  c2^\< c\f
  \hairpinMore
  c2\ppppp\< c\f
}

[image of music]


Changing ottava text

Internally, \ottava sets the properties ottavation (for example, to 8va or 8vb) and middleCPosition. To override the text of the bracket, set ottavation after invoking \ottava.

Short text is especially useful when a brief ottava is used.

{
  c'2
  \ottava 1
  \set Staff.ottavation = "8"
  c''2
  \ottava 0
  c'1
  \ottava 1
  \set Staff.ottavation = "Text"
  c''1
}

[image of music]


Canviar la família de tipus de lletra predeterminada per al text

Les famílies de tipus de lletra per al text es poden sobreescriure amb make-pango-font-tree.

%{
You may have to install additional fonts.

Red Hat Fedora

  dejavu-fonts-all

Debian GNU/Linux, Ubuntu

  fonts-dejavu-core
  fonts-dejavu-extra
%}

\paper {
  %{
     run
         lilypond -dshow-available-fonts
     to show all fonts available in the process log.
  %}
  property-defaults.fonts.serif = "DejaVu Serif"
  property-defaults.fonts.sans = "DejaVu Sans"
  property-defaults.fonts.typewriter = "DejaVu Sans Mono"
}

{
  g'''4^\markup {
    DejaVu Serif: \bold bold
                  \italic italic
                  \italic \bold { bold italic }
  }
  g4_\markup {
    \override #'(font-family . sans) {
      DejaVu Sans: \bold bold
                   \italic italic
                   \italic \bold { bold italic }
    }
  }
  g''2^\markup {
    \override #'(font-family . typewriter) {
      DejaVu Sans Mono: \bold bold
                        \italic italic
                        \italic \bold { bold italic }
    }
  }
}

[image of music]


Combinar indicacions dinàmiques amb marcatges textuals

Certes indicacions dinàmiques poden portar textos (com “più forte” o “piano subito”). Es poden produir usant un bloc \markup.

piuF = \markup { \italic più \dynamic f }

\layout { ragged-right = ##f }

\relative c'' {
  c2\f c-\piuF
}

[image of music]


Combinar dues parts sobre el mateix pentagrama

L’eina de combinació de parts (ordre \partcombine) permet la combinació de diverses parts diferents sobre el mateix pentagrama. Les indicacions textuals com ara “solo” o “a2” s’afegeixen de forma predeterminada; per treure-les, senzillament heu d’establir la propietat printPartCombineTexts al valor “fals”. Per a partitures vocals (com himnes), no cal afegir els textos “solo” o “a2”, per la qual cosa s’han de deshabilitar. No obstant, podria ser millor no usar-lo si hi ha solos, perquè no s’indicaran. En aquests casos podria ser preferible la notació polifònica estàndard.

Aquest fragment de codi presenta les tres formes en las quals es poden imprimir dues parts sobre un sol pentagrama: polifonia estàndard, \partcombine sense textos, i \partcombine amb texts.

musicUp = \relative c'' {
  \time 4/4
  a4 c4.( g8) a4 |
  g4 e' g,( a8 b) |
  c b a2.
}

musicDown = \relative c'' {
  g4 e4.( d8) c4 |
  r2 g'4( f8 e) |
  d2 \stemDown a
}

\score {
  <<
    \new Staff \with {
      instrumentName = "standard polyphony"
    } << \musicUp \\ \musicDown >>

    \new Staff \with {
      instrumentName =
        \markup { \typewriter "\\partCombine" without text}
      printPartCombineTexts = ##f
    } \partCombine \musicUp \musicDown

    \new Staff \with {
      instrumentName =
        \markup { \typewriter "\\partCombine" with text}
    } \partCombine \musicUp \musicDown
  >>

  \layout {
    indent = 6.0\cm
    \context {
      \Score
      % Setting this to a large value avoids a bar line at the
      % beginning that would connect the three staves otherwise.
      \override SystemStartBar.collapse-height = 30
    }
  }
}

[image of music]


Crear indicacions dinàmiques "vertaderes" entre parèntesis

Tot i que la manera més fàcil d’afegir parèntesis a una indicació de dinàmica és utilitzar un bloc \markup, aquest mètode té un inconvenient: els objectes que es creen es comportaran com elements de marcatge de text i no com indicacions dinàmiques.

No obstant, és possible crear un objecte utilitzant el codi de l’Scheme equivalent (com s’explica a la Referència de la notació), en combinació amb la funció make-dynamic-script. D’aquesta forma l’element de marcatge es tractarà com una indicació dinàmica, i per tant seguirà sent compatible amb ordre com ara \dynamicUp o \dynamicDown.

paren =
#(define-event-function (dyn) (ly:event?)
   (make-dynamic-script
    #{ \markup \concat {
         \normal-text \italic \fontsize #2 (
	 \pad-x #0.2 #(ly:music-property dyn 'text)
	 \normal-text \italic \fontsize #2 )
       }
    #}))

\relative c'' {
  c4\paren\f c c \dynamicUp c\paren\p
}

[image of music]


Crear elements de extensió textuals

Les ordres \startTextSpan i \stopTextSpan permeten la creació d’elements d’extensió textuals tan fàcilment com indicacions de pedal o octavacions. Sobreescrivim certes propietats de l’object TextSpanner per modificar la seva sortida.

\paper { ragged-right = ##f }

\relative c'' {
  \override TextSpanner.bound-details.left.text = #"bla"
  \override TextSpanner.bound-details.right.text = #"blu"
  a4 \startTextSpan
  b4 c
  a4 \stopTextSpan

  \override TextSpanner.style = #'line
  \once \override TextSpanner.bound-details.left.stencil-align-dir-y = #CENTER
  a4 \startTextSpan
  b4 c
  a4 \stopTextSpan

  \override TextSpanner.style = #'dashed-line
  \override TextSpanner.bound-details.left.text =
    \markup { \draw-line #'(0 . 1) }
  \override TextSpanner.bound-details.right.text =
    \markup { \draw-line #'(0 . -2) }
  \once \override TextSpanner.bound-details.right.padding = #-2

  a4 \startTextSpan
  b4 c
  a4 \stopTextSpan

  \set Staff.middleCPosition = #-13
  \override TextSpanner.dash-period = #10
  \override TextSpanner.dash-fraction = #0.5
  \override TextSpanner.thickness = #10
  a4 \startTextSpan
  b4 c
  a4 \stopTextSpan
}

[image of music]


Mostra de cadascú dels encapçalaments possibles

Mostra de tots els tipus d’encapçalament.

\header {
  copyright = "copyright"
  title = "title"
  subtitle = "subtitle"
  composer = "composer"
  arranger = "arranger"
  instrument = "instrument"
  meter = "meter"
  opus = "opus"
  piece = "piece"
  poet = "poet"
  texidoc = "All header fields with special meanings."
  copyright = "public domain"
  enteredby = "jcn"
  source = "urtext"
}

\layout {
  ragged-right = ##f
}

\score {
  \relative c'' { c1 | c | c | c }
}

\score {
   \relative c'' { c1 | c | c | c }
   \header {
     title = "localtitle"
     subtitle = "localsubtitle"
     composer = "localcomposer"
     arranger = "localarranger"
     instrument = "localinstrument"
     metre = "localmetre"
     opus = "localopus"
     piece = "localpiece"
     poet = "localpoet"
     copyright = "localcopyright"
   }
}

[image of music]


Inserir PostScript nadiu dins d’un bloc \markup

Es pot inserir codi PostScript directament dins d’un bloc \markup.

% PostScript is a registered trademark of Adobe Systems Inc.

\relative c'' {
  a4-\markup { \postscript "3 4 moveto 5 3 rlineto stroke" }
  -\markup { \postscript "[ 0 1 ] 0 setdash 3 5 moveto 5 -3 rlineto stroke " }

  b4-\markup { \postscript "3 4 moveto 0 0 1 2 8 4 20 3.5 rcurveto stroke" }
  s2
  a'1
}

[image of music]


Donar format a síl·labes de la lletra

És possible usar el mode de marcatge per donar format a síl·labes individualment dins de la lletra.

mel = \relative c'' { c4 c c c }
lyr = \lyricmode {
  Lyrics \markup { \italic can } \markup { \with-color #red contain }
  \markup { \fontsize #8 \bold Markup! }
}

<<
  \new Voice = melody \mel
  \new Lyrics \lyricsto melody \lyr
>>

[image of music]


Com posar lligadures entre síl·labes de la lletra

Es pot fer separant les síl·labes mitjançant símbols de titlle corb.

\lyrics {
  wa~o~a
}

[image of music]


Alineació de la lletra

L’alineació horitzontal de la lletra es pot ajustar sobreescrivint la propietat self-alignment-X de l’objecte LyricText. #-1 és esquerra, #0 és centrat #1 es dreta; tanmateix, podem usar també #LEFT, #CENTER i #RIGHT.

\layout { ragged-right = ##f }

\relative c'' {
  c1
  c1
  c1
}
\addlyrics {
  \once \override LyricText.self-alignment-X = #LEFT
  "This is left-aligned"
  \once \override LyricText.self-alignment-X = #CENTER
  "This is centered"
  \once \override LyricText.self-alignment-X = 1
  "This is right-aligned"
}

[image of music]


Markup list

Text that can spread over pages is entered with the \markuplist command.

%% updated/modified by P.P.Schneider on Feb. 2014

\paper { tagline = ##f }

#(set-default-paper-size "a6")

#(define-markup-list-command (paragraph layout props args) (markup-list?)
  (interpret-markup-list layout props
   (make-justified-lines-markup-list (cons (make-hspace-markup 2) args))))

% Candide, Voltaire
\markuplist {
  \override-lines #'(baseline-skip . 2.5) {
    \paragraph {
      Il y avait en Westphalie, dans le château de M. le baron de
      Thunder-ten-tronckh, un jeune garçon à qui la nature avait donné
      les mœurs les plus douces.  Sa physionomie annonçait son âme.
      Il avait le jugement assez droit, avec l'esprit le plus
      \concat { simple \hspace #.3 ; }
      c'est, je crois, pour cette raison qu'on le nommait Candide.  Les
      anciens domestiques de la maison soupçonnaient qu'il était fils
      de la sœur de monsieur le baron et d'un bon et honnête
      gentilhomme du voisinage, que cette demoiselle ne voulut jamais
      épouser parce qu'il n'avait pu prouver que soixante et onze
      quartiers, et que le reste de son arbre généalogique avait été
      perdu par l'injure du temps.
    }
    \vspace #.3
    \paragraph {
      Monsieur le baron était un des plus puissants seigneurs de la
      Westphalie, car son château avait une porte et des fenêtres.  Sa
      grande salle même était ornée d'une tapisserie.  Tous les chiens
      de ses basses-cours composaient une meute dans le
      \concat { besoin \hspace #.3 ; }
      ses palefreniers étaient ses
      \concat { piqueurs \hspace #.3 ; }
      le vicaire du village était
      son grand-aumônier.  Ils l'appelaient tous monseigneur, et ils
      riaient quand il faisait des contes.
    }
  }
}

[image of music]


Marcatge de silencis multicompàs

Els elements de marcatge aplicats a un silenci multicompàs se centren a sobre o a sota del silenci. Els elements de marcatge extensos que s’adjunten a silencis multicompàs no produeixen l’expansió del comàs. Per expandir un silenci multicompàs de forma que càpiga tot el marcatge, utilitzeu un acord buit amb un marcatge aplicat abans del silenci multicompàs.

El text aplicat a un silenci separador d’aquesta forma s’alinea per l’esquerra a la posició en la qual la nota estaria situada dins del compàs, però si la longitud del compàs està determinada per la longitud del text, el text apareixerà centrat.

\relative c' {
  \compressMMRests {
    \textLengthOn
    <>^\markup { [MAJOR GENERAL] }
    R1*19
    <>_\markup { \italic { Cue: ... it is yours } }
    <>^\markup { A }
    R1*30^\markup { [MABEL] }
    \textLengthOff
    c4^\markup { CHORUS } d f c
  }
}

[image of music]


Of the ubiquity of markup objects

Text objects are entered either as simple strings between double quotes or as \markup blocks that can accept a variety of advanced text formatting and graphical enhancements.

As such, markup blocks may be used:

\markup may additionally be used for lyrics, in chord names, and as dynamics. In fact, it is possible to use \markup to customize the appearance of virtually any object, as demonstrated in this example using various methods.

%% Thanks to Aaron Hill https://lists.gnu.org/archive/html/lilypond-user/2019-01/msg00437.html

\paper {
  paper-width = 8\cm paper-height = 8\cm
}

\header {
  title = \markup "Header"
  tagline = \markup "(tagline)"
}

\markup "Top-level markup"

dyn = #(make-dynamic-script #{ \markup \serif "DynamicText" #})

\score {
  <<
    \new ChordNames
    \with { majorSevenSymbol = \markup "majorSevenSymbol" }
    \chordmode { c1:maj7 }
    \new Staff {
      \tempo \markup "MetronomeMark"
      \textMark "TextMark"
      \once \override TupletNumber.text = \markup "TupletNumber"
      \tuplet 3/2 {
        \once \override NoteHead.stencil = #ly:text-interface::print
        \once \override NoteHead.text = \markup \lower #0.5 "NoteHead"
        c''8^\markup "TextScript"
        \once \override Rest.stencil = #(lambda (grob)
          (grob-interpret-markup grob #{
            \markup  "Rest"
            #}))
        r4
      }
    }
    \new Lyrics \lyricmode { \markup "LyricText" 1 }
    \new Dynamics { s1\dyn }
  >>
}

[image of music]


Imprimir el número de versió

Introduint la sortida de lilypond-version en la lletra d’una cançó, és possible imprimir el número de versió del LilyPond dins d’una partitura, o en un document generat amb lilypond-book. Una altra possibilitat és afegir el número de versió al final de la doc-string, d’aquesta forma:

\markup { Processed with LilyPond version #(lilypond-version) }

[image of music]


Plantilla de piano amb lletra centrada

En comptes de tenir un pentagrama dedicat a la melodia i la lletra, la lletra es pot centrar entre els pentagrames d’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 { }
}

[image of music]


Printing bar numbers with changing regular intervals

Using the set-bar-number-visibility context function, bar number intervals can be changed.

\relative c' {
  \override Score.BarNumber.break-visibility = #end-of-line-invisible
  \context Score \applyContext #(set-bar-number-visibility 4)
  \repeat unfold 10 c'1
  \context Score \applyContext #(set-bar-number-visibility 2)
  \repeat unfold 10 c
}

\paper { tagline = ##f }

[image of music]


Impressió de marques d’assaig en qualsevol pentagrama

Tot i que normalment les marques d’assaig textuals sols s’imprimeixen sobre el pentagrama superior, també es poden imprimir en un altra pentagrama qualsevol.

\score {
  <<
    \new Staff { \mark \default c''1 \textMark "molto" c'' }
    \new Staff { \mark \default c'1 \textMark "molto" c' }
  >>
  \layout {
    \context {
      \Score
      \remove Mark_engraver
      \remove Text_mark_engraver
      \remove Staff_collecting_engraver
    }
    \context {
      \Staff
      \consists Mark_engraver
      \consists Text_mark_engraver
      \consists Staff_collecting_engraver
    }
  }
}

[image of music]


Impressió de text de dreta a esquerra

És possible imprimir text de dreta a esquerra en un element de marcatge, com es mostra aquí.

{
  b1^\markup {
    \line { i n g i r u m i m u s n o c t e }
  }
  f'_\markup {
    \override #'(text-direction . -1)
    \line { i n g i r u m i m u s n o c t e }
  }
}

[image of music]


Posar lletra dins del pentagrama

Es poden moure les línies de lletra verticalment per imprimir-les dins del pentagrama. Les lletres es mouen amb \override LyricText.extra-offset = #'(0 . dy) i hi ha instruccions per moure les línies d’extensió i els guions. El desplaçament necessari s’estableix mitjançant un procés d’assaig i error.

<<
  \new Staff <<
    \new Voice = "voc" \relative c' { \stemDown a bes c8 b c4 }
  >>
  \new Lyrics \with {
    \override LyricText.extra-offset = #'(0 . 8.6)
    \override LyricExtender.extra-offset = #'(0 . 8.6)
    \override LyricHyphen.extra-offset = #'(0 . 8.6)
  } \lyricsto "voc" { La la -- la __ _ la }
>>

[image of music]


Element de marcatge de text independent en dues columnes

Els textos independents es poden disposar en diverses columnes utilitzant ordres \markup:

\markup {
  \fill-line {
    \hspace #1
    \column {
      \line { O sacrum convivium }
      \line { in quo Christus sumitur, }
      \line { recolitur memoria passionis ejus, }
      \line { mens impletur gratia, }
      \line { futurae gloriae nobis pignus datur. }
      \line { Amen. }
    }
    \hspace #2
    \column \italic {
      \line { O sacred feast }
      \line { in which Christ is received, }
      \line { the memory of His Passion is renewed, }
      \line { the mind is filled with grace, }
      \line { and a pledge of future glory is given to us. }
      \line { Amen. }
    }
    \hspace #1
  }
}

[image of music]


Línies d’extensió per a nombre de corda

Fem una línia extensora per a les indicacions de nombre de corda, mostrant que una sèrie de notes s’han de tocar sobre la mateixa corda.

stringNumberSpanner =
  #(define-music-function (StringNumber) (string?)
    #{
      \override TextSpanner.style = #'solid
      \override TextSpanner.font-size = #-5
      \override TextSpanner.bound-details.left.stencil-align-dir-y = #CENTER
      \override TextSpanner.bound-details.left.text =
        \markup { \circle \number $StringNumber }
    #})


\relative c {
  \clef "treble_8"
  \stringNumberSpanner "5"
  \textSpannerDown
  a8\startTextSpan
  b c d e f\stopTextSpan
  \stringNumberSpanner "4"
  g\startTextSpan a
  bes4 a g2\stopTextSpan
}

[image of music]


Rectangle de tres segments visibles

Aquest exemple mostra com afegir una ordre de marcatge per obtenir un rectangle de tres segments visibles rodejant un element de text (o un altre element de marcatge).

% New command to add a three sided box, with sides north, west and south
% Based on the box-stencil command defined in scm/stencil.scm
% Note that ";;" is used to comment a line in Scheme
#(define-public (NWS-box-stencil stencil thickness padding)
   "Add a box around STENCIL, producing a new stencil."
   (let* ((x-ext (interval-widen (ly:stencil-extent stencil X) padding))
          (y-ext (interval-widen (ly:stencil-extent stencil Y) padding))
          (y-rule (make-filled-box-stencil (cons 0 thickness) y-ext))
          (x-rule (make-filled-box-stencil
                   (interval-widen x-ext thickness) (cons 0 thickness))))
     ;; (set! stencil (ly:stencil-combine-at-edge stencil X 1 y-rule padding))
     (set! stencil (ly:stencil-combine-at-edge stencil X LEFT y-rule padding))
     (set! stencil (ly:stencil-combine-at-edge stencil Y UP x-rule 0.0))
     (set! stencil (ly:stencil-combine-at-edge stencil Y DOWN x-rule 0.0))
     stencil))

% The corresponding markup command, based on the \box command defined
% in scm/define-markup-commands.scm
#(define-markup-command (NWS-box layout props arg) (markup?)
   #:properties ((thickness 0.1) (font-size 0) (box-padding 0.2))
   "Draw a box round @var{arg}.  Looks at @code{thickness},
@code{box-padding} and @code{font-size} properties to determine line
thickness and padding around the markup."
   (let ((pad (* (magstep font-size) box-padding))
         (m (interpret-markup layout props arg)))
     (NWS-box-stencil m thickness pad)))

% Test it:

\relative c' {
  c1^\markup { \NWS-box ABCD }
  c1^\markup { \NWS-box \note {4} #1.0 }
}

[image of music]


UTF-8

Es poden usar diversos sistemes d’escriptura per a textos (com ara títols o la lletra de les cançons) si s’introdueixen amb la codificació UTF-8, i utilitzant un motor basat en el Pango. Depenent dels tipus de lletra instal·lats, aquest fragment compon textos en búlgar (ciríl·lic), hebreu, japonès i portuguès.

%{
You may have to install additional fonts.

Red Hat Fedora

  linux-libertine-fonts (Latin, Cyrillic, Hebrew)
  google-noto-serif-jp-fonts (Japanese)

Debian GNU/Linux, Ubuntu

  fonts-linuxlibertine (Latin, Cyrillic, Hebrew)
  fonts-noto-cjk (Japanese)
%}

% 'Linux Libertine' fonts also contain Cyrillic and Hebrew glyphs.
\paper {
  property-defaults.fonts.serif =
    "Linux Libertine O, Noto Serif CJK JP, Noto Serif JP"
}

bulgarian = \lyricmode {
  Жълтата дюля беше щастлива, че пухът, който цъфна, замръзна като гьон.
}

hebrew = \lyricmode {
  זה כיף סתם לשמוע איך תנצח קרפד עץ טוב בגן.
}

japanese = \lyricmode {
  いろはにほへど ちりぬるを
  わがよたれぞ  つねならむ
  うゐのおくや  まけふこえて
  あさきゆめみじ ゑひもせず
}

% "a nice song for you"
portuguese = \lyricmode {
  à vo --  uma can -- ção le -- gal
}

\relative c' {
  c2 d
  e2 f
  g2 f
  e2 d
}
\addlyrics { \bulgarian }
\addlyrics { \hebrew }
\addlyrics { \japanese }
\addlyrics { \portuguese }

[image of music]


Plantilla per a conjunt amb lletres alineades a sobre i a sota dels pentagrames

Aquesta plantilla és, bàsicament, la mateixa que la senzilla plantilla “Conjunt vocal”, excepte que aquí totes les línies de lletra es col·loquen utilitzant alignAboveContext i 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
  >>
}

[image of music]


Elements de marcatge per al text de les caselles de repetició usant repeatCommands

Tot i que les caselles de repetició s’especifiquen de forma òptima usant \repeat volta, s’ha d’usar la propietat de context repeatCommands en cas que el text de la casella requereixi un format més avançat amb \markup.

Atès que repeatCommands admet una llista, el mètode més senzill d’incloure elements de marcatge és usar un identificador per al text i inserir-lo a la llista d’ordres usant la sintaxi de l’Scheme #(list (list 'volta textIdentifier)). Les ordres de principi i fi de repetició es poden afegir com elements de llista independents:

voltaAdLib = \markup { \volta-number { 1. 2. 3... } \italic { ad lib. } }

\relative c'' {
  c1
  \set Score.repeatCommands = #(list (list 'volta voltaAdLib) 'start-repeat)
  c4 b d e
  \set Score.repeatCommands = #'((volta #f) (volta "4.") end-repeat)
  f1
  \set Score.repeatCommands = #'((volta #f))
}

[image of music]


Vocal music

Vocal music


Afegir un àmbit per veu

Es pot afegir un àmbit per cada veu. En aquest cas, l’àmbit s’ha de desplaçar manualment per evitar col·lisions.

\new Staff <<
  \new Voice \with {
    \consists "Ambitus_engraver"
  } \relative c'' {
    \override Ambitus.X-offset = 2.0
    \voiceOne
    c4 a d e
    f1
  }
  \new Voice \with {
    \consists "Ambitus_engraver"
  } \relative c' {
    \voiceTwo
    es4 f g as
    b1
  }
>>

[image of music]


Afegir indicadors als pentagrames que es divideixen després d’un salt de línia

Aquest fragment de codi defineix les ordres \splitStaffBarLine, convUpStaffBarLine i convDownStaffBarLine, que afegeix una fletxa doble a l’últim compàs d’un pentagrama, indicant que les diverses veus disposaran d’un pentagrama propi a la línia següent.

#(define-markup-command (arrow-at-angle layout props angle-deg length fill)
   (number? number? boolean?)
   (let* (
           (PI-OVER-180 (/ (atan 1 1) 34))
           (degrees->radians (lambda (degrees) (* degrees PI-OVER-180)))
           (angle-rad (degrees->radians angle-deg))
           (target-x (* length (cos angle-rad)))
           (target-y (* length (sin angle-rad))))
     (interpret-markup layout props
       (markup
        #:translate (cons (/ target-x 2) (/ target-y 2))
        #:rotate angle-deg
        #:translate (cons (/ length -2) 0)
        #:concat (#:draw-line (cons length 0)
                   #:arrow-head X RIGHT fill)))))


splitStaffBarLineMarkup = \markup \with-dimensions #'(0 . 0) #'(0 . 0) {
  \combine
  \arrow-at-angle #45 #(sqrt 8) ##t
  \arrow-at-angle #-45 #(sqrt 8) ##t
}

splitStaffBarLine = {
  \once \override Staff.BarLine.stencil =
  #(lambda (grob)
     (ly:stencil-combine-at-edge
      (ly:bar-line::print grob)
      X RIGHT
      (grob-interpret-markup grob splitStaffBarLineMarkup)
      0))
  \break
}

convDownStaffBarLine = {
  \once \override Staff.BarLine.stencil =
  #(lambda (grob)
     (ly:stencil-combine-at-edge
      (ly:bar-line::print grob)
      X RIGHT
      (grob-interpret-markup grob #{
        \markup\with-dimensions #'(0 . 0) #'(0 . 0) {
          \translate #'(0 . -.13)\arrow-at-angle #-45 #(sqrt 8) ##t
        }#})
      0))
  \break
}

convUpStaffBarLine = {
  \once \override Staff.BarLine.stencil =
  #(lambda (grob)
     (ly:stencil-combine-at-edge
      (ly:bar-line::print grob)
      X RIGHT
      (grob-interpret-markup grob #{
        \markup\with-dimensions #'(0 . 0) #'(0 . 0) {
          \translate #'(0 . .14)\arrow-at-angle #45 #(sqrt 8) ##t
        }#})
      0))
  \break
}


\header { tagline = ##f }

\paper {
  ragged-right = ##t
  short-indent = 10\mm
}

separateSopranos = {
  \set Staff.instrumentName = "AI AII"
  \set Staff.shortInstrumentName = "AI AII"
  \splitStaffBarLine
  \change Staff = "up"
}
convSopranos = {
  \convDownStaffBarLine
  \change Staff = "shared"
  \set Staff.instrumentName = "S A"
  \set Staff.shortInstrumentName = "S A"
}

sI = {
  \voiceOne
  \repeat unfold 4 f''2
  \separateSopranos
  \repeat unfold 4 g''2
  \convSopranos
  \repeat unfold 4 c''2
}
sII = {
  s1*2
  \voiceTwo
  \change Staff = "up"
  \repeat unfold 4 d''2
}
aI = {
  \voiceTwo
  \repeat unfold 4 a'2
  \voiceOne
  \repeat unfold 4 b'2
  \convUpStaffBarLine
  \voiceTwo
  \repeat unfold 4 g'2
}
aII = {
  s1*2
  \voiceTwo
  \repeat unfold 4 g'2
}
ten = {
  \voiceOne
  \repeat unfold 4 c'2
  \repeat unfold 4 d'2
  \repeat unfold 4 c'2
}
bas = {
  \voiceTwo
  \repeat unfold 4 f2
  \repeat unfold 4 g2
  \repeat unfold 4 c2
}

\score {
  <<
    \new ChoirStaff <<
      \new Staff = up \with {
        instrumentName = "SI SII"
        shortInstrumentName = "SI SII"
      } {
        s1*4
      }

      \new Staff = shared \with {
        instrumentName = "S A"
        shortInstrumentName = "S A"
      } <<
        \new Voice = sopI \sI
        \new Voice = sopII \sII
        \new Voice = altI \aI
        \new Voice = altII \aII
      >>
      \new Lyrics \with {
        alignBelowContext = up
      }
      \lyricsto sopII { e f g h }
      \new Lyrics \lyricsto altI { a b c d e f g h i j k l }

      \new Staff = men \with {
        instrumentName = "T B"
        shortInstrumentName = "T B"
      } <<
        \clef F
        \new Voice = ten \ten
        \new Voice = bas \bas
      >>
      \new Lyrics \lyricsto bas { a b c d e f g h i j k l }
    >>
  >>
  \layout {
    \context {
      \Staff \RemoveEmptyStaves
      \override VerticalAxisGroup.remove-first = ##t
    }
  }
}

[image of music]


Afegir notes guia orquestrals a una partitura vocal

Aquest exemple mostra una forma de simplificar l’addició de moltes notes guia orquestrals a la reducció de piano a una partitura vocal. La funció musical \cueWhile agafa quatre arguments: la música de la qual es pren la citació, com ve definida per \addQuote, el nom a inserir abans de la notes guia, i després #UP o #DOWN per especificar \voiceOne amb el nom a sobre del pentagrama o bé \voiceTwo amb el nom a sota del pentagrama, i finalment la música de piano amb la qual les notes guia han d’aparèixer en paral·lel. El nom de l’instrument citat es posiciona a l’esquerra de les notes guia. Es poden citar molts passatges com a guia, però no es poden superposar en el temps entre ells.

cueWhile =
#(define-music-function
   (instrument name dir music)
   (string? string? ly:dir? ly:music?)
   #{
     \cueDuring $instrument #dir {
       \once \override TextScript.self-alignment-X = #RIGHT
       \once \override TextScript.direction = $dir
       <>-\markup { \tiny #name }
       $music
     }
   #})

flute = \relative c'' {
  \transposition c'
  s4 s4 e g
}
\addQuote "flute" { \flute }

clarinet = \relative c' {
  \transposition bes
  fis4 d d c
}
\addQuote "clarinet" { \clarinet }

singer = \relative c'' { c4. g8 g4 bes4 }
words = \lyricmode { here's the lyr -- ics }

pianoRH = \relative c'' {
  \transposition c'
  \cueWhile "clarinet" "Clar." #DOWN { c4. g8 }
  \cueWhile "flute" "Flute" #UP { g4 bes4 }
}
pianoLH = \relative c { c4 <c' e> e, <g c> }

\score {
  <<
    \new Staff {
      \new Voice = "singer" {
        \singer
      }
    }
    \new Lyrics {
      \lyricsto "singer"
      \words
    }
    \new PianoStaff <<
      \new Staff {
        \new Voice {
          \pianoRH
        }
      }
      \new Staff {
        \clef "bass"
        \pianoLH
      }
    >>
  >>
}

[image of music]


Ajustament de l’espaiat vertical de la lletra

Aquest fragment de codi mostra com situar la línia de base de la lletra més a prop del pentagrama.

% Default layout:
<<
  \new Staff \new Voice = melody \relative c' {
    c4 d e f
    g4 f e d
    c1
  }
  \new Lyrics \lyricsto melody { aa aa aa aa aa aa aa aa aa }

  \new Staff {
    \new Voice = melody \relative c' {
      c4 d e f
      g4 f e d
      c1
    }
  }
  % Reducing the minimum space below the staff and above the lyrics:
  \new Lyrics \with {
    \override VerticalAxisGroup.nonstaff-relatedstaff-spacing =
      #'((basic-distance . 1))
  }
  \lyricsto melody { aa aa aa aa aa aa aa aa aa }
>>

[image of music]


Alineació de síl·labes amb melisma

De forma predeterminada, les síl·labes de la lletra que comencen un melisma s’alineen a l’esquerra sobre la seva nota corresponent. Es pot alterar l’alineació usant la propietat lyricMelismaAlignment.

\score {
  <<
    \new Staff {
      \relative c''
      \new Voice = "vocal" {
        c d~^\markup default  d e
        c d~^\markup "right aligned" d e
        c d~^\markup "center aligned" d e
        c d~^\markup "reset to default" d e
      }
    }
    \new Lyrics \lyricsto "vocal" {
      word word word
      \set lyricMelismaAlignment = #RIGHT
      word word word
      \set lyricMelismaAlignment = #CENTER
      word word word
      \unset lyricMelismaAlignment
      word word word
    }
  >>
}

[image of music]


Indicacions de tessitura

Les indicacions d’àmbit o tessitura indiquen rangs d’altures per a les veus.

Les alteracions accidentals sols es mostren si no formen part de l’armadura de tonalitat. Els objectes gràfics AmbitusNoteHead també tenen línies addicionals.

\layout {
  \context {
    \Voice
    \consists "Ambitus_engraver"
  }
}

<<
  \new Staff {
    \relative c' {
      \time 2/4
      c4 f'
    }
  }
  \new Staff {
    \relative c' {
      \time  2/4
      \key d \major
      cis4 as'
    }
  }
>>

[image of music]


Ambitus after key signature

By default, ambitus are positioned at the left of the clef. The \ambitusAfter function allows for changing this placement. Syntax is \ambitusAfter grob-interface (see Graphical Object Interfaces for a list of possible values for grob-interface.)

A common use case is printing the ambitus between key signature and time signature.

\new Staff \with {
  \consists Ambitus_engraver
} \relative {
  \ambitusAfter key-signature
  \key d \major
  es'8 g bes cis d2
}

[image of music]


Àmbits amb diverses veus

L’addició del gravador Ambitus_engraver al context de Staff crea un sol àmbit per pentagrama, fins i tot en el cas de pentagrames amb diverses veus.

\new Staff \with {
  \consists "Ambitus_engraver"
  }
<<
  \new Voice \relative c'' {
    \voiceOne
    c4 a d e
    f1
  }
  \new Voice \relative c' {
    \voiceTwo
    es4 f g as
    b1
  }
>>

[image of music]


Plantilla per a notació de música antiga (transcripció moderna de cant gregorià)

Aquest exemple mostra com fer una transcripció moderna de cant gregorià. El cant gregorià no té compàs ni pliques; utilitza sols caps de nota de blanca i de negra, i unes marques especials que indiquen silencis de diferents longituds.

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 GregorianTranscriptionStaff <<
    \new GregorianTranscriptionVoice = "melody" \chant
    \new GregorianTranscriptionLyrics = "one" \lyricsto melody \verba
  >>
}

[image of music]


Plantilla de salm del cant anglicà

Aquesta plantilla mostra una forma de preparar un càntic salmòdic anglicà. També mostra com es poden afegir estrofes addicionals com text independent per sota de la música. Les dues estrofes es codifiquen en estils diferents per il·lustrar més possibilitats.

\paper { tagline = ##f }

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 =
                      \musicLength 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.
        }
      }
    }
  }
}

[image of music]


Arranging separate lyrics on a single line

Sometimes you may want to put lyrics for different performers on a single line: where there is rapidly alternating text, for example. This snippet shows how this can be done with \override VerticalAxisGroup.nonstaff-nonstaff-spacing.minimum-distance = ##f.

\header { tagline = ##f }

\layout {
  \context {
    \Lyrics
    \override VerticalAxisGroup
              .nonstaff-nonstaff-spacing
              .minimum-distance = ##f
  }
}

aliceSings = \markup { \smallCaps "Alice" }
eveSings = \markup { \smallCaps "Eve" }

<<
  \new Staff <<
    \new Voice = "alice" {
      f'4^\aliceSings g' r2 |
      s1 |
      f'4^\aliceSings g' r2 |
      s1 | \break
      % ...

      \voiceOne
      s2 a'8^\aliceSings a' b'4 |
      \oneVoice
      g'1
    }
    \new Voice = "eve" {
      s1 |
      a'2^\eveSings g' |
      s1 |
      a'2^\eveSings g'
      % ...

      \voiceTwo
      f'4^\eveSings a'8 g' f'4 e' |
      \oneVoice
      s1
    }
  >>
  \new Lyrics \lyricsto "alice" {
    may -- be
    sec -- ond
    % ...
    Shut up, you fool!
  }
  \new Lyrics \lyricsto "eve" {
    that the
    words are
    % ...
    …and then I was like–
  }
>>

[image of music]


Modificar el tipus de lletra per a cada estrofa

Es poden canviar els tipus de lletra de forma independent per a cada estrofa, inclosa la font que s’usa per imprimir el número d’estrofa.

%{
You may have to install additional fonts.

Red Hat Fedora

  dejavu-fonts-all

Debian GNU/Linux, Ubuntu

  fonts-dejavu-core
  fonts-dejavu-extra
%}

\relative c'' {
  \time 3/4
  g2 e4
  a2 f4
  g2.
}
\addlyrics {
  \set stanza = #"1. "
  Hi, my name is Bert.
}
\addlyrics {
  \override StanzaNumber.fonts.serif = "DejaVu Sans"
  \set stanza = #"2. "
  \override LyricText.font-family = #'typewriter
  Oh, ché -- ri, je t'aime
}

[image of music]


Notació de responsos o salms

Aquest tipus de notació s’utilitza per als cants salmòdics, en les quals les estrofes no sempre tenen la mateixa longitud.

stemOff = \hide Staff.Stem
stemOn  = \undo \stemOff

\score {
  \new Staff \with { \remove "Time_signature_engraver" }
  {
    \key g \minor
    \cadenzaOn
    \stemOff a'\breve bes'4 g'4
    \stemOn a'2 \section
    \stemOff a'\breve g'4 a'4
    \stemOn f'2 \section
    \stemOff a'\breve^\markup { \italic flexe }
    \stemOn g'2 \fine
  }
}

[image of music]


Forçar la visibilitat dels guions separadors de síl·labes

Si el LilyPond considera que no hi ha lloc suficient per a un guionet separador de síl·labes, l’ometrà. Es pot sobreescriure aquest comportament amb la propietat minimum-distance de LyricHyphen.

\relative c'' {
  c32 c c c
  c32 c c c
  c32 c c c
  c32 c c c
}
\addlyrics {
  syl -- lab word word
  \override LyricHyphen.minimum-distance = #1.0
  syl -- lab word word
  \override LyricHyphen.minimum-distance = #2.0
  syl -- lab word word
  \revert LyricHyphen.minimum-distance
  syl -- lab word word
}

[image of music]


Donar format a síl·labes de la lletra

És possible usar el mode de marcatge per donar format a síl·labes individualment dins de la lletra.

mel = \relative c'' { c4 c c c }
lyr = \lyricmode {
  Lyrics \markup { \italic can } \markup { \with-color #red contain }
  \markup { \fontsize #8 \bold Markup! }
}

<<
  \new Voice = melody \mel
  \new Lyrics \lyricsto melody \lyr
>>

[image of music]


Com posar lligadures entre síl·labes de la lletra

Es pot fer separant les síl·labes mitjançant símbols de titlle corb.

\lyrics {
  wa~o~a
}

[image of music]


Plantilla per a himnes

Aquest fragment de codi mostra una forma de preparar un himne quan cada línia comença amb un compàs parcial. També mostra com afegir els versos com a text independent a sota de la música.

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

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

\layout {
  \context {
    \Score
    caesuraType = #'((bar-line . "||"))
    fineBarType = "||"
  }
}

\paper {  % Start paper block
  indent = 0     % don't indent first system
  line-width = 130   % shorten line length to suit music
  tagline = ##f % Don't print tag line, can be removed
}  % End paper block

[image of music]


Alineació de la lletra

L’alineació horitzontal de la lletra es pot ajustar sobreescrivint la propietat self-alignment-X de l’objecte LyricText. #-1 és esquerra, #0 és centrat #1 es dreta; tanmateix, podem usar també #LEFT, #CENTER i #RIGHT.

\layout { ragged-right = ##f }

\relative c'' {
  c1
  c1
  c1
}
\addlyrics {
  \once \override LyricText.self-alignment-X = #LEFT
  "This is left-aligned"
  \once \override LyricText.self-alignment-X = #CENTER
  "This is centered"
  \once \override LyricText.self-alignment-X = 1
  "This is right-aligned"
}

[image of music]


Marking notes of spoken parts with a cross on the stem (Sprechstimme)

This example shows how to put crosses on stems. Mark the beginning of a spoken section with the \speakOn keyword, and end it with the \speakOff keyword.

speakOn = {
  \override Stem.stencil =
    #(lambda (grob)
       (let* ((x-parent (ly:grob-parent grob X))
              (is-rest? (ly:grob? (ly:grob-object x-parent 'rest))))
         (if is-rest?
             empty-stencil
             (ly:stencil-combine-at-edge
              (ly:stem::print grob)
              Y
              (- (ly:grob-property grob 'direction))
              (grob-interpret-markup grob
                                     (markup #:center-align #:fontsize -4
                                             #:musicglyph "noteheads.s2cross"))
              -2.3))))
}

speakOff = {
  \revert Stem.stencil
  \revert Flag.stencil
}

\score {
  \new Staff {
    \relative c'' {
      a4 b a c
      \speakOn
      g4 f r g
      b4 r d e
      \speakOff
      c4 a g f
    }
  }
}

[image of music]


Aconseguir l’espaiat de la lletra de la versió 2.12 en versions més recent

El motor d’espaiat vertical va canviar a la versió 2.14. Això pot fer que s’alteri l’espaiat de la lletra de les cançons. És possible fixar propietats per als contextos Lyric i Staff de forma que el motor d’espaiat es comporti com ho feia a la versió 2.12.

\header { tagline = ##f }

global = {
  \key d \major
  \time 3/4
}

sopMusic = \relative c' {
  % VERSE ONE
  fis4 fis fis | \break
  fis4. e8 e4
}

altoMusic = \relative c' {
  % VERSE ONE
  d4 d d |
  d4. b8 b4 |
}

tenorMusic = \relative c' {
  a4 a a |
  b4. g8 g4 |
}

bassMusic = \relative c {
  d4 d d |
  g,4. g8 g4 |
}

words = \lyricmode {
  Great is Thy faith -- ful -- ness,
}

\score {
  \new ChoirStaff <<
    \new Lyrics = sopranos
    \new Staff = women <<
      \new Voice = "sopranos" {
        \voiceOne
        \global \sopMusic
      }
      \new Voice = "altos" {
        \voiceTwo
        \global \altoMusic
      }
    >>
    \new Lyrics = "altos"
    \new Lyrics = "tenors"
    \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 \words
    \context Lyrics = altos \lyricsto altos \words
    \context Lyrics = tenors \lyricsto tenors \words
    \context Lyrics = basses \lyricsto basses \words
  >>
  \layout {
    \context {
      \Lyrics
      \override VerticalAxisGroup.staff-affinity = ##f
      \override VerticalAxisGroup.staff-staff-spacing =
        #'((basic-distance . 0)
	   (minimum-distance . 2)
	   (padding . 2))
    }
    \context {
      \Staff
      \override VerticalAxisGroup.staff-staff-spacing =
        #'((basic-distance . 0)
	   (minimum-distance . 2)
	   (padding . 2))
    }
  }
}

[image of music]


Plantilla d’orquestra amb cor i piano

Aquesta plantilla mostra l’ús de contextos StaffGroup i GrandStaff niuats per sub-agrupar instruments del mateix tipus, i una forma d’usar \transpose de manera que unes variables continguin la música per a instruments transpositors en afinació de concert.

#(set-global-staff-size 17)

\paper {
  indent = 3.0\cm  % add space for instrumentName
  short-indent = 1.5\cm  % add less space for shortInstrumentName
}

\header { tagline = ##f }


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

[image of music]


Plantilla de piano amb melodia i lletra

Vet aquí el típic format d’una cançó: un pentagrama amb la melodia i la lletra, i el acompanyament de piano per sota.

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

[image of music]


Posar lletra dins del pentagrama

Es poden moure les línies de lletra verticalment per imprimir-les dins del pentagrama. Les lletres es mouen amb \override LyricText.extra-offset = #'(0 . dy) i hi ha instruccions per moure les línies d’extensió i els guions. El desplaçament necessari s’estableix mitjançant un procés d’assaig i error.

<<
  \new Staff <<
    \new Voice = "voc" \relative c' { \stemDown a bes c8 b c4 }
  >>
  \new Lyrics \with {
    \override LyricText.extra-offset = #'(0 . 8.6)
    \override LyricExtender.extra-offset = #'(0 . 8.6)
    \override LyricHyphen.extra-offset = #'(0 . 8.6)
  } \lyricsto "voc" { La la -- la __ _ la }
>>

[image of music]


Plantilla de cor SATB, a quatre pentagrames

Plantilla de cor SATB (en quatre pentagrames)

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

[image of music]


Plantilla de pentagrama únic amb música, lletra i acords

Aquesta plantilla facilita la preparació d’una cançó amb melodia, lletra i acords.

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

[image of music]


Plantilla per a un pentagrama únic amb música, lletra, acords i trastos

A continuació presentem un exemple de plantilla per a un full guia d’acords amb melodia, lletra, acords i diagrama de trastos.

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

[image of music]


Plantilla de pentagrama únic amb notes i lletra

Aquesta petita plantilla mostra una melodia senzilla amb lletra. Talleu-la i pegueu-la, escriviu les notes i després la lletra. Aquest exemple desactiva el barrat automàtic, que és el més freqüent a les parts vocals antigues. Per usar el barrat automàtic modifiqueu o marqueu com un comentari la línia corresponent.

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

[image of music]


Silencis de separació en mode de lletra

La sintaxi s per als silencis de desplaçament sols està disponible als modes de nota i d’acord. En altres situacions, per exemple en escriure la lletra de les cançons, es recomana usar l’ordre \skip.

<<
  \relative c'' { a1 | a }
  \new Lyrics \lyricmode { \skip 1 bla1 }
>>

[image of music]


Silencis de separació en mode de lletra (2)

Tot i que no es poden usar els silencis de separació s dins de \lyricmode (s’agafen com una “s”, literal, no com un espai), sí hi ha disponibles les comtes dobles ("") i la barra baixa (_). Així com per exemple:

<<
  \relative c'' { a4 b c d }
  \new Lyrics \lyricmode { a4 "" _ gap }
>>

[image of music]


Ús de arpeggioBracket per fer més visible un divisi

El corxet d’arpegis arpeggioBracket es pot usar per indicar la divisió de veus quan no hi ha pliques que puguin oferir aquesta informació. Se sol trobar a la múśica coral.

\include "english.ly"

\score {
  \relative c'' {
    \key a \major
    \time 2/2
    <<
      \new Voice = "upper"
      <<
        { \voiceOne \arpeggioBracket
          a2( b2
          <b d>1\arpeggio)
          <cs e>\arpeggio ~
          <cs e>4
        }
        \addlyrics { \lyricmode { A -- men. } }
      >>
      \new Voice = "lower"
      { \voiceTwo
        a1 ~
        a
        a ~
        a4 \bar "|."
      }
    >>
  }
  \layout { ragged-right = ##t }
}

[image of music]


Using tags to produce mensural and modern music from the same source

Using tags, it is possible to produce both mensural and modern notation from the same music. In this snippet, a function \menrest is introduced, allowing mensural rests to be pitched as in the original, but with modern rests in the standard staff position.

Tags can also be used where other differences are needed: for example using “whole measure rests” (R1, R\breve, etc.) in modern music, but normal rests (r1, r\breve, etc.) in the mensural version. Converting mensural music to its modern equivalent is usually referred to as transcription.

\header { tagline = ##f }

menrest =
#(define-music-function (note)
  (ly:music?)
    #{
      \tag #'mens $(make-music 'RestEvent note)
      \tag #'mod $(make-music 'RestEvent note 'pitch '())
    #})

MenStyle = {
  \autoBeamOff
  \override NoteHead.style = #'petrucci
  \override Score.BarNumber.transparent = ##t
  \override Stem.neutral-direction = #up
}

finalis = \section

Music = \relative c'' {
  \set Score.tempoHideNote = ##t
  \key f \major
  \time 4/4
  g1 d'2 \menrest bes4 bes2 a2 r4 g4 fis2.
  \finalis
}

MenLyr = \lyricmode { So farre, deere life, deare life }
ModLyr = \lyricmode { So far, dear life, dear life }

\score {
  \keepWithTag #'mens {
    <<
      \new MensuralStaff
      {
        \new MensuralVoice = Cantus
          \clef "mensural-c1" \MenStyle \Music
      }
      \new Lyrics \lyricsto Cantus \MenLyr
    >>
  }
}

\score {
  \keepWithTag #'mod {
    \new ChoirStaff <<
      \new Staff
      {
        \new Voice = Sop \with {
          \remove "Note_heads_engraver"
          \consists "Completion_heads_engraver"
          \remove "Rest_engraver"
          \consists "Completion_rest_engraver" }
        {
          \shiftDurations 1 0 { \autoBeamOff \Music }
        }
      }
      \new Lyrics \lyricsto Sop \ModLyr
    >>
  }
}

[image of music]


Alineació vertical de la lletra i els compassos d’ossia

Aquest fragment de codi mostra l’ús de les propietats de context alignBelowContext i alignAboveContext per a controlar la posició de la lletra i els compassos d’ossia.

\relative c' <<
  \new Staff = "1" { c4 c s2 }
  \new Staff = "2" { c4 c s2 }
  \new Staff = "3" { c4 c s2 }
  { \skip 2
    <<
      \lyrics {
        \set alignBelowContext = "1"
        lyrics4 below
      }
      \new Staff \with {
        alignAboveContext = "3"
        fontSize = -2
        \override StaffSymbol.staff-space = #(magstep -2)
        \remove "Time_signature_engraver"
      } {
        \tuplet 6/4 {
          \override TextScript.padding = 3
          c8[^"ossia above" d e d e f]
        }
      }
    >>
  }
>>

\paper {
  ragged-right = ##t
}

[image of music]


Lletra comuna centrada verticalment

A una peça vocal en la qual hi ha diverses línies de lletra (dues, quatre o més) i hi ha lletres comunes a totes les veus en algun punt, es pot fer que les lletres comunes se centrin verticalment com es mostra a l’exemple següent:

dropLyrics = {
  \override LyricText.extra-offset = #'(0 . -4.5)
  \override LyricHyphen.extra-offset = #'(0 . -4.5)
  \override LyricExtender.extra-offset = #'(0 . -4.5)
  \override StanzaNumber.extra-offset = #'(0 . -4.5)
}

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

skipFour = \repeat unfold 4 { \skip 8 }

lyricsA = \lyricmode {
  The first verse has
  \dropLyrics
  \set stanza = #"   All:"
  the com -- mon __ words
  \raiseLyrics
  used in all four.
}

lyricsB = \lyricmode { In stan -- za two,   \skipFour al -- so ap -- pear. }

lyricsC = \lyricmode { By the third verse,  \skipFour are get -- ting dull. }

lyricsD = \lyricmode { Last stan -- za, and \skipFour get used once more. }

melody = \relative c' {
  c4 d e f |
  g f e8( e f) d |
  c4 e d c |
}

\score {
  <<
    \new Voice = m \melody
    \new Lyrics \lyricsto m \lyricsA
    \new Lyrics \lyricsto m \lyricsB
    \new Lyrics \lyricsto m \lyricsC
    \new Lyrics \lyricsto m \lyricsD
  >>
}

[image of music]


Plantilla de conjunt vocal

Vet aquí una partitura vocal estàndard per a quatre veus SATB. Amb grups més grans, sol ser útil incloure una secció que aparegui a totes les parts. Per exemple, el compàs i l’armadura gairebé sempre son els mateixos per a totes. Com a la plantilla “Himne”, les quatre veus es reagrupen en sols dos pentagrames.

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

[image of music]


Plantilla de conjunt vocal amb reducció de piano automàtica

Aquesta plantilla afegeix una reducció de piano automàtica a la partitura vocal SATB estàndard que es va mostrar a la “Plantilla de conjunt vocal”. Això presenta un dels punts forts del LilyPond: podem usar una definició de música més d’un cop. Si es fa qualsevol canvi a les notes de la part vocal (diguem tenorMusic), aleshores els canvis s’aplicaran també a la reducció 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 >>
      >>
    >>
  >>
}

[image of music]


Plantilla per a conjunt amb lletres alineades a sobre i a sota dels pentagrames

Aquesta plantilla és, bàsicament, la mateixa que la senzilla plantilla “Conjunt vocal”, excepte que aquí totes les línies de lletra es col·loquen utilitzant alignAboveContext i 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
  >>
}

[image of music]


Estrofa per a solista i tornada a dues veus

Aquesta plantilla crea una partitura que comença amb una estrofa per a solista i continua amb una tornada a dues veus. També mostra l’ús de silencis de separació dins de la variable \global per definit canvis de compàs (i altres exemple que són comuns a totes les parts) al llarg de tota la partitura.

\header { tagline = ##f }

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

[image of music]


Chords

Chord notation


Afegir un baix xifrat a sobre o a sota de les notes

En escriure un baix xifrat, podem ubicar les xifres a sobre a o a sota de les notes del baix, mitjançant la definició de la propietat BassFigureAlignmentPositioning #'direction (exclusivament dins d’un context Staff). es pot escollir entre #UP (o #1, a sobre), #CENTER (o #0, centraat) i #DOWN (o #-1, a sota).

Aquesta propietat es pot canviar tantes vegades com volem. Utilitzeu \once \override si no voleu que la sobreescriptura s’apliqui a tota la partitura.

bass = {
  \clef bass
  g4 b, c d
  e d8 c d2
}

continuo = \figuremode {
  <_>4 <6>4 <5/>4
  \override Staff.BassFigureAlignmentPositioning.direction = #UP
  %\bassFigureStaffAlignmentUp
  < _+ >4 <6>
  \set Staff.useBassFigureExtenders = ##t
  \override Staff.BassFigureAlignmentPositioning.direction = #DOWN
  %\bassFigureStaffAlignmentDown
  <4>4. <4>8 <_+>4
}

\score {
  <<
    \new Staff = bassStaff \bass
    \context Staff = bassStaff \continuo
  >>
}

[image of music]


Afegir barres de compàs al context de noms d’acord (ChordNames)

Per afegir indicacions de línia divisòria dins del context dels noms d’acord ChordNames, incloeu el gravador Bar_engraver.

\new ChordNames \with {
  \override BarLine.bar-extent = #'(-2 . 2)
  \consists "Bar_engraver"
}

\chordmode {
  f1:maj7 f:7 bes:7
}

[image of music]


Adjusting figured bass alteration glyphs

In figured bass, specially designed glyphs for 6\\, 7\\, and 9\\ are used by default. Similarly, specially designed glyphs for symbols 2\+, 4\+, and 5\+ are used by default if plus signs appear after the number.

To change that, pass an alist to figuredBassPlusStrokedAlist and set the glyph in question to #f (or omit it).

\figures {
  \set figuredBassPlusDirection = #RIGHT
  <6\\> <7\\> <9\\> r
  <2\+> <4\+> <5\+> r

  \set figuredBassPlusStrokedAlist =
    #'((2 . "figbass.twoplus")
       ;; (4 . "figbass.fourplus")
       ;; (5 . "figbass.fiveplus")
       (6 . "figbass.sixstroked")
       ;; (7 . "figbass.sevenstroked")
       ;; (9 . "figbass.ninestroked")
      )
  <6\\> <7\\> <9\\> r
  <2\+> <4\+> <5\+> r
}

[image of music]


Modificació del separador d’acords

The separator between different parts of a chord name can be set to any markup.

\chords {
  c:7sus4
  \set chordNameSeparator
    = \markup { \typewriter | }
  c:7sus4
}

[image of music]


Canviar la nomenclatura dels acords del xifrat americà per la notació alemanya o semi-alemanya

La nomenclatura anglesa (predeterminada) per als acords del xifrat americà es pot canviar per l’alemanya (\germanChords que substitueix B i Bes per H i B) o per la semi-anglesa (\semiGermanChords que substitueix B i Bes per H i Bb).

scm = \chordmode {
  c1/c | cis/cis
  b1/b | bis/bis | bes/bes
}


\layout {
  ragged-right = ##t
  \context {
    \ChordNames
    \consists "Instrument_name_engraver"
  }
}

<<
  \new ChordNames {
    \set instrumentName = #"default"
    \scm
  }
  \new ChordNames {
    \set instrumentName = #"german"
    \germanChords \scm
  }
  \new ChordNames {
    \set instrumentName = #"semi-german"
    \semiGermanChords \scm
  }
  \new ChordNames {
    \set instrumentName = #"italian"
    \italianChords \scm
  }
  \new ChordNames {
    \set instrumentName = #"french"
    \frenchChords \scm
  }
  \context Voice { \scm }
>>

[image of music]


Canviar les posicions de les alteracions de baix xifrat

Les alteracions i els signes «més» poden aparèixer abans o després dels nombres, segon el valor de ls propietats figuredBassAlterationDirection i figuredBassPlusDirection.

\figures {
  <5\+> <5+ 4\+> <6 4- 2\+> r
  \set figuredBassAlterationDirection = #RIGHT
  <5\+> <5+ 4\+> <6 4- 2\+> r
  \set figuredBassPlusDirection = #RIGHT
  <5\+> <5+ 4\+> <6 4- 2\+> r
  \set figuredBassAlterationDirection = #LEFT
  <5\+> <5+ 4\+> <6 4- 2\+> r
}

[image of music]


Excepcions per als noms d’acord

Es pot usar la propietat chordNameExceptions per a emmagatzemar una llista de notacions espacials per a acords específics.

% modify maj9 and 6(add9)
% Exception music is chords with markups
chExceptionMusic = {
  <c e g b d'>1-\markup { \super "maj9" }
  <c e g a d'>1-\markup { \super "6(add9)" }
}

% Convert music to list and prepend to existing exceptions.
chExceptions = #(append
  (sequential-music-to-chord-exceptions chExceptionMusic #t)
  ignatzekExceptions)

theMusic = \chordmode {
  g1:maj9 g1:6.9
  \set chordNameExceptions = #chExceptions
  g1:maj9 g1:6.9
}

\layout {
  ragged-right = ##t
}

<<
   \new ChordNames \theMusic
   \new Voice \theMusic
>>

[image of music]


Nom d’acord maj7

La presentació de l’acord de sèptima major es pot ajustar mitjançant majorSevenSymbol.

\chords {
  c:7+
  \set majorSevenSymbol = \markup { j7 }
  c:7+
}

[image of music]


Chord names alternative

Chord names are generated from a list of pitches. The functions which construct these names can be customised.

Here are shown chords following Ignatzek (pp. 17-18, 1995), used by default since LilyPond 1.7.20, compared with an alternative Jazz chord notation and Harald Banter’s (1987) notation. A smaller font is used in the latter case, as these tend to be overly verbose.

This mirrors the mechanism originally used in early LilyPond versions (pre-1.7); not having been properly maintained, however, some features have been lost (mainly chord exception lists) and bugs have been introduced.

%%%% Legacy chord naming functions (formerly in scm/chord-generic-names.scm)
%%%% Copyright (C) 2003--2023 Jan Nieuwenhuizen <janneke@gnu.org>

#(set-global-staff-size 19.7)

#(define-public (banter-chordnames pitches bass inversion context)
  (old_chord->markup 'banter pitches bass inversion context))

#(define-public (jazz-chordnames pitches bass inversion context)
  (old_chord->markup 'jazz pitches bass inversion context))

#(define (define-translator-property symbol type? description)
  (if (not (and (symbol? symbol)
    (procedure? type?)
    (string? description)))
      (ly:error "error in call of define-translator-property"))
  (if (not (equal? (object-property symbol 'translation-doc) #f))
      (ly:error (G_ "symbol ~S redefined") symbol))

  (set-object-property! symbol 'translation-type? type?)
  (set-object-property! symbol 'translation-doc description)
  symbol)

#(for-each
  (lambda (x)
    (apply define-translator-property x))
  `((chordNameExceptionsFull ,list? "An alist of full chord
exceptions.  Contains @code{(@var{chord} . @var{markup})} entries.")
    (chordNameExceptionsPartial ,list? "An alist of partial chord
exceptions.  Contains @code{(@var{chord} . (@var{prefix-markup}
@var{suffix-markup}))} entries.")))

#(define-public (old_chord->markup
                style pitches bass inversion context)
  "Entry point for @code{Chord_name_engraver}.
@var{pitches}, @var{bass}, and @var{inversion} are lily pitches."
  (define (default-note-namer pitch)
    (note-name->markup pitch #f))

  (define (markup-or-empty-markup markup)
    "Return MARKUP if markup, else empty-markup"
    (if (markup? markup) markup empty-markup))

  (define (accidental->markup alteration)
    "Return accidental markup for ALTERATION."
    (if (= alteration 0)
        (make-line-markup (list empty-markup))
        (conditional-kern-before
         (alteration->text-accidental-markup alteration)
         (= alteration FLAT) 0.094725)))

  (define (list-minus a b)
    "Return list of elements in A that are not in B."
    (lset-difference eq? a b))

  (define (markup-join markups sep)
    "Return line-markup of MARKUPS, joining them with markup SEP"
    (if (pair? markups)
        (make-line-markup (list-insert-separator markups sep))
        empty-markup))

  (define (conditional-kern-before markup bool amount)
    "Add AMOUNT of space before MARKUP if BOOL is true."
    (if bool
        (make-line-markup
         (list (make-hspace-markup amount)
           markup))
        markup))

  (define (step-nr pitch)
    (let* ((pitch-nr (+ (* 7 (ly:pitch-octave pitch))
                        (ly:pitch-notename pitch)))
           (root-nr (+ (* 7 (ly:pitch-octave (car pitches)))
                       (ly:pitch-notename (car pitches)))))
      (+ 1 (- pitch-nr root-nr))))

  (define (next-third pitch)
    (+ pitch
       (ly:make-pitch 0 2 (if (or (= (step-nr pitch) 3)
                                  (= (step-nr pitch) 5))
                              FLAT 0))))

  (define (step-alteration pitch)
    (let* ((normalized-pitch (- pitch (car pitches)))
           (alteration (ly:pitch-alteration normalized-pitch)))
      (if (= (step-nr pitch) 7) (+ alteration SEMI-TONE) alteration)))

  (define (pitch-unalter pitch)
    (let ((alteration (step-alteration pitch)))
      (if (= alteration 0)
          pitch
          (ly:make-pitch (ly:pitch-octave pitch) (ly:pitch-notename pitch)
                         (- (ly:pitch-alteration pitch) alteration)))))

  (define (step-even-or-altered? pitch)
    (let ((nr (step-nr pitch)))
      (if (!= (modulo nr 2) 0)
          (!= (step-alteration pitch) 0)
          #t)))

  (define (step->markup-plusminus pitch)
    (let ((alt (step-alteration pitch)))
      (make-line-markup
       (list
        (number->string (step-nr pitch))
        (cond
         ((= alt DOUBLE-FLAT) "--")
         ((= alt FLAT) "-")
         ((= alt NATURAL) "")
         ((= alt SHARP) "+")
         ((= alt DOUBLE-SHARP) "++"))))))

  (define (step->markup-accidental pitch)
    (make-line-markup
     (list (accidental->markup (step-alteration pitch))
           (make-simple-markup (number->string (step-nr pitch))))))

  (define (step->markup-ignatzek pitch)
    (make-line-markup
     (if (and (= (step-nr pitch) 7)
              (= (step-alteration pitch) 1))
         (list (ly:context-property context 'majorSevenSymbol))
         (list (accidental->markup (step-alteration pitch))
               (make-simple-markup (number->string (step-nr pitch)))))))

  ;; tja, kennok
  (define (make-sub->markup step->markup)
    (lambda (pitch)
      (make-line-markup (list (make-simple-markup "no")
                              (step->markup pitch)))))

  (define (step-based-sub->markup step->markup pitch)
    (make-line-markup (list (make-simple-markup "no") (step->markup pitch))))

  (define (get-full-list pitch)
    (if (<= (step-nr pitch) (step-nr (last pitches)))
        (cons pitch (get-full-list (next-third pitch)))
        '()))

  (define (get-consecutive nr pitches)
    (if (pair? pitches)
        (let* ((pitch-nr (step-nr (car pitches)))
               (next-nr (if (!= (modulo pitch-nr 2) 0) (+ pitch-nr 2) nr)))
          (if (<= pitch-nr nr)
              (cons (car pitches) (get-consecutive next-nr (cdr pitches)))
              '()))
        '()))

  ;;; FIXME -- exceptions no longer work. -vv

  (define (full-match exceptions)
    (if (pair? exceptions)
        (let* ((e (car exceptions))
               (e-pitches (car e)))
          (if (equal? e-pitches pitches)
              e
              (full-match (cdr exceptions))))
        #f))

  (define (partial-match exceptions)
    (if (pair? exceptions)
        (let* ((e (car exceptions))
               (e-pitches (car e)))
          (if (equal? e-pitches (take pitches (length e-pitches)))
              e
              (partial-match (cdr exceptions))))
        #f))

  ;; FIXME: exceptions don't work anyway.
  (if #f (begin
           (write-me "pitches: " pitches)))
  (let* ((full-exceptions
          (ly:context-property context 'chordNameExceptionsFull))
         (full-exception (full-match full-exceptions))
         (full-markup (if full-exception (cadr full-exception) '()))
         (partial-exceptions
          (ly:context-property context 'chordNameExceptionsPartial))
         (partial-exception (partial-match partial-exceptions))
         (partial-pitches (if partial-exception (car partial-exception) '()))
         (partial-markup-prefix
          (if partial-exception (markup-or-empty-markup
                                 (cadr partial-exception)) empty-markup))
         (partial-markup-suffix
          (if (and partial-exception (pair? (cddr partial-exception)))
              (markup-or-empty-markup (caddr partial-exception)) empty-markup))
         (root (car pitches))
         (full (get-full-list root))
         ;; kludge alert: replace partial matched lower part of all with
         ;; 'normal' pitches from full
         ;; (all pitches)
         (all (append (take full (length partial-pitches))
                      (drop pitches (length partial-pitches))))

         (highest (last all))
         (missing (list-minus full (map pitch-unalter all)))
         (consecutive (get-consecutive 1 all))
         (rest (list-minus all consecutive))
         (altered (filter step-even-or-altered? all))
         (cons-alt (filter step-even-or-altered? consecutive))
         (base (list-minus consecutive altered)))


    (if #f (begin
             (write-me "full:" full)
             ;; (write-me "partial-pitches:" partial-pitches)
             (write-me "full-markup:" full-markup)
             (write-me "partial-markup-perfix:" partial-markup-prefix)
             (write-me "partial-markup-suffix:" partial-markup-suffix)
             (write-me "all:" all)
             (write-me "altered:" altered)
             (write-me "missing:" missing)
             (write-me "consecutive:" consecutive)
             (write-me "rest:" rest)
             (write-me "base:" base)))

    (case style
      ((banter)
       ;;    root
       ;;    + steps:altered + (highest all -- if not altered)
       ;;    + subs:missing

       (let* ((root->markup default-note-namer)
              (step->markup step->markup-plusminus)
              (sub->markup (lambda (x)
                              (step-based-sub->markup step->markup x)))
              (sep (make-simple-markup "/")))

         (if
          (pair? full-markup)
          (make-line-markup (list (root->markup root) full-markup))

          (make-line-markup
           (list
            (root->markup root)
            partial-markup-prefix
            (make-super-markup
             (markup-join
              (append
               (map step->markup
                    (append altered
                            (if (and (> (step-nr highest) 5)
                                     (not
                                      (step-even-or-altered? highest)))
                                (list highest) '())))
               (list partial-markup-suffix)
               (map sub->markup missing))
              sep)))))))


      ((jazz)
       ;;    root
       ;;    + steps:(highest base) + cons-alt
       ;;    + 'add'
       ;;    + steps:rest
       (let* ((root->markup default-note-namer)
              (step->markup step->markup-ignatzek)
              (sep (make-simple-markup " "))
              (add-prefix (make-simple-markup " add")))

         (if
          (pair? full-markup)
          (make-line-markup (list (root->markup root) full-markup))

          (make-line-markup
           (list
            (root->markup root)
            partial-markup-prefix
            (make-super-markup
             (make-line-markup
              (list

               ;; kludge alert: omit <= 5
               ;;(markup-join (map step->markup
               ;;                        (cons (last base) cons-alt)) sep)

               ;; This fixes:
               ;;  c     C5       -> C
               ;;  c:2   C5 2     -> C2
               ;;  c:3-  Cm5      -> Cm
               ;;  c:6.9 C5 6add9 -> C6 add 9 (add?)
               ;;  ch = \chords { c c:2 c:3- c:6.9^7 }
               (markup-join (map step->markup
                                 (let ((tb (last base)))
                                   (if (> (step-nr tb) 5)
                                       (cons tb cons-alt)
                                       cons-alt))) sep)

               (if (pair? rest)
                   add-prefix
                   empty-markup)
               (markup-join (map step->markup rest) sep)
               partial-markup-suffix))))))))

      (else empty-markup))))


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%
%%%% Here begins the actual snippet:

chs = \transpose c' c' {
  <c e g>1
  <c es g>  % m = minor triad
  <c e gis>
  <c es ges> \break
  <c e g bes>
  <c es g bes>
  <c e g b>  % triangle = maj
  <c es ges beses>
  <c es ges b> \break
  <c e gis bes>
  <c es g b>
  <c e gis b>
  <c es ges bes> \break
  <c e g a>  % 6 = major triad with added sixth
  <c es g a>  % m6 = minor triad with added sixth
  <c e g bes d'>
  <c es g bes d'> \break
  <c es g bes d' f' a' >
  <c es g bes d' f' >
  <c es ges bes d' >
  <c e g bes des' > \break
  <c e g bes dis'>
  <c e g bes d' f'>
  <c e g bes d' fis'>
  <c e g bes d' f' a'> \break
  <c e g bes d' fis' as'>
  <c e gis bes dis'>
  <c e g bes dis' fis'>
  <c e g bes d' f' as'> \break
  <c e g bes des' f' as'>
  <c e g bes d' fis'>
  <c e g b d'>
  <c e g bes d' f' as'> \break
  <c e g bes des' f' as'>
  <c e g bes des' f' a'>
  <c e g b d'>
  <c e g b d' f' a'> \break
  <c e g b d' fis'>
  <c e g bes des' f ' a'>
  <c f g>
  <c f g bes> \break
  <c f g bes d'>
  <c e g d'>  % add9
  <c es g f'>
  <c e g b fis'>  % Lydian
  <c e g bes des' ees' fis' aes'>  % altered chord
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% alternate Jazz notation

efullmusicJazzAlt = {
  <c e gis>1-\markup { "+" }
  <c e g b>-\markup {
    \normal-size-super
    % \override #'(font-family . math) "N"
    \override #'(font-family . math) "M"
  }
  %%c:3.5.7 = \markup { \override #'(font-family . math) "M" }
  %%c:3.5.7 = \markup { \normal-size-super "maj7" }

  <c es ges>-\markup { \super "o" }  % should be $\circ$ ?
  <c es ges bes>-\markup { \super \combine "o" "/" }
  <c es ges beses>-\markup { \super  "o7" }
}

efullJazzAlt = #(sequential-music-to-chord-exceptions efullmusicJazzAlt #f)

epartialmusicJazzAlt = {
  <c d>1-\markup { \normal-size-super "2" }
  <c es>-\markup { "m" }
  <c f>-\markup { \normal-size-super "sus4" }
  <c g>-\markup { \normal-size-super "5" }
  %% TODO, partial exceptions
  <c es f>-\markup { "m" }-\markup { \normal-size-super "sus4" }
  <c d es>-\markup { "m" }-\markup { \normal-size-super "sus2" }
}

epartialJazzAlt = #(sequential-music-to-chord-exceptions epartialmusicJazzAlt #f)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\score {
  <<
    \new ChordNames {
      %% Already set by default:
      %\set chordNameFunction = #ignatzek-chord-names
      \set instrumentName = "Ignatzek"
      \set shortInstrumentName = "Def"
      \chs
    }

    \new ChordNames {
      \set chordNameFunction = #jazz-chordnames
      \set majorSevenSymbol = \whiteTriangleMarkup
      \set chordNameSeparator = "/"
      \set chordNameExceptionsFull = \efullJazzAlt
      \set chordNameExceptionsPartial = \epartialJazzAlt
      \set instrumentName = "Alternative"
      \set shortInstrumentName = "Alt"
      \chs
    }

    %% This is the Banter (1987) style.  It gives exceedingly
    %% verbose (wide) names, making the output file take up to 4 pages.

    \new ChordNames {
      \set chordNameFunction = #banter-chordnames
      \override ChordName.font-size = -3
      \set instrumentName = "Banter"
      \set shortInstrumentName = "Ban"
      \chs
    }

  \new Staff \transpose c c' { \chs }
  >>
  \layout {
    #(layout-set-staff-size 16)
    system-system-spacing.basic-distance = 0
    \context {
      \ChordNames
      \consists "Instrument_name_engraver"
    }
    \context {
      \Score
      \remove "Bar_number_engraver"
    }
  }
}

[image of music]


Chords with stretched fingering for FretBoards and TabVoice

Sometimes chords with a stretched fingering are required. If not otherwise specified the context-property maximumFretStretch is set to 4, though. Resulting in a warning about "No string for pitch ..." and the note is omitted. You may set maximumFretStretch to an approppriate value or explecitely assign string-numbers to all notes of a chord.

%% The code below will print two warnings, which may be omitted by uncommenting:
%#(for-each (lambda (x) (ly:expect-warning "No string for pitch")) (iota 2))

mus = {
  <c' bes'>
  <c'\2 bes'>
  \set maximumFretStretch = 5
  <c' bes'>
  <c'\2 bes'\1>
}

<<
  \new FretBoards \mus
  \new TabVoice \mus
>>

[image of music]


Clusters («raïms»)

Els «clusters» o raïms són un mecanisme per indicar la interpretació d’un àmbit de notes al mateix temps.

fragment = \relative c' {
  c4 f <e d'>4
  <g a>8 <e a> a4 c2 <d b>4
  e2 c
}

<<
  \new Staff \fragment
  \new Staff \makeClusters \fragment
>>

[image of music]


Controlar la col·locación de les digitacions d’acords

Es pot controlar amb precisió la col·locació dels números de digitació. Perquè es tingui en compte l’orientació de les digitacions, es pot utilitzar una construcció d’acord <> tot i que siguin una sola nota.

\relative c' {
  \set fingeringOrientations = #'(left)
  <c-1 e-3 a-5>4
  \set fingeringOrientations = #'(down)
  <c-1 e-3 a-5>4
  \set fingeringOrientations = #'(down right up)
  <c-1 e-3 a-5>4
  \set fingeringOrientations = #'(up)
  <c-1 e-3 a-5>4
  \set fingeringOrientations = #'(left)
  <c-1>2
  \set fingeringOrientations = #'(down)
  <e-3>2
  \set stringNumberOrientations = #'(up left down)
  <f\3 a\2 c\1>1
  \set strokeFingerOrientations = #'(down right up)
  <c\rightHandFinger 1 e\rightHandFinger 2 c'\rightHandFinger 4 >
}

[image of music]


Cross-staff chords - beaming problems workaround

Sometimes it is better to use stems from the upper staff for creating cross-staff chords, because no problems with automatic beam collision avoidance then arise. If the stems from the lower staff were used in the following example, it would be necessary to change the automatic beam collision avoidance settings so that it doesn’t detect collisions between staves using \override Staff.Beam.collision-voice-only = ##t

\new PianoStaff <<
  \new Staff = up
    \relative c' {
      <<
        { r4
          \override Stem.cross-staff = ##t
          \override Stem.length = #19 % this is in half-spaces,
              % so it makes stems 9.5 staffspaces long
          \override Stem.Y-offset = #-6 % stems are normally lengthened
              % upwards, so here we must lower the stem by the amount
              % equal to the lengthening - in this case (19 - 7) / 2
              % (7 is default stem length)
          e e e }
        { s4
          \change Staff = "bottom"
          \override NoteColumn.ignore-collision = ##t
          c, c c
        }
      >>
    }
  \new Staff = bottom
    \relative c' {
      \clef bass
      \voiceOne
      g8 a g a g a g a
    }
>>

[image of music]


Customizing the chord grid style

Custom divisions of chord squares can be defined through the measure-division-lines-alist and measure-division-chord-placement-alist properties of ChordSquare. These are both alists. Their keys are measure divisions, namely lists which give the fraction of the measure that each chord (or rest, or skip) represents. More precisely, a measure division alist is made of positive, exact numbers adding up to 1, for example: '(1/2 1/4 1/4). The exactness requirement means that, e.g., 1/2 is valid but not 0.5.

The values in measure-division-lines-alist are lists of lines, which are represented as (x1 y1 x2 y2). The line starts at the point (x1 . y1) and ends at (x2 . y2). Coordinates are expressed in the [-1, 1] scale relative to the extent of the square.

The values in measure-division-chord-placement-alist are lists of (x . y) pairs giving the placement of the respective chords.

This example defines a peculiar chord grid style that has a rule for measures divided in three equal parts.

\paper {
  line-width = 10\cm
  ragged-right = ##f
}

\new ChordGrid \with {
  \override ChordSquare.measure-division-lines-alist =
    #'(((1) . ())
       ((1/3 1/3 1/3) . ((-1 -0.4 0 1) (0 -1 1 0.4))))
  \override ChordSquare.measure-division-chord-placement-alist =
    #'(((1) . ((0 . 0)))
       ((1/3 1/3 1/3) . ((-0.7 . 0.5) (0 . 0) (0.7 . -0.5))))
}
\chordmode {
  \time 3/4
  c2.
  c4 c4 c4
}

[image of music]


Customizing the no-chord symbol

By default, rests in a ChordNames context cause the “N.C.” symbol to be printed. This markup can be customized.

<<
  \chords {
    R1
    \set noChordSymbol = "—"
    R1
    \set noChordSymbol = \markup \italic "Ssh!"
    R1
  }
  {
    R1*3
  }
>>

[image of music]


Impressió d’acords complexos

Aquí es presenta una forma d’imprimir un acord en la qual sona la mateixa nota dues vegades amb diferents alteracions.

fixA = {
  \once \override Stem.length = #11
}

fixB = {
  \once \override NoteHead.X-offset = #1.7
  \once \override Stem.length = #7
  \once \override Stem.rotation = #'(45 0 0)
  \once \override Stem.extra-offset = #'(-0.1 . -0.2)
  \once \override Flag.style = #'no-flag
  \once \override Accidental.extra-offset = #'(4 . -.1)
}


\relative c' {
  << { \fixA <b d!>8 } \\ { \voiceThree \fixB dis } >> s
}

[image of music]


Dividir manualment les línies d’extensió del baix xifrat per certs números solament

Sovint, el baix figurat usa línies d’extensió per indicar la continuació de l’element corresponent dins de l’acord. No obstant, en aquest cas el LilyPond està en mode “modo voraç” i usa els extensors quan és possible Per dividir els extensors individuals, podem senzillament usar el modificador \! per a un número, cosa que trenca qualsevol línia d’extensió atribuïda a aquest número just abans del número.

bassfigures = \figuremode {
  \set useBassFigureExtenders = ##t
  <6 4>4 <6 4\!> <6 4\!> <6 4\!> |  <6\! 4\!>  <6 4> <6 4\!> <6 4>
}

<<
  \new Staff \relative c'' { c1 c1 }
  \new FiguredBass \bassfigures
>>

[image of music]


Print ChordNames with same root and different bass as slash and bass-note

To print subsequent ChordNames only differing in its bass note as slash and bass note use the here defined engraver. The behaviour may be controlled in detail by the chordChanges context property.

#(define Bass_changes_equal_root_engraver
  (lambda (ctx)
  "For sequential @code{ChordNames} with same root, but different bass, the root
markup is dropped: D D/C D/B  -> D /C /B
The behaviour may be controlled by setting the @code{chordChanges}
context-property."
    (let ((chord-pitches '())
          (last-chord-pitches '())
          (bass-pitch #f))
      (make-engraver
        ((initialize this-engraver)
          (let ((chord-note-namer (ly:context-property ctx 'chordNoteNamer)))
            ;; Set 'chordNoteNamer, respect user setting if already done
            (ly:context-set-property! ctx 'chordNoteNamer
              (if (procedure? chord-note-namer)
                  chord-note-namer
                  note-name->markup))))
        (listeners
          ((note-event this-engraver event)
            (let* ((pitch (ly:event-property event 'pitch))
                   (pitch-name (ly:pitch-notename pitch))
                   (pitch-alt (ly:pitch-alteration pitch))
                   (bass (ly:event-property event 'bass #f))
                   (inversion (ly:event-property event 'inversion #f)))
            ;; Collect notes of the chord
            ;;  - to compare inversed chords we need to collect the bass note
            ;;    as usual member of the chord, whereas an added bass must be
            ;;    treated separate from the usual chord-notes
            ;;  - notes are stored as pairs containing their
            ;;    pitch-name (an integer), i.e. disregarding their octave and
            ;;    their alteration
            (cond (bass (set! bass-pitch pitch))
                  (inversion
                    (set! bass-pitch pitch)
                    (set! chord-pitches
                          (cons (cons pitch-name pitch-alt) chord-pitches)))
                  (else
                    (set! chord-pitches
                          (cons (cons pitch-name pitch-alt) chord-pitches)))))))
        (acknowledgers
          ((chord-name-interface this-engraver grob source-engraver)
            (let ((chord-changes (ly:context-property ctx 'chordChanges #f)))
              ;; If subsequent chords are equal apart from their bass,
              ;; reset the 'text-property.
              ;; Equality is done by comparing the sorted lists of this chord's
              ;; elements and the previous chord. Sorting is needed because
              ;; inverted chords may have a different order of pitches.
              ;; `chord-changes' needs to be true
              (if (and bass-pitch
                       chord-changes
                       (equal?
                         (sort chord-pitches car<)
                         (sort last-chord-pitches car<)))
                  (ly:grob-set-property! grob 'text
                    (make-line-markup
                      (list
                        (ly:context-property ctx 'slashChordSeparator)
                        ((ly:context-property ctx 'chordNoteNamer)
                         bass-pitch
                         (ly:context-property ctx 'chordNameLowercaseMinor))))))
              (set! last-chord-pitches chord-pitches)
              (set! chord-pitches '())
              (set! bass-pitch #f))))
        ((finalize this-engraver)
          (set! last-chord-pitches '()))))))

myChords = \chordmode {
  %\germanChords

  \set chordChanges = ##t
  d2:m d:m/cis

  d:m/c
  \set chordChanges = ##f
  d:m/b

  e1:7
  \set chordChanges = ##t
  e
  \break
  \once \set chordChanges = ##f
  e1/f
  e2/gis e/+gis e e:m/f d:m d:m/cis d:m/c
  \set chordChanges = ##f
  d:m/b
}

<<
  \new ChordNames
    \with { \consists #Bass_changes_equal_root_engraver }
    \myChords
  \new Staff \myChords
>>

[image of music]


Imprimir els acords quan es produeix un canvi

Es poden imprimir els acords exclusivament al començament de les línies i quan canvia l’acord.

harmonies = \chordmode {
  c1:m c:m \break c:m c:m d
}

<<
  \new ChordNames {
    \set chordChanges = ##t
    \harmonies
  }
  \new Staff {
    \relative c' { \harmonies }
  }
>>

[image of music]


Full guia d’acords o «lead sheet» senzilla

En ajuntar noms d’acord en xifrat americà, melodia i lletra, obtenim un full d’acord os «lead sheet»:

<<
  \chords { c2 g:sus4 f e }
  \new Staff \relative c'' {
    a4 e c8 e r4
    b2 c4( d)
  }
  \addlyrics { One day this shall be free __ }
>>

[image of music]


Plantilla de pentagrama únic amb música, lletra i acords

Aquesta plantilla facilita la preparació d’una cançó amb melodia, lletra i acords.

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

[image of music]


Plantilla per a un pentagrama únic amb música, lletra, acords i trastos

A continuació presentem un exemple de plantilla per a un full guia d’acords amb melodia, lletra, acords i diagrama de trastos.

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

[image of music]


Plantilla de pentagrama únic amb música i acords

Voleu preparar un full guia d’acords (o «lead sheet») amb melodia i acords? No busqueu 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 { }
}

[image of music]


Centrat vertical de les línies de baix xifrat emparellades

Al lloc on s’utilitzin línies extensores per al baix xifrat mitjançant l’establiment de useBassFigureExtenders al valor vertader, les parelles de línies extensores congruents se centren verticalment si el valor de figuredBassCenterContinuations té el valor vertader.

<<
  \relative c' {
    c8 c b b a a c16 c b b
    c8 c b b a a c16 c b b
    c8 c b b a a c c b b
  }
  \figures {
    \set useBassFigureExtenders = ##t
    <6+ 4 3>4 <6 4 3>8 r
    <6+ 4 3>4 <6 4 3>8 <4 3+>16 r
    \set figuredBassCenterContinuations = ##t
    <6+ 4 3>4 <6 4 3>8 r
    <6+ 4 3>4 <6 4 3>8 <4 3+>16 r
    \set figuredBassCenterContinuations = ##f
    <6+ 4 3>4 <6 4 3>8 r
    <6+ 4 3>4 <6 4 3>8 <4 3+>8
  }
>>

[image of music]


Corxets de primera i segona vegada a sota dels acords

Mitjançant l’addició del gravador Volta_engraver al pentagrama pertinent, es poden posar els corxets de primera i segona veu a sota dels acords.

\score {
  <<
    \chords {
      c1
      c1
    }
    \new Staff \with {
      \consists "Volta_engraver"
    }
    {
      \repeat volta 2 { c'1 }
      \alternative { c' }
    }
  >>
  \layout {
    \context {
      \Score
      \remove "Volta_engraver"
    }
  }
}

[image of music]


Keyboards

Keyboard and other multi-staff instruments


Símbols d’acordió discanto

Aquest fragment de codi ha quedat obsolet per les ordres de marcatge predefinides, vegeu ‘Registres d’acordió’ en la Referència de la notació. Tanmateix, encara és útil com a demostració senzila de la forma de combinar símbols: la col·locació dels símbols afegits amb \markup es pot ajustar modificant els arguments de \translate-scaled. Aquí s’usa \translate-scaled en lloc de \translate perquè el posicionament de les parts de símbols s’adapti als canvis de font-size.

discant = \markup {
  \musicglyph "accordion.discant"
}
dot = \markup {
  \musicglyph "accordion.dot"
}

\layout { ragged-right = ##t }

% 16 voets register
accBasson = ^\markup {
  \combine
  \discant
  \translate-scaled #'(0 . 0.5) \dot
}

% een korig 8 en 16 voets register
accBandon = ^\markup {
  \combine
    \discant
    \combine
      \translate-scaled #'(0 . 0.5) \dot
      \translate-scaled #'(0 . 1.5) \dot
}

accVCello = ^\markup {
  \combine
    \discant
    \combine
      \translate-scaled #'(0 . 0.5) \dot
      \combine
        \translate-scaled #'(0 . 1.5) \dot
        \translate-scaled #'(1 . 1.5) \dot
}

% 4-8-16 voets register
accHarmon = ^\markup {
  \combine
    \discant
    \combine
      \translate-scaled #'(0 . 0.5) \dot
      \combine
        \translate-scaled #'(0 . 1.5) \dot
        \translate-scaled #'(0 . 2.5) \dot
}

accTrombon = ^\markup {
  \combine
    \discant
    \combine
      \translate-scaled #'(0 . 0.5) \dot
      \combine
        \translate-scaled #'(0 . 1.5) \dot
        \combine
          \translate-scaled #'(1 . 1.5) \dot
          \translate-scaled #'(-1 . 1.5) \dot
}

% eenkorig 4 en 16 voets register
accOrgan = ^\markup {
  \combine
    \discant
    \combine
      \translate-scaled #'(0 . 0.5) \dot
      \translate-scaled #'(0 . 2.5) \dot
}

accMaster = ^\markup {
  \combine
    \discant
    \combine
      \translate-scaled #'(0 . 0.5) \dot
      \combine
        \translate-scaled #'(0 . 1.5) \dot
        \combine
          \translate-scaled #'(1 . 1.5) \dot
          \combine
            \translate-scaled #'(-1 . 1.5) \dot
            \translate-scaled #'(0 . 2.5) \dot
}

accAccord = ^\markup {
  \combine
    \discant
    \combine
      \translate-scaled #'(0 . 1.5) \dot
      \combine
        \translate-scaled #'(1 . 1.5) \dot
        \combine
          \translate-scaled #'(-1 . 1.5) \dot
          \translate-scaled #'(0 . 2.5) \dot
}

accMusette = ^\markup {
  \combine
    \discant
    \combine
      \translate-scaled #'(0 . 1.5) \dot
      \combine
        \translate-scaled #'(1 . 1.5) \dot
        \translate-scaled #'(-1 . 1.5) \dot
}

accCeleste = ^\markup {
  \combine
    \discant
    \combine
      \translate-scaled #'(0 . 1.5) \dot
      \translate-scaled #'(-1 . 1.5) \dot
}

accOboe = ^\markup {
  \combine
    \discant
    \combine
      \translate-scaled #'(0 . 1.5) \dot
      \translate-scaled #'(0 . 2.5) \dot
}

accClarin = ^\markup {
  \combine
    \discant
    \translate-scaled #'(0 . 1.5) \dot
}

accPiccolo = ^\markup {
    \combine
       \discant
       \translate-scaled #'(0 . 2.5) \dot
}

accViolin = ^\markup {
  \combine
    \discant
    \combine
      \translate-scaled #'(0 . 1.5) \dot
      \combine
        \translate-scaled #'(1 . 1.5) \dot
        \translate-scaled #'(0 . 2.5) \dot
}

\relative c'' {
  c4 d\accBasson e f
  c4 d\accBandon e f
  c4 d\accVCello e f
  c4 d\accHarmon e f
  c4 d\accTrombon e f
  \break
  c4 d\accOrgan e f
  c4 d\accMaster e f
  c4 d\accAccord e f
  c4 d\accMusette e f
  c4 d\accCeleste e f
  \break
  c4 d\accOboe e f
  c4 d\accClarin e f
  c4 d\accPiccolo e f
  c4 d\accViolin e f
}

[image of music]


Accordion register symbols

Accordion register symbols are available as \markup as well as as standalone music events (as register changes tend to occur between actual music events). Bass registers are not overly standardized. The available commands can be found in ’Discant symbols’ in the Notation Reference.

#(use-modules (lily accreg))

\new PianoStaff
<<
  \new Staff \relative {
    \clef treble
    \discant "10"
    r8 s32 f'[ bes f] s e[ a e] s d[ g d] s16 e32[ a]
    <<
      { r16 <f bes> r <e a> r <d g> }
      \\
      { d r a r bes r }
    >> |
    <cis e a>1
  }

  \new Staff \relative {
    \clef treble
    \freeBass "1"
    r8 d'32 s16. c32 s16. bes32 s16. a32[ cis] s16
    \clef bass \stdBass "Master"
    <<
      { r16 <f, bes d>^"b" r <e a c>^"am" r <d g bes>^"gm" |
      <e a cis>1^"a" }
      \\
      { d8_"D" c_"C" bes_"B" | a1_"A" }
    >>
  }
>>

[image of music]


Modificar el text de las indicacions de pedal

Es pot usar Staff.pedalSustainStrings per fixar el text de les indicacions de pisar pedal i aixecar pedal. Observeu que les úniques cadenes vàlides són les que estan a la llista de glifs de pedal: els valors que apareixen en aquest fragment de codi són una relació exhaustiva.

sustainNotes = { c4\sustainOn d e\sustainOff\sustainOn f\sustainOff }

\relative c' {
  \sustainNotes
  \set Staff.pedalSustainStrings = #'("P" "P-" "-")
  \sustainNotes
  \set Staff.pedalSustainStrings = #'("d" "de" "e")
  \sustainNotes
  \set Staff.pedalSustainStrings = #'("M" "M-" "-")
  \sustainNotes
  \set Staff.pedalSustainStrings = #'("Ped" "*Ped" "*")
  \sustainNotes
}

[image of music]


Clusters («raïms»)

Els «clusters» o raïms són un mecanisme per indicar la interpretació d’un àmbit de notes al mateix temps.

fragment = \relative c' {
  c4 f <e d'>4
  <g a>8 <e a> a4 c2 <d b>4
  e2 c
}

<<
  \new Staff \fragment
  \new Staff \makeClusters \fragment
>>

[image of music]


Controlar la col·locación de les digitacions d’acords

Es pot controlar amb precisió la col·locació dels números de digitació. Perquè es tingui en compte l’orientació de les digitacions, es pot utilitzar una construcció d’acord <> tot i que siguin una sola nota.

\relative c' {
  \set fingeringOrientations = #'(left)
  <c-1 e-3 a-5>4
  \set fingeringOrientations = #'(down)
  <c-1 e-3 a-5>4
  \set fingeringOrientations = #'(down right up)
  <c-1 e-3 a-5>4
  \set fingeringOrientations = #'(up)
  <c-1 e-3 a-5>4
  \set fingeringOrientations = #'(left)
  <c-1>2
  \set fingeringOrientations = #'(down)
  <e-3>2
  \set stringNumberOrientations = #'(up left down)
  <f\3 a\2 c\1>1
  \set strokeFingerOrientations = #'(down right up)
  <c\rightHandFinger 1 e\rightHandFinger 2 c'\rightHandFinger 4 >
}

[image of music]


Fer lligadures entre veus diferents

En determinades situacions cal crear lligadures d’expressió entre notes que estan a veus diferents.

La solució és afegir notes invisible a una de les veus utilitzant \hideNotes.

Aquest exemple és el compàs 235 de la Chacona de la segona Partita per a violí sol, BMW 1004, de Bach.

\relative c' {
  <<
    {
      d16( a') s a s a[ s a] s a[ s a]
    }
    \\
    {
      \slurUp
      bes,16[ s e](
      \hideNotes a)
      \unHideNotes f[(
      \hideNotes a)
      \unHideNotes fis](
      \hideNotes a)
      \unHideNotes g[(
      \hideNotes a)
      \unHideNotes gis](
      \hideNotes a)
    }
  >>
}

[image of music]


Cross-staff chords - beaming problems workaround

Sometimes it is better to use stems from the upper staff for creating cross-staff chords, because no problems with automatic beam collision avoidance then arise. If the stems from the lower staff were used in the following example, it would be necessary to change the automatic beam collision avoidance settings so that it doesn’t detect collisions between staves using \override Staff.Beam.collision-voice-only = ##t

\new PianoStaff <<
  \new Staff = up
    \relative c' {
      <<
        { r4
          \override Stem.cross-staff = ##t
          \override Stem.length = #19 % this is in half-spaces,
              % so it makes stems 9.5 staffspaces long
          \override Stem.Y-offset = #-6 % stems are normally lengthened
              % upwards, so here we must lower the stem by the amount
              % equal to the lengthening - in this case (19 - 7) / 2
              % (7 is default stem length)
          e e e }
        { s4
          \change Staff = "bottom"
          \override NoteColumn.ignore-collision = ##t
          c, c c
        }
      >>
    }
  \new Staff = bottom
    \relative c' {
      \clef bass
      \voiceOne
      g8 a g a g a g a
    }
>>

[image of music]


Trèmolos de pentagrama creuat

Atès que \repeat tremolo espera exactament dos arguments musicals per als trèmolos d’acord, la nota o acord que canvia de pentagrama a un trèmolo que creua el pentagrama s’ha de col·locar dins de claus corbes junt a la seva ordre \change Staff.

\new PianoStaff <<
  \new Staff = "up" \relative c'' {
    \key a \major
    \time 3/8
    s4.
  }
  \new Staff = "down" \relative c'' {
    \key a \major
    \time 3/8
    \voiceOne
    \repeat tremolo 6 {
      <a e'>32
      {
        \change Staff = "up"
        \voiceTwo
        <cis a' dis>32
      }
    }
  }
>>

[image of music]


Ajustament fi de les línies de pedal

Es pot alterar l’aspecte de les línies de pedal de diverses formes.

\paper { ragged-right = ##f }

\relative c'' {
  c2\sostenutoOn c
  c2\sostenutoOff c
  \once \override Staff.PianoPedalBracket.shorten-pair = #'(-7 . -2)
  c2\sostenutoOn c
  c2\sostenutoOff c
  \once \override Staff.PianoPedalBracket.edge-height = #'(0 . 3)
  c2\sostenutoOn c
  c2\sostenutoOff c
}

[image of music]


Indicar acords de pentagrama creuat amb claudàtors d’arpegi

Un claudàtor d’arpegi pot indicar que s’han de tocar amb la mateixa mà notes que estan en dos pentagrames diferents. Per fer-ho, el PianoStaff s’ha de configurar perquè accepti símbols d’arpegi de pentagrama creuat i els símbols d’arpegi s’han de configurar a la forma de claudàtor en el context de PianoStaff.

(Debussy, Les collines d’Anacapri, m. 65)

\new PianoStaff <<
  \set PianoStaff.connectArpeggios = ##t
  \override PianoStaff.Arpeggio.stencil =
    #ly:arpeggio::brew-chord-bracket
  \new Staff {
    \relative c' {
      \key b \major
      \time 6/8
      b8-.(\arpeggio fis'-.\> cis-.
        e-. gis-. b-.)\!\fermata^\laissezVibrer \bar "||"
    }
  }
  \new Staff {
    \relative c' {
      \clef bass
      \key b \major
      <<
        {
          <a e cis>2.\arpeggio
        }
        \\
        {
          <a, e a,>2.
        }
      >>
    }
  }
>>

[image of music]


Plantilla per a combo de jazz

Això és una plantilla força avançada, per a un conjunt de jazz. Observeu que la notació de tots els instruments està a \key c \major (Do major). Això es refereix al to de concert; l’armadura es transporta automàticament si la música està dins d’una secció \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 { }
}

[image of music]


Lligaduras “Laissez vibrer”

Les lligadures “Laissez vibrer” (deixar vibrar) tenen una mida fixa. Es pot ajustar el seu format usant 'tie-configuration.

\relative c' {
  <c e g>4\laissezVibrer r <c f g>\laissezVibrer r
  <c d f g>4\laissezVibrer r <c d f g>4.\laissezVibrer r8

  <c d e f>4\laissezVibrer r
  \override LaissezVibrerTieColumn.tie-configuration
     = #`((-7 . ,DOWN)
          (-5 . ,DOWN)
          (-3 . ,UP)
          (-1 . ,UP))
  <c d e f>4\laissezVibrer r
}

[image of music]


Plantilla de piano (senzilla)

Presentem a continuació una plantilla de piano senzilla amb algunes 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 { }
}

[image of music]


Plantilla de piano amb lletra centrada

En comptes de tenir un pentagrama dedicat a la melodia i la lletra, la lletra es pot centrar entre els pentagrames d’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 { }
}

[image of music]


Plantilla de piano amb melodia i lletra

Vet aquí el típic format d’una cançó: un pentagrama amb la melodia i la lletra, i el acompanyament de piano per sota.

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

[image of music]


Removing brace on first line of piano score

This snippet removes the first brace from a PianoStaff or a GrandStaff, together with the clefs.

It may be useful when cutting and pasting the engraved image into existing music.

It uses \alterBroken.

someMusic =  {
  \once \override Staff.Clef.stencil = ##f
  \once \override Staff.TimeSignature.stencil = ##f
  \repeat unfold 3 c1 \break
  \repeat unfold 5 c1 \break
  \repeat unfold 5 c1
}

\score {
  \new PianoStaff
  <<
    \new Staff = "right" \relative c'' \someMusic
    \new Staff = "left" \relative c' { \clef F \someMusic }
  >>
  \layout {
    indent=75
    \context {
      \PianoStaff
      \alterBroken transparent #'(#t) SystemStartBrace
    }
  }
}

\paper { tagline = ##f }

[image of music]


Usar canvi automàtic de pentagrama amb més d’una veu

Utilització de autochange amb més d’una veu.

\score {
  \new PianoStaff
  <<
    \new Staff = "up" {
      <<
        \set Timing.beamExceptions = #'()
        \set Timing.beatStructure = #'(4)
        \new Voice {
          \voiceOne
          \autoChange
          \relative c' {
            g8 a b c d e f g
            g,8 a b c d e f g
          }
        }

        \new Voice {
          \voiceTwo
          \autoChange
          \relative c' {
            g8 a b c d e f g
            g,,8 a b c d e f g
          }
        }
      >>
    }

    \new Staff = "down" {
      \clef bass
    }
  >>
}

[image of music]


Plantilla de conjunt vocal amb reducció de piano automàtica

Aquesta plantilla afegeix una reducció de piano automàtica a la partitura vocal SATB estàndard que es va mostrar a la “Plantilla de conjunt vocal”. Això presenta un dels punts forts del LilyPond: podem usar una definició de música més d’un cop. Si es fa qualsevol canvi a les notes de la part vocal (diguem tenorMusic), aleshores els canvis s’aplicaran també a la reducció 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 >>
      >>
    >>
  >>
}

[image of music]


Percussion

Percussion


Escriptura de parts de percussió

Mitjançant la utilització de les potents eines preconfigurades com la funció \drummode i el context DrumStaff, la introducció de parts per a percussió és molt fàcil: les percussions se situen en les seves pròpies posicions de pentagrama (amb una clau especial) i tenen els caps corresponents a l’instrument. És possible afegir un símbol addicional a la percussió o reduir el nombre de línies.

drh = \drummode {
        cymc4.^"crash" hhc16^"h.h." hh hhc8 hho hhc8 hh16 hh
        hhc4 r4 r2
      }
drl = \drummode {
        bd4 sn8 bd bd4 << bd ss >>
        bd8 tommh tommh bd toml toml bd tomfh16 tomfh
      }
timb = \drummode {
         timh4 ssh timl8 ssh r timh r4
         ssh8 timl r4 cb8 cb
       }

\score {
  <<
    \new DrumStaff \with {
      instrumentName = "timbales"
      drumStyleTable = #timbales-style
      \override StaffSymbol.line-count = #2
      \override BarLine.bar-extent = #'(-1 . 1)
    }
    <<
      \timb
    >>
    \new DrumStaff \with { instrumentName = "drums" }
    <<
      \new DrumVoice { \stemUp \drh }
      \new DrumVoice { \stemDown \drl }
    >>
  >>
  \layout { }
  \midi { \tempo 4 = 120 }
}

[image of music]


Cow and ride bell example

Two different bells, entered with ’cb’ (cowbell) and ’rb’ (ridebell).

\paper { tagline = ##f }

#(define mydrums '((ridebell default #f  3)
                   (cowbell  default #f -2)))

\new DrumStaff \with { instrumentName = #"Different Bells" }

\drummode {
  \set DrumStaff.drumStyleTable = #(alist->hash-table mydrums)
  \set DrumStaff.clefPosition = 0.5
  \override DrumStaff.StaffSymbol.line-positions = #'(-2 3)
  \override Staff.BarLine.bar-extent = #'(-1.0 . 1.5)

  \time 2/4
  rb8 8 cb8 16 rb16-> ~ |
  16 8 16 cb8 8 |
}

[image of music]


Customized drum notation in printed and MIDI output

Customized drum “pitch” names (suitable for a custom drum style, for example) may be used both in printed and MIDI output by defining such variables as drumPitchNames, drumStyleTable and midiDrumPitches, as demonstrated here.

In short, this snippet

%% This snippet tries to amend
%% NR 2.5.1 Common notation for percussion - Custom percussion staves
%% http://lilypond.org/doc/v2.24/Documentation/notation/common-notation-for-percussion#custom-percussion-staves

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% To use custom drum pitch names for your score and midi you need to follow
%% this route:
%%
%%%%%%%%%%%%
%% LAYOUT:
%%%%%%%%%%%%
%%
%% (1) Define a name and put it in `drumPitchNames'
%%     This can be done at toplevel with
%%         drumPitchNames.my-name  = #'my-name
%%     It's possible to add an alias as well.
%% (2) Define how it should be printed
%%     Therefore put them into a top-level list, where each entry should
%%     be of the form:
%%         (my-name
%%           note-head-style-or-default
%%             articulation-type-or-#f
%%               staff-position)
%%     Example:
%%         #(define my-style
%%           '(
%%             (my-name default tenuto -1)
%%             ; ...
%%             ))
%% (3) Tell LilyPond to use these custom definitions, with
%%         drumStyleTable = #(alist->hash-table my-style)
%%     in a \layout or \with block
%%
%%     Now we're done for layout. Here is a short but complete example:
%%         \new DrumStaff
%%           \with { drumStyleTable = #(alist->hash-table my-style) }
%%           \drummode { my-name }
%%
%%%%%%%%%%%%
%% MIDI:
%%%%%%%%%%%%
%%
%% (1) Again at top-level, assign a pitch to your custom note name
%%         midiDrumPitches.my-name = ges
%%     Note that you have to use the name, which is in drumPitchNames, no alias
%% (2) Tell LilyPond to use this pitch(es), with
%%         drumPitchTable = #(alist->hash-table midiDrumPitches)
%%
%%     Example:
%%         \score {
%%            \new DrumStaff
%%             \with {
%%               drumStyleTable = #(alist->hash-table my-style)
%%               drumPitchTable = #(alist->hash-table midiDrumPitches)
%%             }
%%             \drummode { my-name4 }
%%           \layout {}
%%           \midi {}
%%         }
%%
%%%%%%%%%%%%
%% TESTING
%%%%%%%%%%%%
%%
%% To test whether all is fine, run the following sequence in terminal:
%%         lilypond my-file.ly
%%         midi2ly my-file.midi
%%         gedit my-file-midi.ly
%%
%% This will do the following:
%% 1. create pdf and midi
%% 2. transform the midi back to a .ly-file
%%    (note: midi2ly is not always good in correctly identifying enharmonic pitches)
%% 3. open this file in gedit (or use another editor)
%% Now watch what you've got.
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% FULL EXAMPLE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

drumPitchNames.dbass      = #'dbass
drumPitchNames.dba        = #'dbass  % 'db is in use already
drumPitchNames.dbassmute  = #'dbassmute
drumPitchNames.dbm        = #'dbassmute
drumPitchNames.do         = #'dopen
drumPitchNames.dopenmute  = #'dopenmute
drumPitchNames.dom        = #'dopenmute
drumPitchNames.dslap      = #'dslap
drumPitchNames.ds         = #'dslap
drumPitchNames.dslapmute  = #'dslapmute
drumPitchNames.dsm        = #'dslapmute

#(define djembe
  '((dbass      default  #f         -2)
    (dbassmute  default  stopped    -2)
    (dopen      default  #f          0)
    (dopenmute  default  stopped     0)
    (dslap      default  #f          2)
    (dslapmute  default  stopped     2)))

midiDrumPitches.dbass = g
midiDrumPitches.dbassmute = fis
midiDrumPitches.dopen =  a
midiDrumPitches.dopenmute = gis
midiDrumPitches.dslap =  b
midiDrumPitches.dslapmute = ais

one = \drummode { r4 dba4 do ds r dbm dom dsm }

\score {
   \new DrumStaff
    \with {
      \override StaffSymbol.line-count =  #3
      instrumentName = #"Djembe "
      drumStyleTable = #(alist->hash-table djembe)
      drumPitchTable = #(alist->hash-table midiDrumPitches)
    }
    \one
  \layout {}
  \midi {}
}

[image of music]


Indicacions polimètricques de compàs totalment personalitzades

Tot i que l’element més essencial no és la indicació polimètrica de compàs que es mostra, s’ha inclòs per mostrar la pulsació de la peça, que és la plantilla d’una cançó real dels Balcans.

melody = \relative c'' {
  \key g \major
  \compoundMeter #'((3 8) (2 8) (2 8) (3 8) (2 8) (2 8)
                    (2 8) (2 8) (3 8) (2 8) (2 8))
  c8 c c d4 c8 c b c b a4 g fis8 e d c b' c d e4-^ fis8 g \break
  c,4. d4 c4 d4. c4 d c2 d4. e4-^ d4
  c4. d4 c4 d4. c4 d c2 d4. e4-^ d4 \break
  c4. d4 c4 d4. c4 d c2 d4. e4-^ d4
  c4. d4 c4 d4. c4 d c2 d4. e4-^ d4 \break
}

drum = \new DrumStaff \drummode {
  \repeat volta 2 {
    bd4.^\markup { Drums } sn4 bd \bar ";"
    sn4. bd4 sn \bar ";"
    bd sn bd4. sn4 bd
  }
}

\new Staff \with {
  instrumentName = \markup { \concat { "B" \flat " Sop." } }
}

{
  \melody
  \drum
}

\paper { tagline = ##f }

[image of music]


High and Low woodblock example

Two Woodblocks, entered with ’wbh’ (high woodblock) and ’wbl’ (low woodblock). The length of the barline has been altered with an \override command otherwise it would be too short. The positions of the two stafflines also have to be explicitly defined.

\paper { tagline = ##f }

% These lines define the position of the woodblocks in the stave;
% if you like, you can change it or you can use special note heads
% for the woodblocks.
#(define mydrums '((hiwoodblock default #f  3)
                   (lowoodblock default #f -2)))

woodstaff = {
  % This defines a staff with only two lines.
  % It also defines the positions of the two lines.
  \override Staff.StaffSymbol.line-positions = #'(-2 3)

  % This is necessary; if not entered,
  % the barline would be too short!
  \override Staff.BarLine.bar-extent = #'(-1.0 . 1.5)
  % small correction for the clef:
  \set DrumStaff.clefPosition = 0.5
}

\new DrumStaff {
  % with this you load your new drum style table
  \set DrumStaff.drumStyleTable = #(alist->hash-table mydrums)

  \woodstaff

  \drummode {
    \time 2/4
    wbl8 16 16 8-> 8 |
    wbl8 16 16-> ~ 16 16 r8 |
  }
}

[image of music]


Plantilla per a combo de jazz

Això és una plantilla força avançada, per a un conjunt de jazz. Observeu que la notació de tots els instruments està a \key c \major (Do major). Això es refereix al to de concert; l’armadura es transporta automàticament si la música està dins d’una secció \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 { }
}

[image of music]


Símbols de cops de percussió

No hi ha de forma nativa els símbols gràfics per a instruments de percussió; no obstant, és possible incloure aquests símbols, ja sigui com un fitxer EPS extern o com a codi PostScript incrustat dins d’un element de marcatge, com es mostra en aquest exemple.

stick = \markup {
  \with-dimensions #'(0 . 5) #'(0 . 5)
  \postscript "
    0 6 translate
    0.8 -0.8 scale
    0 0 0 setrgbcolor
    [] 0 setdash
    1 setlinewidth
    0 setlinejoin
    0 setlinecap
    gsave [1 0 0 1 0 0] concat
    gsave [1 0 0 1 -3.5406095 -199.29342] concat
    gsave
    0 0 0 setrgbcolor
    newpath
    7.1434065 200.94354 moveto
    7.2109628 200.90454 7.2785188 200.86554 7.3460747 200.82654 curveto
    8.2056347 202.31535 9.0651946 203.80414 9.9247546 205.29295 curveto
    9.8571989 205.33195 9.7896429 205.37095 9.7220864 205.40996 curveto
    8.8625264 203.92115 8.0029664 202.43233 7.1434065 200.94354 curveto
    closepath
    eofill
    grestore
    gsave
    0 0 0 setrgbcolor
    newpath
    4.9646672 203.10444 moveto
    5.0036707 203.03688 5.0426744 202.96933 5.0816777 202.90176 curveto
    6.5704792 203.76133 8.0592809 204.6209 9.5480824 205.48045 curveto
    9.5090791 205.54801 9.4700754 205.61556 9.4310717 205.68311 curveto
    7.94227 204.82356 6.4534687 203.96399 4.9646672 203.10444 curveto
    closepath
    eofill
    grestore
    gsave
    <<
    /ShadingType 3
    /ColorSpace /DeviceRGB
    /Coords [113.13708 207.87465 0 113.13708 207.87465 16.162441]
    /Extend [true true]
    /Domain [0 1]
    /Function <<
    /FunctionType 3
    /Functions
    [
    <<
    /FunctionType 2
    /Domain [0 1]
    /C0 [1 1 1]
    /C1 [0.72941178 0.72941178 0.72941178]
    /N 1
    >>
    ]
    /Domain [0 1]
    /Bounds [ ]
    /Encode [ 0 1 ]
    >>
    >>
    newpath
    7.6422017 200.76488 moveto
    7.6505696 201.02554 7.3905363 201.24867 7.1341335 201.20075 curveto
    6.8759501 201.16916 6.6949602 200.87978 6.7801462 200.63381 curveto
    6.8480773 200.39155 7.1438307 200.25377 7.3728389 200.35861 curveto
    7.5332399 200.42458 7.6444521 200.59122 7.6422017 200.76488 curveto
    closepath
    clip
    gsave [
      0.052859054 0.063089841 -0.020912282 0.017521108 5.7334261 189.76443
    ] concat
    shfill
    grestore
    grestore
    0 0 0 setrgbcolor
    [] 0 setdash
    0.027282091 setlinewidth
    0 setlinejoin
    0 setlinecap
    newpath
    7.6422017 200.76488 moveto
    7.6505696 201.02554 7.3905363 201.24867 7.1341335 201.20075 curveto
    6.8759501 201.16916 6.6949602 200.87978 6.7801462 200.63381 curveto
    6.8480773 200.39155 7.1438307 200.25377 7.3728389 200.35861 curveto
    7.5332399 200.42458 7.6444521 200.59122 7.6422017 200.76488 curveto
    closepath
    stroke
    gsave
    <<
    /ShadingType 3
    /ColorSpace /DeviceRGB
    /Coords [113.13708 207.87465 0 113.13708 207.87465 16.162441]
    /Extend [true true]
    /Domain [0 1]
    /Function <<
    /FunctionType 3
    /Functions
    [
    <<
    /FunctionType 2
    /Domain [0 1]
    /C0 [1 1 1]
    /C1 [0.72941178 0.72941178 0.72941178]
    /N 1
    >>
    ]
    /Domain [0 1]
    /Bounds [ ]
    /Encode [ 0 1 ]
    >>
    >>
    newpath
    5.2721217 202.83181 moveto
    5.2804896 203.09247 5.0204563 203.3156 4.7640539 203.26768 curveto
    4.5058701 203.23609 4.3248803 202.94671 4.4100662 202.70074 curveto
    4.4779975 202.45848 4.7737511 202.3207 5.0027593 202.42554 curveto
    5.1631598 202.49149 5.2743721 202.65813 5.2721217 202.83181 curveto
    closepath
    clip
    gsave [
      0.052859054 0.063089841 -0.020912282 0.017521108 3.363346 191.83136
    ] concat
    shfill
    grestore
    grestore
    0 0 0 setrgbcolor
    [] 0 setdash
    0.027282091 setlinewidth
    0 setlinejoin
    0 setlinecap
    newpath
    5.2721217 202.83181 moveto
    5.2804896 203.09247 5.0204563 203.3156 4.7640539 203.26768 curveto
    4.5058701 203.23609 4.3248803 202.94671 4.4100662 202.70074 curveto
    4.4779975 202.45848 4.7737511 202.3207 5.0027593 202.42554 curveto
    5.1631598 202.49149 5.2743721 202.65813 5.2721217 202.83181 curveto
    closepath
    stroke
    grestore
    grestore
  "
}

\score {
  b1^\stick
}

[image of music]


Percussion example

A short example taken from Stravinsky’s L’histoire du Soldat.

#(define mydrums '((bassdrum   default #f  4)
                   (snare      default #f -4)
                   (tambourine default #f  0)))

\paper { tagline = ##f }

global = {
  \time 3/8 s4.
  \time 2/4 s2*2
  \time 3/8 s4.
  \time 2/4 s2
}

drumsA = {
  \context DrumVoice <<
    { \global }
    { \drummode {
        \autoBeamOff
        \stemDown sn8 \stemUp tamb s8 |
        sn4 \stemDown sn4 |
        \stemUp tamb8 \stemDown sn8 \stemUp sn16 \stemDown sn \stemUp sn8 |
        \stemDown sn8 \stemUp tamb s8 |
        \stemUp sn4 s8 \stemUp tamb
      }
    }
  >>
}

drumsB = {
  \drummode {
    s4 bd8 s2*2 s4 bd8 s4 bd8 s8
  }
}

\layout {
  indent = 40
  \context {
    \DrumStaff
    drumStyleTable = #(alist->hash-table mydrums)
  }
}

\score {
  \new StaffGroup <<
    \new DrumStaff \with {
      instrumentName = \markup \center-column {
        "Tambourine"
        "et"
        "caisse claire s. timbre"
        }
  }
  \drumsA
  \new DrumStaff \with {
    instrumentName = "Grosse Caisse"
  }
  \drumsB
  >>
}

[image of music]


Impressió de música que tingui compassos en cada pentagrama

En el següent fragment de codi, dues parts diferents tenen un compàs completament diferent i malgrat això es mantenen sincronitzades. Les barres de compàs ja no es poden imprimir en el nivell de Score; per permetre barres de compàs independents en cada part es tralladen els gravadores Default_barline_engraver i Timing_translator des del context de partitura Score fins el context de pentagrama Staff.

Si calen nombres de compàs, el gravador de nombres de compàs Bar_number_engraver també s’ha de traslladar, ja que descansa en propietat fixades pel Timing_translator; es pot usar un bloc \with per afegir nombres de compàs al pentagrama apropiat.

\paper {
  indent = #0
  ragged-right = ##t
  tagline = ##f
}

global = { \time 3/4 { s2.*3 } \bar "" \break { s2.*3 } }

\layout {
  \context {
    \Score
    \remove "Timing_translator"
    \remove "Bar_number_engraver"
    \override SpacingSpanner.uniform-stretching = ##t
    \override SpacingSpanner.strict-note-spacing = ##t
    proportionalNotationDuration = \musicLength 64
  }
  \context {
    \Staff
    \consists "Timing_translator"
  }
  \context {
    \Voice
    \remove "Forbid_line_break_engraver"
    tupletFullLength = ##t
  }
}

Bassklarinette = \new Staff \with {
  \consists "Bar_number_engraver"
  barNumberVisibility = #(every-nth-bar-number-visible 2)
  \override BarNumber.break-visibility = #end-of-line-invisible
} <<
  \global {
    \bar "|"
    \clef treble
    \time 3/8
    d''4.

    \bar "|"
    \time 3/4
    r8 des''2( c''8)

    \bar "|"
    \time 7/8
    r4. ees''2 ~

    \bar "|"
    \time 2/4
    \tupletUp
    \tuplet 3/2 { ees''4 r4 d''4 ~ }

    \bar "|"
    \time 3/8
    \tupletUp
    \tuplet 4/3 { d''4 r4 }

    \bar "|"
    \time 2/4
    e''2

    \bar "|"
    \time 3/8
    es''4.

    \bar "|"
    \time 3/4
    r8 d''2 r8
    \bar "|"
  }
>>

Perkussion = \new StaffGroup <<
  \new Staff <<
    \global {
      \bar "|"
      \clef percussion
      \time 3/4
      r4 c'2 ~

      \bar "|"
      c'2.

      \bar "|"
      R2.

      \bar "|"
      r2 g'4 ~

      \bar "|"
      g'2. ~

      \bar "|"
      g'2.
    }
  >>
  \new Staff <<
    \global {
      \bar "|"
      \clef percussion
      \time 3/4
      R2.

      \bar "|"
      g'2. ~

      \bar "|"
      g'2.

      \bar "|"
      r4 g'2 ~

      \bar "|"
      g'2 r4

      \bar "|"
      g'2.
    }
  >>
>>

\score {
  <<
    \Bassklarinette
    \Perkussion
  >>
}

[image of music]


Tam-tam example

A tam-tam example, entered with ’tt’

#(define mydrums '((tamtam default #f 0)))

\new DrumStaff \with { instrumentName = #"Tamtam" }

\drummode {
  \set DrumStaff.drumStyleTable = #(alist->hash-table mydrums)
  \override Staff.StaffSymbol.line-positions = #'( 0 )
  \override Staff.BarLine.bar-extent = #'(-1.5 . 1.5)

  tt 1 \pp \laissezVibrer
}

\paper { tagline = ##f }

[image of music]


Tambourine example

A tambourine example, entered ’tamb’

\paper { tagline = ##f }

#(define mydrums '((tambourine default #f 0)))

\new DrumStaff \with { instrumentName = #"Tambourine" }

\drummode {
  \set DrumStaff.drumStyleTable = #(alist->hash-table mydrums)
  \override Staff.StaffSymbol.line-positions = #'( 0 )
  \override Staff.BarLine.bar-extent = #'(-1.5 . 1.5)

  \time 6/8
  tamb8. 16 8 8 8 8 |
  tamb4. 8 8 8 |
  % the trick with the scaled duration and the shorter rest
  % is neccessary for the correct ending of the trill-span!
  tamb2.*5/6 \startTrillSpan s8 \stopTrillSpan |
}

[image of music]


Fretted strings

Fretted string instruments


Afegir digitacions a la partitura

Es poden escriure ordre de digitació usant una sintaxi molt senzilla.

\relative c'' {
  c4-1 d-2 f-4 e-3
}

[image of music]


Afegir digitacions a les tabulatures

Per afegir digitacions a les tabulatures, utilitzeu una combinació de \markup i \finger.

one = \markup { \finger 1 }
two = \markup { \finger 2 }
threeTwo = \markup {
  \override #'(baseline-skip . 2)
  \column {
    \finger 3
    \finger 2
  }
}
threeFour = \markup {
  \override #'(baseline-skip . 2)
  \column {
    \finger 3
    \finger 4
  }
}

\score {
  \new TabStaff {
    \tabFullNotation
    \stemUp
    e8\4^\one b\2 <g\3 e'\1>^>[ b\2 e\4]
    <a\3 fis'\1>^>^\threeTwo[ b\2 e\4]
  }
}

[image of music]


Adding markups in a tablature

By default markups does not show in a tablature.

To make them appear, simply use the command \revert TabStaff.TextScript.stencil

%% http://lsr.di.unimi.it/LSR/Item?id=919
% by P.P.Schneider on June 2014

high  = { r4 r8 <g c'> q r8 r4 }

low = { c4 r4 c8 r8 g,8 b, }

pulse = { s8^"1" s^"&" s^"2" s^"&" s^"3" s^"&" s^"4" s^"&" }

\score {
 \new TabStaff {
   \repeat unfold 2 << \high \\ \low \\ \pulse >>
  }
  \layout {
    \context {
      \TabStaff
      \clef moderntab
      \revert TextScript.stencil
      \override TextScript.font-series = #'bold
      \override TextScript.font-size = #-2
      \override TextScript.color = #red

    }
    \context {
      \Score
      proportionalNotationDuration = \musicLength 8
    }
  }
}

[image of music]


Permetre que les digitacions s’imprimeixen del pentagrama

Les xifres de digitació orientades verticalment es col·loquen de forma predeterminada fora del pentagrama. Malgrat això, aquest comportament es pot desactivar. Nota: s’ha d’usar una construcció d’acord <>, tot i que sigui una sola nota.

\relative c' {
  <c-1 e-2 g-3 b-5>2
  \override Fingering.staff-padding = #'()
  <c-1 e-2 g-3 b-5>4 g'-0
  a8[-1 b]-2 g-0 r
  \override Fingering.add-stem-support = ##f
  a[-1 b]-2 g-0 r
  \override Fingering.add-stem-support = ##t
  a[-1 b]-2 g-0 r
  \override Fingering.add-stem-support = #only-if-beamed
  a[-1 b]-2 g-0 r
}

[image of music]


Automatic Fretboards Barre

When automatic fretboards are used, barre indicators will be drawn whenever one finger is responsible for multiple strings.

If no finger indications are given in the chord from which the automatic fretboard is created, no barre indicators will be included, because there is no way to identify where barres should be placed.

\new FretBoards {
  <f,-1 c-3 f-4 a-2 c'-1 f'-1>1
  <f, c f a c' f'>1
}

[image of music]


Modificar l’orientació dels trastos

Els diagrames de posicions d’acords es poden orientar de tres formes. De manera predeterminada, s’alinea la corda o trast superior en les diferents alineacions.

\include "predefined-guitar-fretboards.ly"

<<
  \chords {
    c1
    c1
    c1
  }
  \new FretBoards {
    \chordmode {
      c1
      \override FretBoard.fret-diagram-details.orientation =
        #'landscape
      c1
      \override FretBoard.fret-diagram-details.orientation =
        #'opposing-landscape
      c1
    }
  }
  \new Voice {
    c'1
    c'1
    c'
  }
>>

[image of music]


Glissando d’acords en tabulatura

Els lliscaments per a acords s’indiquen per omissió tant al context Staff com a TabStaff. Els nombres de corda són necessaris per a TabStaff perquè els càlculs de corda automàtics són diferents per als acords i per a les notes soltes.

myMusic = \relative c' {
  <c e g>1 \glissando <f a c>
}

\score {
  <<
    \new Staff {
      \clef "treble_8"
      \myMusic
    }
    \new TabStaff \myMusic
  >>
}

\score {
  <<
    \new Staff {
      \clef "treble_8"
      \myMusic
    }
    \new TabStaff \with { \override Glissando.style = #'none } {
      \myMusic
    }
  >>
}

\paper { tagline = ##f }

[image of music]


Canvis d’acord de posicions de trastos

Es pot fer que els diagrames de posicions es mostren sols quan l’acord canvia o al començament d’una nova línia.

\include "predefined-guitar-fretboards.ly"

\paper { tagline = ##f }

myChords = \chordmode {
  c1 c1 \break
  \set chordChanges = ##t
  c1 c1 \break
  c1 c1
}

<<
  \new ChordNames { \myChords }
  \new FretBoards { \myChords }
  \new Staff { \myChords }
>>

[image of music]


Chords with stretched fingering for FretBoards and TabVoice

Sometimes chords with a stretched fingering are required. If not otherwise specified the context-property maximumFretStretch is set to 4, though. Resulting in a warning about "No string for pitch ..." and the note is omitted. You may set maximumFretStretch to an approppriate value or explecitely assign string-numbers to all notes of a chord.

%% The code below will print two warnings, which may be omitted by uncommenting:
%#(for-each (lambda (x) (ly:expect-warning "No string for pitch")) (iota 2))

mus = {
  <c' bes'>
  <c'\2 bes'>
  \set maximumFretStretch = 5
  <c' bes'>
  <c'\2 bes'\1>
}

<<
  \new FretBoards \mus
  \new TabVoice \mus
>>

[image of music]


Controlar la col·locación de les digitacions d’acords

Es pot controlar amb precisió la col·locació dels números de digitació. Perquè es tingui en compte l’orientació de les digitacions, es pot utilitzar una construcció d’acord <> tot i que siguin una sola nota.

\relative c' {
  \set fingeringOrientations = #'(left)
  <c-1 e-3 a-5>4
  \set fingeringOrientations = #'(down)
  <c-1 e-3 a-5>4
  \set fingeringOrientations = #'(down right up)
  <c-1 e-3 a-5>4
  \set fingeringOrientations = #'(up)
  <c-1 e-3 a-5>4
  \set fingeringOrientations = #'(left)
  <c-1>2
  \set fingeringOrientations = #'(down)
  <e-3>2
  \set stringNumberOrientations = #'(up left down)
  <f\3 a\2 c\1>1
  \set strokeFingerOrientations = #'(down right up)
  <c\rightHandFinger 1 e\rightHandFinger 2 c'\rightHandFinger 4 >
}

[image of music]


Personalitzar els diagrames de posicions

Es poden establir les propietats dels diagrames de posicions d’acords per mitjà de 'fret-diagram-details. Per als diagrames de posicions de FretBoard, s’apliquen els overrides (sobreescriptures) a l’objecte FretBoards.FretBoard. Com Voice, FretBoards és un context del nivell inferior, i per tant es pot ometre el seu nom a la sobreescriptura de propietats.

\include "predefined-guitar-fretboards.ly"

\storePredefinedDiagram #default-fret-table \chordmode { c' }
                        #guitar-tuning
                        "x;1-1-(;3-2;3-3;3-4;1-1-);"

% shorthand
oo = #(define-music-function
       (grob-path value)
       (list? scheme?)
       #{ \once \override $grob-path = #value #})

<<
  \new ChordNames {
    \chordmode { c1 | c | c | d }
  }
  \new FretBoards {
    % Set global properties of fret diagram
    \override FretBoards.FretBoard.size = 1.2
    \override FretBoard.fret-diagram-details.finger-code = #'in-dot
    \override FretBoard.fret-diagram-details.dot-color = #'white
    \chordmode {
      c
      \oo FretBoard.size #1.0
      \oo FretBoard.fret-diagram-details.barre-type #'straight
      \oo FretBoard.fret-diagram-details.dot-color #'black
      \oo FretBoard.fret-diagram-details.finger-code #'below-string
      c'
      \oo FretBoard.fret-diagram-details.barre-type #'none
      \oo FretBoard.fret-diagram-details.number-type #'arabic
      \oo FretBoard.fret-diagram-details.orientation #'landscape
      \oo FretBoard.fret-diagram-details.mute-string "M"
      \oo FretBoard.fret-diagram-details.label-dir #LEFT
      \oo FretBoard.fret-diagram-details.dot-color #'black
      c'
      \oo FretBoard.fret-diagram-details.finger-code #'below-string
      \oo FretBoard.fret-diagram-details.dot-radius #0.35
      \oo FretBoard.fret-diagram-details.dot-position #0.5
      \oo FretBoard.fret-diagram-details.fret-count #3
      d
    }
  }
  \new Voice {
    c'1 | c' | c' | d'
  }
>>

[image of music]


Personalitzar diagrames de posicions de marcatge

Es poden establir les propietats dels diagrames de posicions a través de 'fret-diagram-details. Per als diagrames de posicions de marcatge, es poden aplicar overrides (sobreescriptures) a l’objecte Voice.TextScript o directament a l’element de marcatge.

<<
  \chords { c1 | c | c | d }

  \new Voice = "mel" {
    \textLengthOn
    % Set global properties of fret diagram
    \override TextScript.size = 1.2
    \override TextScript.fret-diagram-details.finger-code = #'in-dot
    \override TextScript.fret-diagram-details.dot-color = #'white

    %% C major for guitar, no barre, using defaults
       % terse style
    c'1^\markup { \fret-diagram-terse "x;3-3;2-2;o;1-1;o;" }

    %% C major for guitar, barred on third fret
       % verbose style
       % size 1.0
       % roman fret label, finger labels below string, straight barre
    c'1^\markup {
      % standard size
      \override #'(size . 1.0) {
        \override #'(fret-diagram-details . (
                     (number-type . roman-lower)
                     (finger-code . in-dot)
                     (barre-type . straight))) {
          \fret-diagram-verbose #'((mute 6)
                                   (place-fret 5 3 1)
                                   (place-fret 4 5 2)
                                   (place-fret 3 5 3)
                                   (place-fret 2 5 4)
                                   (place-fret 1 3 1)
                                   (barre 5 1 3))
        }
      }
    }

    %% C major for guitar, barred on third fret
       % verbose style
       % landscape orientation, arabic numbers, M for mute string
       % no barre, fret label down or left, small mute label font
    c'1^\markup {
      \override #'(fret-diagram-details . (
                   (finger-code . below-string)
                   (number-type . arabic)
                   (label-dir . -1)
                   (mute-string . "M")
                   (orientation . landscape)
                   (barre-type . none)
                   (xo-font-magnification . 0.4)
                   (xo-padding . 0.3))) {
        \fret-diagram-verbose #'((mute 6)
                                 (place-fret 5 3 1)
                                 (place-fret 4 5 2)
                                 (place-fret 3 5 3)
                                 (place-fret 2 5 4)
                                 (place-fret 1 3 1)
                                 (barre 5 1 3))
      }
    }

    %% simple D chord
       % terse style
       % larger dots, centered dots, fewer frets
       % label below string
    d'1^\markup {
      \override #'(fret-diagram-details . (
                   (finger-code . below-string)
                   (dot-radius . 0.35)
                   (dot-position . 0.5)
                   (fret-count . 3))) {
        \fret-diagram-terse "x;x;o;2-1;3-2;2-3;"
      }
    }
  }
>>

[image of music]


Definició de posicions predefinides per a d’altres instruments

Es poden afegir diagrames de posicions predefinides per a instruments nous a més dels estàndard que s’usen per a la guitarra. Aquest fitxer mostra com es fa, definint una afinació nova i unes quantes posicions per al cuatro veneçolà.

Aquest fitxer també mostra com es poden incloure les digitacions als acords que s’usen com punts de referència per a la cerca d’acords a la taula, i mostrar-se al diagrama de posiciones i la tabulatura TabStaff, però no a la música.

Aquestes posicions no es poden transportar perquè contenen informació de les cordes. Hi ha plans per corregir això en un futur.

% add FretBoards for the Cuatro
%   Note: This section could be put into a separate file
%      predefined-cuatro-fretboards.ly
%      and \included into each of your compositions

cuatroTuning = #`(,(ly:make-pitch 0 6 0)
                  ,(ly:make-pitch 1 3 SHARP)
		  ,(ly:make-pitch 1 1 0)
		  ,(ly:make-pitch 0 5 0))

dSix = { <a\4 b\1 d\3 fis\2> }
dMajor = { <a\4 d\1 d\3 fis \2> }
aMajSeven = { <a\4 cis\1 e\3 g\2> }
dMajSeven = { <a\4 c\1 d\3 fis\2> }
gMajor = { <b\4 b\1 d\3 g\2> }

\storePredefinedDiagram #default-fret-table \dSix
                        #cuatroTuning
                        "o;o;o;o;"
\storePredefinedDiagram #default-fret-table \dMajor
                        #cuatroTuning
                        "o;o;o;3-3;"
\storePredefinedDiagram #default-fret-table \aMajSeven
                        #cuatroTuning
                        "o;2-2;1-1;2-3;"
\storePredefinedDiagram #default-fret-table \dMajSeven
                        #cuatroTuning
                        "o;o;o;1-1;"
\storePredefinedDiagram #default-fret-table \gMajor
                        #cuatroTuning
                        "2-2;o;1-1;o;"

% end of potential include file /predefined-cuatro-fretboards.ly


#(set-global-staff-size 16)

primerosNames = \chordmode {
  d:6 d a:maj7 d:maj7
  g
}
primeros = {
  \dSix \dMajor \aMajSeven \dMajSeven
  \gMajor
}

\score {
  <<
    \new ChordNames {
      \set chordChanges = ##t
      \primerosNames
    }

    \new Staff {
      \new Voice \with {
        \remove "New_fingering_engraver"
      }
      \relative c'' {
        \primeros
      }
    }

    \new FretBoards {
      \set Staff.stringTunings = #cuatroTuning
%      \override FretBoard
%        #'(fret-diagram-details string-count) = 4
      \override FretBoard.fret-diagram-details.finger-code = #'in-dot
      \primeros
    }

    \new TabStaff \relative c'' {
      \set TabStaff.stringTunings = #cuatroTuning
      \primeros
    }

  >>

  \layout {
    \context {
      \Score
      \override SpacingSpanner.base-shortest-duration =
        \musicLength 16
    }
  }
  \midi { }
}

[image of music]


Simular un hammer o lligat ascendent a una tabulatura

Es pot simular un “hammer” o lligat ascendent amb lligadures d’expressió.

\score {
  \new TabStaff {
    \relative c'' {
      \tabFullNotation
      c4( d) d( d)
      d2( c)
    }
  }
}

[image of music]


Digitacions - indicació del nombre de corda i digitacions de ma dreta

En aquest exemple es combinen les digitacions de la ma esquerra, indicacions del nombre de corda i digitacions de la ma dreta.

#(define RH rightHandFinger)

\relative c {
  \clef "treble_8"
  <c-3\5\RH 1 >4
  <e-2\4\RH 2 >4
  <g-0\3\RH 3 >4
  <c-1\2\RH 4 >4
}

[image of music]


Notació del flamenco

Per a la guitarra flamenca s’utilitzen certs elements de notació especials:

Gairebé totes les figures utilitzen fletxes combinades amb digitacions; amb els ventalls i els rasguejos, les notes s’imprimeixen amb cap sol al primer acord.

Aquest fragment de codi conté codi de tipus capçalera que es pot copiar com flamenco.ly i incloure’s en els documents font.

%%%%%%%  Cut here ----- Start 'flamenco.ly'

% Text indicators :
abanico = ^\markup\small { \italic Abanico }
rasgueado = ^\markup\small { \italic Ras. }
alzapua = ^\markup\small { \italic Alzapua }

% Finger stroke symbols :
strokeUp = \markup\combine\override #'(thickness . 1.3) \draw-line #'(0 . 2)\raise #2 \arrow-head #Y #UP ##f
strokeDown = \markup\combine\arrow-head #Y #DOWN ##f \override #'(thickness . 1.3) \draw-line #'(0 . 2)

% Golpe symbol :
golpe = \markup {
  \filled-box #'(0 . 1) #'(0 . 1) #0
  \hspace #-1.6
  \with-color #white
  \filled-box #'(0.15 . 0.85) #'(0.15 . 0.85) #0
}

% Strokes, fingers and golpe command :
RHp = \rightHandFinger #1
RHi = \rightHandFinger #2
RHm = \rightHandFinger #3
RHa = \rightHandFinger #4
RHx = \rightHandFinger #5
RHu = \rightHandFinger \strokeUp
RHd = \rightHandFinger \strokeDown
RHg = \rightHandFinger \golpe

% Just handy :)
tupletOff = {
  \once \omit TupletNumber
  \once \omit TupletBracket
}

tupletsOff = {
  \omit TupletNumber
  \override TupletBracket.bracket-visibility = #'if-no-beam
}

tupletsOn = {
  \override TupletBracket.bracket-visibility = #'default
  \undo \omit TupletNumber
}

headsOff = {
  \hide TabNoteHead
  \hide NoteHead
  \override NoteHead.no-ledgers = ##t
}

headsOn = {
  \override TabNoteHead.transparent = ##f
  \override NoteHead.transparent = ##f
  \override NoteHead.no-ledgers = ##f
}

%%%%%%%  Cut here ----- End 'flamenco.ly'
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

part = \relative c' {
  \set strokeFingerOrientations = #'(up)
  \key a\major
  <a, e' a cis e\RHu\RHi>8
  <a e' a cis e\RHd\RHi>8
  r4
  r2^\markup\golpe
  <a e' a cis e\RHu\RHi>8
  <a e' a cis e\RHd\RHi>8
  <a e' a cis e\RHu\RHi\RHg>8
  <a e' a cis e\RHd\RHi>8
  r2
  <a e' a cis e\RHu\RHa>16\rasgueado
  \headsOff
  <a e' a cis e\RHu\RHm>
  <a e' a cis e\RHu\RHi>
  <a e' a cis e\RHd\RHi>~
  \headsOn
  <a e' a cis e>2
  r4
  \tupletOff
  \tuplet 5/4 {
    <a e' a cis e\RHu\RHx>16\rasgueado
    \headsOff
    <a e' a cis e\RHu\RHa>
    <a e' a cis e\RHu\RHm>
    <a e' a cis e\RHu\RHi>
    <a e' a cis e\RHd\RHi>~
    \headsOn
  }
  <a e' a cis e>2
  r4
  \tupletsOff
  \tuplet 3/2 {
    <a e' a cis e\RHd\RHp>8\abanico
    \headsOff
    <a e' a cis e\RHu\RHx>
    <a e' a cis e\RHu\RHi>
    \headsOn
  }
  \tuplet 3/2 {
    <a e' a cis e\RHd\RHp>8
    \headsOff
    <a e' a cis e\RHu\RHx>
    <a e' a cis e\RHu\RHi>
    \headsOn
  }
  \tuplet 3/2 {
    <a e' a cis e\RHd\RHp>8
    \headsOff
    <a e' a cis e\RHu\RHx>
    <a e' a cis e\RHu\RHi>
    \headsOn
  }
  \tuplet 3/2 {
    <a e' a cis e\RHd\RHp>8
    \headsOff
    <a e' a cis e\RHu\RHx>
    <a e' a cis e\RHu\RHi>
    \headsOn
  }
  \tupletsOff
  \override Beam.positions = #'(2 . 2)
  \tuplet 3/2 {
    a8\RHp\alzapua
    <e' a\RHu\RHg>
    <e a\RHd>
  }
  \tuplet 3/2 {
    a,8\RHp
    <e' a\RHu\RHg>
    <e a\RHd>
  }
  \tuplet 3/2 {
    a,8\RHp
    <e' a\RHu\RHg>
    <e a\RHd>
  }
  \tuplet 3/2 {
    a,8\RHp
    <e' a\RHu\RHg>
    <e a\RHd>
  }
  \tupletsOn
  <a, e' a\RHu\RHm>1
  \bar "|."
}

\score {
  \new StaffGroup <<
    \context Staff = "part" <<
      \clef "G_8"
      {
        \part
      }
    >>
    \context TabStaff {
      \part
    }
  >>
  \layout {
    ragged-right = ##t
  }
}

\paper { tagline = ##f }

[image of music]


Diagrames de posicions d’acord, explicats i desenvolupats

Aquest fragment de codi presenta moltes possibilitat per obtenir diagrames de posicions d’acord i com ajustar-los.

<<
  \chords {
    a1 a \bar "||" \break
    \repeat unfold 3 {
      c c c d d \bar "||" \break
    }
  }

  \new Voice {
    % Set global properties of fret diagram
    \override TextScript.size = 1.2
    \override TextScript.fret-diagram-details
                .finger-code = #'below-string
    \override TextScript.fret-diagram-details
                .dot-color = #'black

    % 1
    %
    % A chord for ukulele.
    a'1^\markup
      \override #'(fret-diagram-details
                   . ((string-count . 4)
                      (dot-color . white)
                      (finger-code . in-dot)))
      \fret-diagram "4-2-2;3-1-1;2-o;1-o;"

    % 2
    %
    % A chord for ukulele, with formatting defined in definition
    % string: 1.2 * size, 4 strings, 4 frets, fingerings below,
    % string dot radius .35 of fret spacing, dot position 0.55 of
    % fret spacing.
    a'1^\markup
      \override #'(fret-diagram-details
                   . ((dot-color . white)
                      (open-string . "o")))
      \fret-diagram
        "s:1.2;w:4;h:3;f:2;d:0.35;p:0.55;4-2-2;3-1-1;2-o;1-o;"


    %%
    %% These chords will be in normal orientation
    %%


    % 3
    %
    % C major for guitar, barred on third fret: verbose style,
    % roman fret label, finger labels below string, straight barre.
    c'1^\markup
      % 110% of default size
      \override #'(size . 1.1)
      \override #'(fret-diagram-details
                   . ((number-type . roman-lower)
                      (finger-code . below-string)
                      (barre-type . straight)))
      \fret-diagram-verbose #'((mute 6)
                               (place-fret 5 3 1)
                               (place-fret 4 5 2)
                               (place-fret 3 5 3)
                               (place-fret 2 5 4)
                               (place-fret 1 3 1)
                               (barre 5 1 3))

    % 4
    %
    % C major for guitar, barred on third fret: double barre used
    % to test barre function, verbose style.
    c'1^\markup
      % 110% of default size
      \override #'(size . 1.1)
      \override #'(fret-diagram-details
                   . ((number-type . arabic)
                      (dot-label-font-mag . 0.9)
                      (finger-code . in-dot)
                      (fret-label-font-mag . 0.6)
                      (fret-label-vertical-offset . 0)
                      (label-dir . -1)
                      (mute-string . "M")
                      (xo-font-magnification . 0.4)
                      (xo-padding . 0.3)))
      \fret-diagram-verbose #'((mute 6)
                               (place-fret 5 3 1)
                               (place-fret 4 5 2)
                               (place-fret 3 5 3)
                               (place-fret 2 5 4)
                               (place-fret 1 3 1)
                               (barre 4 2 5)
                               (barre 5 1 3))

    % 5
    %
    % C major for guitar, with capo on third fret: verbose style.
    c'1^\markup
      % 110% of default size
      \override #'(size . 1.1)
      \override #'(fret-diagram-details
                   . ((number-type . roman-upper)
                      (dot-label-font-mag . 0.9)
                      (finger-code . none)
                      (fret-label-vertical-offset . 0.5)
                      (xo-font-magnification . 0.4)
                      (xo-padding . 0.3)))
      \fret-diagram-verbose #'((mute 6)
                               (capo 3)
                               (open 5)
                               (place-fret 4 5 1)
                               (place-fret 3 5 2)
                               (place-fret 2 5 3)
                               (open 1))

    % 6
    %
    % Simple D chord.
    d'1^\markup
      \override #'(fret-diagram-details
                   . ((finger-code . below-string)
                      (dot-radius . 0.35)
                      (string-thickness-factor . 0.3)
                      (dot-position . 0.5)
                      (fret-count . 3)))
      \fret-diagram-terse "x;x;o;2-1;3-2;2-3;"

    % 7
    %
    % Simple D chord, large top fret thickness.
    d'1^\markup
      \override #'(fret-diagram-details
                   . ((finger-code . below-string)
                      (dot-radius . 0.35)
                      (dot-position . 0.5)
                      (top-fret-thickness . 7)
                      (fret-count . 3)))
      \fret-diagram-terse "x;x;o;2-1;3-2;2-3;"


    %%
    %% These chords will be in landscape orientation
    %%
    \override TextScript.fret-diagram-details
                .orientation = #'landscape


    % 8
    %
    % C major for guitar, barred on third fret: verbose style,
    % roman fret label, finger labels below string, straight
    % barre.
    c'1^\markup
      % 110% of default size
      \override #'(size . 1.1)
      \override #'(fret-diagram-details
                   . ((number-type . roman-lower)
                      (finger-code . below-string)
                      (barre-type . straight)))
      \fret-diagram-verbose #'((mute 6)
                               (place-fret 5 3 1)
                               (place-fret 4 5 2)
                               (place-fret 3 5 3)
                               (place-fret 2 5 4)
                               (place-fret 1 3 1)
                               (barre 5 1 3))

    % 9
    %
    % C major for guitar, barred on third fret: Double barre
    % used to test barre function, verbose style.
    c'1^\markup
      % 110% of default size
      \override #'(size . 1.1)
      \override #'(fret-diagram-details
                   . ((number-type . arabic)
                      (dot-label-font-mag . 0.9)
                      (finger-code . in-dot)
                      (fret-label-font-mag . 0.6)
                      (fret-label-vertical-offset . 0)
                      (label-dir . -1)
                      (mute-string . "M")
                      (xo-font-magnification . 0.4)
                      (xo-padding . 0.3)))
      \fret-diagram-verbose #'((mute 6)
                               (place-fret 5 3 1)
                               (place-fret 4 5 2)
                               (place-fret 3 5 3)
                               (place-fret 2 5 4)
                               (place-fret 1 3 1)
                               (barre 4 2 5)
                               (barre 5 1 3))

    % 10
    %
    % C major for guitar, with capo on third fret: verbose style.
    c'1^\markup
      % 110% of default size
      \override #'(size . 1.1)
      \override #'(fret-diagram-details
                   . ((number-type . roman-upper)
                      (dot-label-font-mag . 0.9)
                      (finger-code . none)
                      (fret-label-vertical-offset . 0.5)
                      (xo-font-magnification . 0.4)
                      (xo-padding . 0.3)))
      \fret-diagram-verbose #'((mute 6)
                               (capo 3)
                               (open 5)
                               (place-fret 4 5 1)
                               (place-fret 3 5 2)
                               (place-fret 2 5 3)
                               (open 1))

    % 11
    %
    % Simple D chord.
    d'1^\markup
      \override #'(fret-diagram-details
                   . ((finger-code . below-string)
                      (dot-radius . 0.35)
                      (dot-position . 0.5)
                      (fret-count . 3)))
      \fret-diagram-terse "x;x;o;2-1;3-2;2-3;"

    % 12
    %
    % Simple D chord, large top fret thickness.
    d'1^\markup
      \override #'(fret-diagram-details
                   . ((finger-code . below-string)
                      (dot-radius . 0.35)
                      (dot-position . 0.5)
                      (top-fret-thickness . 7)
                      (fret-count . 3)))
      \fret-diagram-terse "x;x;o;2-1;3-2;2-3;"


    %%
    %% These chords will be in opposing-landscape orientation.
    %%
    \override TextScript.fret-diagram-details
                .orientation = #'opposing-landscape


    % 13
    %
    % C major for guitar, barred on third fret: verbose style,
    % roman fret label, finger labels below string, straight
    % barre.
    c'1^\markup
      % 110% of default size
      \override #'(size . 1.1)
      \override #'(fret-diagram-details
                   . ((number-type . roman-lower)
                      (finger-code . below-string)
                      (barre-type . straight)))
      \fret-diagram-verbose #'((mute 6)
                               (place-fret 5 3 1)
                               (place-fret 4 5 2)
                               (place-fret 3 5 3)
                               (place-fret 2 5 4)
                               (place-fret 1 3 1)
                               (barre 5 1 3))

    % 14
    %
    % C major for guitar, barred on third fret: double barre
    % used to test barre function, verbose style.
    c'1^\markup
      % 110% of default size
      \override #'(size . 1.1)
      \override #'(fret-diagram-details
                   . ((number-type . arabic)
                      (dot-label-font-mag . 0.9)
                      (finger-code . in-dot)
                      (fret-label-font-mag . 0.6)
                      (fret-label-vertical-offset . 0)
                      (label-dir . -1)
                      (mute-string . "M")
                      (xo-font-magnification . 0.4)
                      (xo-padding . 0.3)))
      \fret-diagram-verbose #'((mute 6)
                               (place-fret 5 3 1)
                               (place-fret 4 5 2)
                               (place-fret 3 5 3)
                               (place-fret 2 5 4)
                               (place-fret 1 3 1)
                               (barre 4 2 5)
                               (barre 5 1 3))

    % 15
    %
    % C major for guitar, with capo on third fret: verbose style.
    c'1^\markup
      % 110% of default size
      \override #'(size . 1.1)
      \override #'(fret-diagram-details
                   . ((number-type . roman-upper)
                      (dot-label-font-mag . 0.9)
                      (finger-code . none)
                      (fret-label-vertical-offset . 0.5)
                      (xo-font-magnification . 0.4)
                      (xo-padding . 0.3)))
      \fret-diagram-verbose #'((mute 6)
                               (capo 3)
                               (open 5)
                               (place-fret 4 5 1)
                               (place-fret 3 5 2)
                               (place-fret 2 5 3)
                               (open 1))

    % 16
    %
    % Simple D chord.
    d'1^\markup
      \override #'(fret-diagram-details
                   . ((finger-code . below-string)
                      (dot-radius . 0.35)
                      (dot-position . 0.5)
                      (fret-count . 3)))
      \fret-diagram-terse "x;x;o;2-1;3-2;2-3;"

    % 17
    %
    % Simple D chord, large top fret thickness.
    d'1^\markup
      \override #'(fret-diagram-details
                   . ((finger-code . below-string)
                      (dot-radius . 0.35)
                      (dot-position . 0.5)
                      (top-fret-thickness . 7)
                      (fret-count . 3)))
      \fret-diagram-terse "x;x;o;2-1;3-2;2-3;"
  }
>>


\paper {
  tagline = ##f
  ragged-right = ##t
  indent = 0
  system-system-spacing.basic-distance = 20
}

\layout {
  \context {
    \Score
    \override SpacingSpanner.spacing-increment = 3
  }
}

[image of music]


Taules alternatives de diagrames de posicions

Es poden crear taules alternatives de diagrames de posicions. S’utilitzarien per tenir diagrames alternatius per un acord donat.

Per usar una taula alternativa de diagrames de posicions, s’ha de crear primer la taula. Després s’afegeixen els diagrames a la taula.

La taula de diagrames de posicions que es crea pot estar buida o es pot copiar a partir d’una taula existent.

La taula a usar en la impressió dels diagrames predefinits se selecciona per mitjà de la propietat \predefinedDiagramTable.

\include "predefined-guitar-fretboards.ly"

% Make a blank new fretboard table
#(define custom-fretboard-table-one
   (make-fretboard-table))

% Make a new fretboard table as a copy of default-fret-table
#(define custom-fretboard-table-two
   (make-fretboard-table default-fret-table))

% Add a chord to custom-fretboard-table-one
\storePredefinedDiagram #custom-fretboard-table-one
                        \chordmode {c}
                        #guitar-tuning
                        "3-(;3;5;5;5;3-);"

% Add a chord to custom-fretboard-table-two
\storePredefinedDiagram #custom-fretboard-table-two
                        \chordmode {c}
                        #guitar-tuning
                        "x;3;5;5;5;o;"

<<
  \chords {
    c1 | d1 |
    c1 | d1 |
    c1 | d1 |
  }
  \new FretBoards {
    \chordmode {
      \set predefinedDiagramTable = #default-fret-table
      c1 | d1 |
      \set predefinedDiagramTable = #custom-fretboard-table-one
      c1 | d1 |
      \set predefinedDiagramTable = #custom-fretboard-table-two
      c1 | d1 |
    }
  }
  \new Staff {
    \clef "treble_8"
    <<
      \chordmode {
        c1 | d1 |
        c1 | d1 |
        c1 | d1 |
      }
      {
        s1_\markup "Default table" | s1 |
        s1_\markup \column {"New table" "from empty"} | s1 |
        s1_\markup \column {"New table" "from default"} | s1 |
      }
    >>
  }
>>

[image of music]


Harmònics sobre cordes pisades en tabulatura

Harmònics sobre cordes trepitjades (harmònics artificials):

pinchedHarmonics = {
  \textSpannerDown
  \override TextSpanner.bound-details.left.text =
    \markup {\halign #-0.5 \teeny "PH" }
  \override TextSpanner.style = #'dashed-line
  \override TextSpanner.dash-period = 0.6
  \override TextSpanner.bound-details.right.attach-dir = 1
  \override TextSpanner.bound-details.right.text =
    \markup { \draw-line #'(0 . 1) }
  \override TextSpanner.bound-details.right.padding = -0.5
}

harmonics = {
  % artificial harmonics (AH)
  \textLengthOn
  <\parenthesize b b'\harmonic>4_\markup { \teeny "AH 16" }
  <\parenthesize g g'\harmonic>4_\markup { \teeny "AH 17" }
  <\parenthesize d' d''\harmonic>2_\markup { \teeny "AH 19" }

  % pinched harmonics (PH)
  \pinchedHarmonics
  <a'\harmonic>2\startTextSpan
  <d''\harmonic>4
  <e'\harmonic>4\stopTextSpan

  % tapped harmonics (TH)
  <\parenthesize g\4 g'\harmonic>4_\markup { \teeny "TH 17" }
  <\parenthesize a\4 a'\harmonic>4_\markup { \teeny "TH 19" }
  <\parenthesize c'\3 c''\harmonic>2_\markup { \teeny "TH 17" }

  % touch harmonics (TCH)
  a4( <e''\harmonic>2. )_\markup { \teeny "TCH" }
}

frettedStrings = {
  % artificial harmonics (AH)
  \harmonicByFret 4 g4\3
  \harmonicByFret 5 d4\4
  \harmonicByFret 7 g2\3

  % pinched harmonics (PH)
  \harmonicByFret 7 d2\4
  \harmonicByFret 5 d4\4
  \harmonicByFret 7 a4\5

  % tapped harmonics (TH)
  \harmonicByFret 5 d4\4
  \harmonicByFret 7 d4\4
  \harmonicByFret 5 g2\3

  % touch harmonics (TCH)
  a4 \harmonicByFret 9 g2.\3
}

\score {
  <<
    \new Staff
    \with { \omit StringNumber } {
      \new Voice {
        \clef "treble_8"
        \harmonics
      }
    }
    \new TabStaff {
      \new TabVoice {
        \frettedStrings
      }
    }
  >>
}

[image of music]


Lligadures de guitarra

A diferència dels glissandos, els ‘slides’ o lligadures poden partir d’un punt imprecís del màstil fins un trast específic. Una bona forma de fer-ho es afegir una nota de mordent oculta abans de la nota real, com es mostra a l’exemple següent.

%% Hide fret number: useful to draw slide into/from a casual point of
%% the fretboard.

hideFretNumber = {
  \once \hide TabNoteHead
  \once \hide NoteHead
  \once \hide Stem
  \once \override NoteHead.no-ledgers = ##t
  \once \override Glissando.bound-details.left.padding = #0.3
}

music= \relative c' {
  \grace { \hideFretNumber d8\2 \glissando s2 } g2\2
  \grace { \hideFretNumber g8\2 \glissando s2 } d2 |

  \grace { \hideFretNumber c,8 \glissando s } f4\5^\markup \tiny { Slide into }
  \grace { \hideFretNumber f8 \glissando s } a4\4
  \grace { \hideFretNumber e'8\3 \glissando s } b4\3^\markup \tiny { Slide from }
  \grace { \hideFretNumber b'8 \glissando s2 } g4 |
}

\score {
  <<
    \new Staff {
      \clef "G_8"
      \music
    }
    \new TabStaff {
      \music
    }
  >>
}

\paper { tagline = ##f }

[image of music]


Ritmes rasguejats de guitarra

Per a la música de guitarra, és possible mostrar els ritmes de rasgueig, a més de les notes de la melodia, acords i diagrames de posicions.

\include "predefined-guitar-fretboards.ly"
<<
  \new ChordNames {
    \chordmode {
      c1 | f | g | c
    }
  }
  \new FretBoards {
    \chordmode {
      c1 | f | g | c
    }
  }
  \new Voice \with {
    \consists "Pitch_squash_engraver"
  } {
    \relative c'' {
      \improvisationOn
      c4 c8 c c4 c8 c
      f4 f8 f f4 f8 f
      g4 g8 g g4 g8 g
      c4 c8 c c4 c8 c
    }
  }
  \new Voice = "melody" {
    \relative c'' {
      c2 e4 e4
      f2. r4
      g2. a4
      e4 c2.
    }
  }
  \new Lyrics {
    \lyricsto "melody" {
      This is my song.
      I like to sing.
    }
  }
>>

[image of music]


Hammer on and pull off

Hammer-on and pull-off can be obtained using slurs.

\new TabStaff {
  \relative c' {
    d4( e\2)
    a( g)
  }
}

[image of music]


Hammer on and pull off using chords

When using hammer-on or pull-off with chorded notes, only a single arc is drawn. However “double arcs” are possible by setting the doubleSlurs property to #t.

\new TabStaff {
  \relative c' {
    % chord hammer-on and pull-off
    \set doubleSlurs = ##t
    <g' b>8( <a c> <g b>)
  }
}

[image of music]


Hammer on and pull off using voices

The arc of hammer-on and pull-off is upwards in voices one and three and downwards in voices two and four:

\new TabStaff {
  \relative c' {
    << { \voiceOne g2( a) }
    \\ { \voiceTwo a,( b) }
    >> \oneVoice
  }
}

[image of music]


Com canviar la posició d’un diagrama de posicions

Si volem moure un diagrama de posicions d’acord, per exemple, per evitar una col·lisió, o situar-lo entre dues notes, tenim diverses possibilitats:

1) modificar els valors de farciment #’padding o del desplaçament addicional #’extra-offset (como es mostra en el primer exemple)

2) podem afegir una veu invisible i adjuntar els diagrames de posicions a les notes invisibles d’aquesta veu (com es veu en el segon exemple).

Si hem de moure el diagrama segons una posició rítmica dins del compàs (a l’exemple, la tercera part del compàs) és millor el segon exemple, perquè el diagrama s’alinea amb la tercera pulsació per si sol

\header { tagline = ##f }

harmonies = \chordmode
{
  a8:13
% THE FOLLOWING IS THE COMMAND TO MOVE THE CHORD NAME
  \once \override ChordNames.ChordName.extra-offset = #'(10 . 0)
  b8:13 s2.
% THIS LINE IS THE SECOND METHOD
    s4 s4  b4:13
}

\score
{
  <<
    \new ChordNames \harmonies
    \new Staff
    {a8^\markup { \fret-diagram  "6-x;5-0;4-2;3-0;2-0;1-2;"  }
% THE FOLLOWING IS THE COMMAND TO MOVE THE FRET DIAGRAM
     \once \override TextScript.extra-offset = #'(10 . 0)
     b4.~^\markup { \fret-diagram  "6-x;5-2;4-4;3-2;2-2;1-4;"  } b4. a8\break
% HERE IS THE SECOND METHOD
     <<
       { a8 b4.~ b4. a8}
       { s4 s4 s4^\markup { \fret-diagram  "6-x;5-2;4-4;3-2;2-2;1-4;"  }
       }
     >>
   }
  >>
}

[image of music]


Plantilla per a combo de jazz

Això és una plantilla força avançada, per a un conjunt de jazz. Observeu que la notació de tots els instruments està a \key c \major (Do major). Això es refereix al to de concert; l’armadura es transporta automàticament si la música està dins d’una secció \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 { }
}

[image of music]


Lligaduras “Laissez vibrer”

Les lligadures “Laissez vibrer” (deixar vibrar) tenen una mida fixa. Es pot ajustar el seu format usant 'tie-configuration.

\relative c' {
  <c e g>4\laissezVibrer r <c f g>\laissezVibrer r
  <c d f g>4\laissezVibrer r <c d f g>4.\laissezVibrer r8

  <c d e f>4\laissezVibrer r
  \override LaissezVibrerTieColumn.tie-configuration
     = #`((-7 . ,DOWN)
          (-5 . ,DOWN)
          (-3 . ,UP)
          (-1 . ,UP))
  <c d e f>4\laissezVibrer r
}

[image of music]


Let TabStaff print the topmost string at bottom

In tablatures usually the first string is printed topmost. If you want to have it at the bottom change the stringOneTopmost-context-property. For a context-wide setting this could be done in layout as well.

%\layout {
%  \context {
%    \Score
%    stringOneTopmost = ##f
%  }
%  \context {
%    \TabStaff
%    tablatureFormat = #fret-letter-tablature-format
%  }
%}

m = {
  \cadenzaOn
  e, b, e gis! b e'
  \bar "||"
}

<<
  \new Staff { \clef "G_8" <>_"default" \m <>_"italian (historic)"\m }
  \new TabStaff
  {
    \m
    \set Score.stringOneTopmost = ##f
    \set TabStaff.tablatureFormat = #fret-letter-tablature-format
    \m
  }
>>

[image of music]


Donar format a tabulatures amb lletres

Es pot donar format a la tabulatura usant lletres en comptes de nombres.

music = \relative c {
  c4 d e f
  g4 a b c
  d4 e f g
}

<<
  \new Staff {
    \clef "G_8"
    \music
  }
  \new TabStaff \with {
    tablatureFormat = #fret-letter-tablature-format
  }
  {
    \music
  }
>>

[image of music]


Referència per a armònics sobre cordes a l’aire

Referència per a armònics sobre cordes a l’aire (armònics naturals):

openStringHarmonics = {
  \textSpannerDown
  \override TextSpanner.staff-padding = 3
  \override TextSpanner.dash-fraction = 0.3
  \override TextSpanner.dash-period = 1

  %first harmonic
  \override TextSpanner.bound-details.left.text =
    \markup\small "1st harm. "
  \harmonicByFret 12 e,2\6\startTextSpan
  \harmonicByRatio #1/2 e,\6\stopTextSpan

  %second harmonic
  \override TextSpanner.bound-details.left.text =
    \markup\small "2nd harm. "
  \harmonicByFret 7 e,\6\startTextSpan
  \harmonicByRatio #1/3 e,\6
  \harmonicByFret 19 e,\6
  \harmonicByRatio #2/3 e,\6\stopTextSpan
  %\harmonicByFret 19 < e,\6 a,\5 d\4 >
  %\harmonicByRatio #2/3 < e,\6 a,\5 d\4 >

  %third harmonic
  \override TextSpanner.bound-details.left.text =
    \markup\small "3rd harm. "
  \harmonicByFret 5 e,\6\startTextSpan
  \harmonicByRatio #1/4 e,\6
  \harmonicByFret 24 e,\6
  \harmonicByRatio #3/4 e,\6\stopTextSpan
  \break

  %fourth harmonic
  \override TextSpanner.bound-details.left.text =
    \markup\small "4th harm. "
  \harmonicByFret 4 e,\6\startTextSpan
  \harmonicByRatio #1/5 e,\6
  \harmonicByFret 9 e,\6
  \harmonicByRatio #2/5 e,\6
  \harmonicByFret 16 e,\6
  \harmonicByRatio #3/5 e,\6\stopTextSpan

  %fifth harmonic
  \override TextSpanner.bound-details.left.text =
    \markup\small "5th harm. "
  \harmonicByFret 3 e,\6\startTextSpan
  \harmonicByRatio #1/6 e,\6\stopTextSpan
  \break

  %sixth harmonic
  \override TextSpanner.bound-details.left.text =
    \markup\small "6th harm. "
  \harmonicByFret 2.7 e,\6\startTextSpan
  \harmonicByRatio #1/7 e,\6\stopTextSpan

  %seventh harmonic
  \override TextSpanner.bound-details.left.text =
    \markup\small "7th harm. "
  \harmonicByFret 2.3 e,\6\startTextSpan
  \harmonicByRatio #1/8 e,\6\stopTextSpan

  %eighth harmonic
  \override TextSpanner.bound-details.left.text =
    \markup\small "8th harm. "
  \harmonicByFret 2 e,\6\startTextSpan
  \harmonicByRatio #1/9 e,\6\stopTextSpan
}

\score {
  <<
    \new Staff
    \with { \omit StringNumber } {
      \new Voice {
        \clef "treble_8"
        \openStringHarmonics
      }
    }
    \new TabStaff {
      \new TabVoice {
        \openStringHarmonics
      }
    }
  >>
}

\paper { tagline = ##f }

[image of music]


Posicionament de digitacions de mà dreta

És possible exercir un control més gran sobre la col·locació de les digitacions de la mà dreta establint el valor d’una propietat específica, com es mostra a l’exemple següent. Nota: s’ha d’usar una construcció d’acord.

#(define RH rightHandFinger)

\relative c {
  \clef "treble_8"

  \set strokeFingerOrientations = #'(up down)
  <c\RH 1 e\RH 2 g\RH 3 c\RH 4 >4

  \set strokeFingerOrientations = #'(up right down)
  <c\RH 1 e\RH 2 g\RH 3 c\RH 4 >4

  \set strokeFingerOrientations = #'(left)
  <c\RH 1 e\RH 2 g\RH 3 c\RH 4 >2

  \set strokeFingerOrientations = #'(right)
  c\RH 1
}

[image of music]


Polifonia en tabulatures

La polifonia es crea de la mateixa forma en un TabStaff que en una pauta normal.

upper = \relative c' {
  \time 12/8
  \key e \minor
  \voiceOne
  r4. r8 e, fis g16 b g e e' b c b a g fis e
}

lower = \relative c {
  \key e \minor
  \voiceTwo
  r16 e d c b a g4 fis8 e fis g a b c
}

\score {
  <<
    \new StaffGroup = "tab with traditional" <<
      \new Staff = "guitar traditional" <<
        \clef "treble_8"
        \new Voice = "upper" \upper
        \new Voice = "lower" \lower
      >>
      \new TabStaff = "guitar tab" <<
        \new TabVoice = "upper" \upper
        \new TabVoice = "lower" \lower
      >>
    >>
  >>
}

[image of music]


Lliscats en tabulatura

Els lliscats es poden gravar tant als contextos de Staff como en los de TabStaff:

slides = {
  c'8\3(\glissando d'8\3)
  c'8\3\glissando d'8\3
  \hideNotes
  \grace { g16\glissando }
  \unHideNotes
  c'4\3
  \afterGrace d'4\3\glissando {
  \stemDown \hideNotes
  g16 }
  \unHideNotes
}

\score {
  <<
    \new Staff { \clef "treble_8" \slides }
    \new TabStaff { \slides }
  >>
  \layout {
    \context {
      \Score
      \override Glissando.minimum-length = 4
      \override Glissando.springs-and-rods =
                          #ly:spanner::set-spacing-rods
      \override Glissando.thickness = 2
      \omit StringNumber
      % or:
      %\override StringNumber.stencil = ##f
    }
  }
}

[image of music]


Comportament de les pliques i les barres de corxera en tabulatures

La direcció de les pliques es controla de la mateixa forma a la tabulatura que en la notació tradicional. Les barres es poden posar horitzontals, com es mostra en aquest exemple.

\new TabStaff {
  \relative c {
    \tabFullNotation
    g16 b d g b d g b
    \stemDown
    \override Beam.concaveness = 10000
    g,,16 b d g b d g b
  }
}

[image of music]


Línies d’extensió per a nombre de corda

Fem una línia extensora per a les indicacions de nombre de corda, mostrant que una sèrie de notes s’han de tocar sobre la mateixa corda.

stringNumberSpanner =
  #(define-music-function (StringNumber) (string?)
    #{
      \override TextSpanner.style = #'solid
      \override TextSpanner.font-size = #-5
      \override TextSpanner.bound-details.left.stencil-align-dir-y = #CENTER
      \override TextSpanner.bound-details.left.text =
        \markup { \circle \number $StringNumber }
    #})


\relative c {
  \clef "treble_8"
  \stringNumberSpanner "5"
  \textSpannerDown
  a8\startTextSpan
  b c d e f\stopTextSpan
  \stringNumberSpanner "4"
  g\startTextSpan a
  bes4 a g2\stopTextSpan
}

[image of music]


Unfretted strings

Unfretted string instruments


Fer lligadures entre veus diferents

En determinades situacions cal crear lligadures d’expressió entre notes que estan a veus diferents.

La solució és afegir notes invisible a una de les veus utilitzant \hideNotes.

Aquest exemple és el compàs 235 de la Chacona de la segona Partita per a violí sol, BMW 1004, de Bach.

\relative c' {
  <<
    {
      d16( a') s a s a[ s a] s a[ s a]
    }
    \\
    {
      \slurUp
      bes,16[ s e](
      \hideNotes a)
      \unHideNotes f[(
      \hideNotes a)
      \unHideNotes fis](
      \hideNotes a)
      \unHideNotes g[(
      \hideNotes a)
      \unHideNotes gis](
      \hideNotes a)
    }
  >>
}

[image of music]


Harmònics amb puntet

Els harmònics artificials que usen l’ordre \harmonic no tenen puntet. Per sobreescriure aquest comportament, fixeu la propietat de context harmonicDots.

\relative c''' {
  \time 3/4
  \key f \major
  \set harmonicDots = ##t
  <bes f'\harmonic>2. ~
  <bes f'\harmonic>4. <a e'\harmonic>8( <gis dis'\harmonic> <g d'\harmonic>)
  <fis cis'\harmonic>2.
  <bes f'\harmonic>2.
}

[image of music]


Pizzicato “snap” o pizzicato de Bartók

El “snap-pizzicato” (pizzicato de pessigada, conegut també com “pizzicato de Bartók”) és un “pizzicato fort en el qual la corda es polsa verticalment pessigant-la i fent que reboti contra el diapasó de l’instrument” (Wikipedia). Es doneta mitjançant un cercle com una línia vertical que surt del centre del cercla cap amunt.

\relative c' {
  c4\snappizzicato
  <c' e g>4\snappizzicato
  <c' e g>4^\snappizzicato
  <c, e g>4_\snappizzicato
}

[image of music]


Plantilla de quartet de cordas (senzilla)

Aquesta plantilla mostra un quartet de corda normal. També utilitza una secció \global per al compàs i l’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 { }
}

[image of music]


Plantilla de quartet de corda amb particel·les independents

El fragment de codi “Plantilla de quartet de corda” produeix un resultat satisfactori per al quartet, però, i si hem d’imprimir les particel·les? Aquesta nova plantilla mostra com usar la funcionalitat \tag (etiqueta) per dividir fàcilment una peça en particel·les individuals.

Hem de dividir aquesta plantilla en fitxers independents; els noms de fitxer estan dins dels comentaris al principi de cada fitxer. piece.ly conté totes les definicions de música. Els altres fitxers (score.ly, vn1.ly, vn2.ly, vla.ly i vlc.ly) produeixen la particel·la corresponent.

No oblideu treure els comentaris que hem especificat quan useu els fitxers independents!

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

%}

[image of music]


Winds

Wind instruments


Modificar la mida dels diagrames de vent fusta

Es pot canviar la mida i el gruix de les línies dels diagrames de posicions per a instruments de vent fusta.

\relative c'' {
  \textLengthOn
  c1^\markup
    \woodwind-diagram
      #'piccolo
      #'()

  c^\markup
    \override #'(size . 1.5) {
      \woodwind-diagram
        #'piccolo
        #'()
    }
  c^\markup
    \override #'(thickness . 0.15) {
      \woodwind-diagram
        #'piccolo
        #'()
    }
}

[image of music]


Símbols de digitació per a instruments de vent

Es poden aconseguir símbols especials combinant glifs existents, cosa que és d’utiitat per a la notació d’instruments de vent.

mymarkup = {
  \once \override TextScript.outside-staff-padding = 0
  \once \override TextScript.staff-padding = 0
  \once \override TextScript.padding = 0.2
  \once \override TextScript.X-offset =
    #(lambda (g)
       (+ (ly:self-alignment-interface::centered-on-x-parent g)
          (ly:self-alignment-interface::x-aligned-on-self g)))
}

\relative c' {
  g\open
  \mymarkup
  g^\markup \combine
      \musicglyph "scripts.open"
      \musicglyph "scripts.tenuto"
  \mymarkup
  g^\markup \combine
      \musicglyph "scripts.open"
      \musicglyph "scripts.stopped"
  g\stopped
}

[image of music]


Notació dels cops de llengua de la flauta

És possible indicar tècniques d’articulació especial com el cop de llengua de la flauta substituint el cap de la figura amb el glif adequat.

slap =
#(define-music-function (music) (ly:music?)
#{
  \temporary \override NoteHead.stencil = #ly:text-interface::print
  \temporary \override NoteHead.text =
    \markup
    \translate #'(1 . 0)
    \override #'(thickness . 1.4)
    \overlay {
      \draw-line #'(-1.2 . 0.4)
      \draw-line #'(-1.2 . -0.4)
    }
  \temporary \override NoteHead.stem-attachment =
  #(lambda (grob)
     (let* ((stem (ly:grob-object grob 'stem))
            (dir (ly:grob-property stem 'direction UP))
            (is-up (eqv? dir UP)))
       (cons dir (if is-up 0 -0.8))))
  #music
  \revert NoteHead.stencil
  \revert NoteHead.text
  \revert NoteHead.stem-attachment
#})

\relative c' {
  c4 \slap c d r
  \slap { g4 a } b r
}

[image of music]


Diagrames per a vent fusta gràfics i textuals

En molts casos, les claus que no estan en la columna central es poden presentar pel nombre de la clau així com de forma gràfic.

\relative c'' {
  \textLengthOn
  c1^\markup
    \woodwind-diagram
      #'piccolo
      #'((cc . (one three))
         (lh . (gis))
         (rh . (ees)))

  c^\markup
    \override #'(graphical . #f) {
      \woodwind-diagram
        #'piccolo
        #'((cc . (one three))
           (lh . (gis))
           (rh . (ees)))
    }
}

[image of music]


Diagrames de digitació per a la flauta dolça

L’exemple següent mostra com es poden realitzar diagrames de digitació per a instruments de vent.

% range chart for paetzold contrabass recorder

centermarkup = {
  \once \override TextScript.self-alignment-X = #CENTER
  \once \override TextScript.X-offset = #(lambda (g)
    (+ (ly:self-alignment-interface::centered-on-x-parent g)
       (ly:self-alignment-interface::x-aligned-on-self g)))
}

\score {
  \new Staff \with {
    \remove "Time_signature_engraver"
    \omit Stem
    \omit Flag
    \consists "Horizontal_bracket_engraver"
  }
  {
    \clef bass
    \set Score.timing = ##f
    f,1*1/4 \glissando
    \clef violin
    gis'1*1/4
    \stemDown a'4^\markup "1)"
    \centermarkup
    \once \override TextScript.padding = 2
    bes'1*1/4_\markup \override #'(baseline-skip . 1.7) \column
      { \fontsize #-5 \slashed-digit #0 \finger 1 \finger 2
        \finger 3 \finger 4 \finger 5 \finger 6 \finger 7 }
    b'1*1/4
    c''4^\markup "1)"
    \centermarkup
    \once \override TextScript.padding = 2
    cis''1*1/4
    deh''1*1/4
    \centermarkup
    \once \override TextScript.padding = 2
    \once \override Staff.HorizontalBracket.direction = #UP
    e''1*1/4_\markup \override #'(baseline-skip . 1.7) \column
      { \fontsize #-5 \slashed-digit #0 \finger 1 \finger 2
        \finger 4 \finger 5}\startGroup
    f''1*1/4^\markup "2)"\stopGroup
  }
}

[image of music]


Llistes de claus per als diagrames de vent fusta

El fragment de codi que apareix a continuació produeix una llista de totes les claus i disposicions de clau possible per als diagrames de posicions d’instruments de fusta, tal i com estan definits a scm/define-woodwind-diagrams.scm. La llista es mostra al fitxer de registre, però no a la música. Si es vol una sortida per la consola, ometeu el (current-error-port) de les ordres.

#(print-keys-verbose 'piccolo (current-error-port))
#(print-keys-verbose 'flute (current-error-port))
#(print-keys-verbose 'flute-b-extension (current-error-port))
#(print-keys-verbose 'tin-whistle (current-error-port))
#(print-keys-verbose 'oboe (current-error-port))
#(print-keys-verbose 'clarinet (current-error-port))
#(print-keys-verbose 'bass-clarinet (current-error-port))
#(print-keys-verbose 'low-bass-clarinet (current-error-port))
#(print-keys-verbose 'saxophone (current-error-port))
#(print-keys-verbose 'soprano-saxophone (current-error-port))
#(print-keys-verbose 'alto-saxophone (current-error-port))
#(print-keys-verbose 'tenor-saxophone (current-error-port))
#(print-keys-verbose 'baritone-saxophone (current-error-port))
#(print-keys-verbose 'bassoon (current-error-port))
#(print-keys-verbose 'contrabassoon (current-error-port))

\score {c''1}

[image of music]


Llistat dels diagrames per a vent fusta

El fragment de música que apareix a continuació presenta tots els diagrames de vent fusta que es troben definits al LilyPond de moment.

\layout {
  indent = 0
}

\relative c' {
  \textLengthOn
  c1^
  \markup {
    \center-column {
      'tin-whistle
      " "
       \woodwind-diagram
                  #'tin-whistle
                  #'()
    }
  }

  c1^
  \markup {
    \center-column {
      'piccolo
      " "
       \woodwind-diagram
                  #'piccolo
                  #'()
    }
  }

  c1^
  \markup {
    \center-column {
       'flute
       " "
       \woodwind-diagram
          #'flute
          #'()
    }
  }
  c1^\markup {
    \center-column {
      'oboe
      " "
      \woodwind-diagram
        #'oboe
        #'()
    }
  }

  c1^\markup {
    \center-column {
      'clarinet
      " "
      \woodwind-diagram
        #'clarinet
        #'()
    }
  }

  c1^\markup {
    \center-column {
      'bass-clarinet
      " "
      \woodwind-diagram
        #'bass-clarinet
        #'()
    }
  }

  c1^\markup {
    \center-column {
      'saxophone
      " "
      \woodwind-diagram
        #'saxophone
        #'()
    }
  }

  c1^\markup {
    \center-column {
      'bassoon
      " "
      \woodwind-diagram
        #'bassoon
        #'()
    }
  }

  c1^\markup {
    \center-column {
      'contrabassoon
      " "
      \woodwind-diagram
        #'contrabassoon
        #'()
    }
  }
}

[image of music]


Ancient notation

Ancient notation


Afegir un baix xifrat a sobre o a sota de les notes

En escriure un baix xifrat, podem ubicar les xifres a sobre a o a sota de les notes del baix, mitjançant la definició de la propietat BassFigureAlignmentPositioning #'direction (exclusivament dins d’un context Staff). es pot escollir entre #UP (o #1, a sobre), #CENTER (o #0, centraat) i #DOWN (o #-1, a sota).

Aquesta propietat es pot canviar tantes vegades com volem. Utilitzeu \once \override si no voleu que la sobreescriptura s’apliqui a tota la partitura.

bass = {
  \clef bass
  g4 b, c d
  e d8 c d2
}

continuo = \figuremode {
  <_>4 <6>4 <5/>4
  \override Staff.BassFigureAlignmentPositioning.direction = #UP
  %\bassFigureStaffAlignmentUp
  < _+ >4 <6>
  \set Staff.useBassFigureExtenders = ##t
  \override Staff.BassFigureAlignmentPositioning.direction = #DOWN
  %\bassFigureStaffAlignmentDown
  <4>4. <4>8 <_+>4
}

\score {
  <<
    \new Staff = bassStaff \bass
    \context Staff = bassStaff \continuo
  >>
}

[image of music]


Ancient fonts

Aquí es mostren molts dels símbols del Lilypond per a la musica antiga.

\paper { tagline = ##f }

m = { c1 e f ges cis' \bar "||" }

\score {
  \new VaticanaVoice {
    \override NoteHead.style = #'vaticana.punctum
    \key es \major
    \textMark \markup \rounded-box "Vaticana clefs, custos and note heads"
    \clef "vaticana-fa2"
    <>^"vaticana.punctum"
    \m

    \override NoteHead.style = #'vaticana.inclinatum
    <>^"vaticana.inclinatum"
    \m

    \override NoteHead.style = #'vaticana.quilisma
    <>^"vaticana.quilisma"
    \m
    \clef "vaticana-fa1"

    \override NoteHead.style = #'vaticana.plica
    <>^"vaticana.plica"
    \m

    \override NoteHead.style = #'vaticana.reverse.plica
    <>^"vaticana.reverse.plica"
    \m

    \override NoteHead.style = #'vaticana.punctum.cavum
    <>^"vaticana.punctum.cavum"
    \m

    \override NoteHead.style = #'vaticana.lpes
    <>^"vaticana.punctum.lpes"
    \m

    \override NoteHead.style = #'vaticana.upes
    <>^"vaticana.punctum.upes"
    \m

    \override NoteHead.style = #'vaticana.vupes
    <>^"vaticana.punctum.vupes"
    \m

    \override NoteHead.style = #'vaticana.linea.punctum
    <>^"vaticana.punctum.linea"
    \m

    \override NoteHead.style = #'vaticana.epiphonus
    <>^"vaticana.punctum.epiphonus"
    \m

    \override NoteHead.style = #'vaticana.cephalicus
    <>^"vaticana.punctum.cephalicus"
    \m

    \break

    \textMark \markup \rounded-box "Medicaea clefs, custos and note heads"

    \set VaticanaStaff.alterationGlyphs =
      #alteration-medicaea-glyph-name-alist
    \override VaticanaStaff.Custos.style = #'medicaea
    \clef "medicaea-fa2"

    \override NoteHead.style = #'medicaea.punctum
    <>^"medicaea.punctum"
    \m
    \clef "medicaea-do2"

    \override NoteHead.style = #'medicaea.inclinatum
    <>^"medicaea.inclinatum"
    \m

    \override NoteHead.style = #'medicaea.virga
    <>^"medicaea.virga"
    \m
    \clef "medicaea-fa1"

    \override NoteHead.style = #'medicaea.rvirga
    <>^"medicaea.rvirga"
    \m

    \break

    \textMark \markup \rounded-box "Hufnagel clefs, custos and note heads"

    \set Staff.alterationGlyphs =
      #alteration-hufnagel-glyph-name-alist
    \override VaticanaStaff.Custos.style = #'hufnagel
    \clef "hufnagel-fa2"

    \break

    \override NoteHead.style = #'hufnagel.punctum
    <>^"hufnagel.punctum"
    \m
    \clef "hufnagel-do2"

    \override NoteHead.style = #'hufnagel.lpes
    <>^"hufnagel.lpes"
    \m
    \clef "hufnagel-do-fa"

    \override NoteHead.style = #'hufnagel.virga
    <>^"hufnagel.virga"
    \m
  }
  \layout {
    indent = 0.0
    \context {
      \Score
      \override TextScript.font-size = #-2
      \override TextMark.break-align-symbols = #'(left-edge clef staff-bar)
      \override TextMark.padding = 4
      \omit BarNumber
    }
    \context {
      \VaticanaStaff
      alterationGlyphs =
        #alteration-vaticana-glyph-name-alist
      \override Clef.space-alist =
        #(grob-transformer 'space-alist
          (lambda (grob orig)
            (acons 'custos '(extra-space . 0.7) orig)))
    }
  }
}

[image of music]


Plantilla per a notació de música antiga (transcripció moderna de cant gregorià)

Aquest exemple mostra com fer una transcripció moderna de cant gregorià. El cant gregorià no té compàs ni pliques; utilitza sols caps de nota de blanca i de negra, i unes marques especials que indiquen silencis de diferents longituds.

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 GregorianTranscriptionStaff <<
    \new GregorianTranscriptionVoice = "melody" \chant
    \new GregorianTranscriptionLyrics = "one" \lyricsto melody \verba
  >>
}

[image of music]


Indicacions de compàs antigues

Les indicacions de compàs també es poden gravar en estil antic.

{
  \override Staff.TimeSignature.style = #'neomensural
  s1
}

[image of music]


Notació de responsos o salms

Aquest tipus de notació s’utilitza per als cants salmòdics, en les quals les estrofes no sempre tenen la mateixa longitud.

stemOff = \hide Staff.Stem
stemOn  = \undo \stemOff

\score {
  \new Staff \with { \remove "Time_signature_engraver" }
  {
    \key g \minor
    \cadenzaOn
    \stemOff a'\breve bes'4 g'4
    \stemOn a'2 \section
    \stemOff a'\breve g'4 a'4
    \stemOn f'2 \section
    \stemOff a'\breve^\markup { \italic flexe }
    \stemOn g'2 \fine
  }
}

[image of music]


Custos

Es poden gravar «custos» en diferents estils.

\layout { ragged-right = ##t }

\new Staff \with { \consists "Custos_engraver" } \relative c' {
  \override Staff.Custos.neutral-position = #4

  \override Staff.Custos.style = #'hufnagel
  c1^"hufnagel" \break
  <d a' f'>1

  \override Staff.Custos.style = #'medicaea
  c1^"medicaea" \break
  <d a' f'>1

  \override Staff.Custos.style = #'vaticana
  c1^"vaticana" \break
  <d a' f'>1

  \override Staff.Custos.style = #'mensural
  c1^"mensural" \break
  <d a' f'>1
}

[image of music]


Incipit

En transcriure música mensural, és útil posar un incipit al començament de la peça per indicar la tonalitat i el compàs originals. Actualment els músics estan acostumats a les línies del pentagrama, però en el període de la música mensural encara no s’utilitzaven. Com a compromís, amb freqüència s’imprimeixen línies divisòries entre els pentagrames, un estil de disseny conegut com mensurstriche.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% A short excerpt from the Jubilate Deo by Orlande de Lassus
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\header { tagline = ##f }

global = {
  \set Score.skipBars = ##t
  \key g \major
  \time 4/4

  % the actual music
  \skip 1*8

  % let finis bar go through all staves
  \override Staff.BarLine.transparent = ##f

  % finis bar
  \bar "|."
}

discantusIncipit = {
  \clef "neomensural-c1"
  \key f \major
  \time 2/2
  c''1.
}

discantusNotes = {
  \transpose c' c'' {
    \clef "treble"
    d'2. d'4 |
    b e' d'2 |
    c'4 e'4.( d'8 c' b |
    a4) b a2 |
    b4.( c'8 d'4) c'4 |
    \once \hide NoteHead
    c'1 |
    b\breve |
  }
}

discantusLyrics = \lyricmode {
  Ju -- bi -- la -- te De -- o,
  om -- nis ter -- ra, __ om-
  "..."
  -us.
}

altusIncipit = {
  \clef "neomensural-c3"
  \key f \major
  \time 2/2
  r1 f'1.
}

altusNotes = {
  \transpose c' c'' {
    \clef "treble"
    r2 g2. e4 fis g |
    a2 g4 e |
    fis g4.( fis16 e fis4) |
    g1 |
    \once \hide NoteHead
    g1 |
    g\breve |
  }
}

altusLyrics = \lyricmode {
  Ju -- bi -- la -- te
  De -- o, om -- nis ter -- ra,
  "..."
  -us.
}

tenorIncipit = {
  \clef "neomensural-c4"
  \key f \major
  \time 2/2
  r\longa
  r\breve
  r1 c'1.
}

tenorNotes = {
  \transpose c' c' {
    \clef "treble_8"
    R1 |
    R1 |
    R1 |
    % two measures
    r2 d'2. d'4 b e' |
    \once \hide NoteHead
    e'1 |
    d'\breve |
  }
}

tenorLyrics = \lyricmode {
  Ju -- bi -- la -- te
  "..."
  -us.
}

bassusIncipit = {
  \clef "mensural-f"
  \key f \major
  \time 2/2
  r\maxima
  f1.
}

bassusNotes = {
  \transpose c' c' {
    \clef "bass"
    R1 |
    R1 |
    R1 |
    R1 |
    g2. e4 |
    \once \hide NoteHead
    e1 |
    g\breve |
  }
}

bassusLyrics = \lyricmode {
  Ju -- bi-
  "..."
  -us.
}

\score {
  <<
    \new StaffGroup = choirStaff <<
      \new Voice = "discantusNotes" <<
        \set Staff.instrumentName = "Discantus"
        \incipit \discantusIncipit
        \global
        \discantusNotes
      >>
      \new Lyrics \lyricsto discantusNotes { \discantusLyrics }
      \new Voice = "altusNotes" <<
        \set Staff.instrumentName = "Altus"
        \global
        \incipit \altusIncipit
        \altusNotes
      >>
      \new Lyrics \lyricsto altusNotes { \altusLyrics }
      \new Voice = "tenorNotes" <<
        \set Staff.instrumentName = "Tenor"
        \global
        \incipit \tenorIncipit
        \tenorNotes
      >>
      \new Lyrics \lyricsto tenorNotes { \tenorLyrics }
      \new Voice = "bassusNotes" <<
        \set Staff.instrumentName = "Bassus"
        \global
        \incipit \bassusIncipit
        \bassusNotes
      >>
      \new Lyrics \lyricsto bassusNotes { \bassusLyrics }
    >>
  >>
  \layout {
    \context {
      \Score
      %% no bar lines in staves or lyrics
      \hide BarLine
    }
    %% the next two instructions keep the lyrics between the bar lines
    \context {
      \Lyrics
      \consists "Bar_engraver"
      \consists "Separating_line_group_engraver"
    }
    \context {
      \Voice
      %% no slurs
      \hide Slur
      %% Comment in the below "\remove" command to allow line
      %% breaking also at those bar lines where a note overlaps
      %% into the next measure.  The command is commented out in this
      %% short example score, but especially for large scores, you
      %% will typically yield better line breaking and thus improve
      %% overall spacing if you comment in the following command.
      %%\remove "Forbid_line_break_engraver"
    }
    indent = 6\cm
    incipit-width = 4\cm
  }
}

[image of music]


Disposició Mensurstriche (línies divisòries entre pentagrames)

La disposició «mensurstriche» en els quals les línies divisòries no estan dibuixades sobre els pentagrames, sinó entre ells, es pot aconseguir amb un StaffGroup en comptes d’un ChoirStaff. La línia divisòria sobre els pentagrames s’esborra usant \hide.

\layout {
  \context {
    \Staff
    measureBarType = "-span|"
  }
}

music = \fixed c'' {
  c1
  d2 \section e2
  f1 \fine
}

\new StaffGroup <<
  \new Staff \music
  \new Staff \music
>>

[image of music]


Estils de silencis

Els silencis es poden imprimir en diferents estils.

restsA = {
  r\maxima r\longa r\breve r1 r2 r4 r8 r16 s32
  s64 s128 s256 s512 s1024 s1024
}
restsB = {
  r\maxima r\longa r\breve r1 r2 r4 r8 r16 r32
  r64 r128 r256 r512 r1024 s1024
}

\new Staff \relative c {
  \omit Score.TimeSignature
  \cadenzaOn

  \override Staff.Rest.style = #'mensural
  <>^\markup \typewriter { mensural } \restsA \bar "" \break

  \override Staff.Rest.style = #'neomensural
  <>^\markup \typewriter { neomensural } \restsA \bar "" \break

  \override Staff.Rest.style = #'classical
  <>^\markup \typewriter { classical } \restsB \bar "" \break

  \override Staff.Rest.style = #'z
  <>^\markup \typewriter { z-style } \restsB \bar "" \break

  \override Staff.Rest.style = #'default
  <>^\markup \typewriter { default } \restsB \bar "" \break
}

\paper {
  indent = 0
  tagline = ##f
}

[image of music]


Using tags to produce mensural and modern music from the same source

Using tags, it is possible to produce both mensural and modern notation from the same music. In this snippet, a function \menrest is introduced, allowing mensural rests to be pitched as in the original, but with modern rests in the standard staff position.

Tags can also be used where other differences are needed: for example using “whole measure rests” (R1, R\breve, etc.) in modern music, but normal rests (r1, r\breve, etc.) in the mensural version. Converting mensural music to its modern equivalent is usually referred to as transcription.

\header { tagline = ##f }

menrest =
#(define-music-function (note)
  (ly:music?)
    #{
      \tag #'mens $(make-music 'RestEvent note)
      \tag #'mod $(make-music 'RestEvent note 'pitch '())
    #})

MenStyle = {
  \autoBeamOff
  \override NoteHead.style = #'petrucci
  \override Score.BarNumber.transparent = ##t
  \override Stem.neutral-direction = #up
}

finalis = \section

Music = \relative c'' {
  \set Score.tempoHideNote = ##t
  \key f \major
  \time 4/4
  g1 d'2 \menrest bes4 bes2 a2 r4 g4 fis2.
  \finalis
}

MenLyr = \lyricmode { So farre, deere life, deare life }
ModLyr = \lyricmode { So far, dear life, dear life }

\score {
  \keepWithTag #'mens {
    <<
      \new MensuralStaff
      {
        \new MensuralVoice = Cantus
          \clef "mensural-c1" \MenStyle \Music
      }
      \new Lyrics \lyricsto Cantus \MenLyr
    >>
  }
}

\score {
  \keepWithTag #'mod {
    \new ChoirStaff <<
      \new Staff
      {
        \new Voice = Sop \with {
          \remove "Note_heads_engraver"
          \consists "Completion_heads_engraver"
          \remove "Rest_engraver"
          \consists "Completion_rest_engraver" }
        {
          \shiftDurations 1 0 { \autoBeamOff \Music }
        }
      }
      \new Lyrics \lyricsto Sop \ModLyr
    >>
  }
}

[image of music]


Línia vertical com una articulació barroca

Aquesta línia curta vertical a sobre de la nota és d’ús comú en la música barroca. El seu significat varia, però en general indica notes que s’han de tocar amb més “pes”. L’exemple següent mostra com aconseguir aquesta notació.

upline =
\tweak stencil
  #(lambda (grob)
    (grob-interpret-markup grob #{ \markup \draw-line #'(0 . 1) #}))
  \stopped

\relative c' {
  a'4^\upline a( c d')_\upline
}

[image of music]


World music

World music


Improvisació de música àrab

For improvisations or taqasim which are temporarily free, the time signature can be omitted and \cadenzaOn can be used. Adjusting the accidental style might be required, since the absence of bar lines will cause the accidental to be marked only once. Here is an example of what could be the start of a hijaz improvisation:

\include "arabic.ly"

\relative sol' {
  \key re \kurd
  \accidentalStyle forget
  \cadenzaOn
  sol4 sol sol sol fad mib sol1 fad8 mib re4. r8 mib1 fad sol
}

[image of music]


Exemple de «Makam»

El «Makam» és un tipus de melodia de Turquia que utilitza alteracions microtonals de 1/9 de to. Consulteu el fitxer d’inici makam.ly (vegeu el «Manual d’aprenentatge 2.25.14, 4.6.3 Altres forms d’informació» per esbrinar la situació d’aquest fitxer) per veure detalls dels noms de les notes i les alteracions.

% Initialize makam settings
\include "makam.ly"

\relative c' {
  \set Staff.keyAlterations = #`((6 . ,(- KOMA)) (3 . ,BAKIYE))
  c4 cc db fk
  gbm4 gfc gfb efk
  fk4 db cc c
}

[image of music]


Impressió de text de dreta a esquerra

És possible imprimir text de dreta a esquerra en un element de marcatge, com es mostra aquí.

{
  b1^\markup {
    \line { i n g i r u m i m u s n o c t e }
  }
  f'_\markup {
    \override #'(text-direction . -1)
    \line { i n g i r u m i m u s n o c t e }
  }
}

[image of music]


Turkish Makam example

This template uses the start of a well-known Turkish Saz Semai that is familiar in the repertoire in order to illustrate some of the elements of Turkish music notation.

\paper { tagline = ##f }

% Initialize makam settings
\include "turkish-makam.ly"

\header {
    title = "Hüseyni Saz Semaisi"
    composer = "Lavtacı Andon"
}

\relative {
  \set Staff.extraNatural = ##f
  \set Staff.autoBeaming = ##f

  \key a \huseyni
  \time 10/8

  a'4 g'16 [fb] e8. [d16] d [c d e] c [d c8] bfc |
  a16 [bfc a8] bfc c16 [d c8] d16 [e d8] e4 fb8 |
  d4 a'8 a16 [g fb e] fb8 [g] a8. [b16] a16 [g] |
  g4 g16 [fb] fb8. [e16] e [g fb e] e4 r8 |
}

[image of music]


Contexts and engravers

Changing defaults

Contexts and engravers


Afegir un baix xifrat a sobre o a sota de les notes

En escriure un baix xifrat, podem ubicar les xifres a sobre a o a sota de les notes del baix, mitjançant la definició de la propietat BassFigureAlignmentPositioning #'direction (exclusivament dins d’un context Staff). es pot escollir entre #UP (o #1, a sobre), #CENTER (o #0, centraat) i #DOWN (o #-1, a sota).

Aquesta propietat es pot canviar tantes vegades com volem. Utilitzeu \once \override si no voleu que la sobreescriptura s’apliqui a tota la partitura.

bass = {
  \clef bass
  g4 b, c d
  e d8 c d2
}

continuo = \figuremode {
  <_>4 <6>4 <5/>4
  \override Staff.BassFigureAlignmentPositioning.direction = #UP
  %\bassFigureStaffAlignmentUp
  < _+ >4 <6>
  \set Staff.useBassFigureExtenders = ##t
  \override Staff.BassFigureAlignmentPositioning.direction = #DOWN
  %\bassFigureStaffAlignmentDown
  <4>4. <4>8 <_+>4
}

\score {
  <<
    \new Staff = bassStaff \bass
    \context Staff = bassStaff \continuo
  >>
}

[image of music]


Afegir un pentagrama nou

Es pot afegir (possiblement de forma temporal) un pentagrama nou un cop la peça ha començat.

\score {
  <<
    \new Staff \relative c'' {
      c1 | c | c | c | c
    }
    \new StaffGroup \relative c'' {
      \new Staff {
        c1 | c
        <<
          {
            c1 | d
          }
          \new Staff {
            \once \omit Staff.TimeSignature
            c1 | b
          }
        >>
        c1
      }
    }
  >>
}

[image of music]


Afegir un pentagrama addicional a un salt de línia

En afegir un pentagrama nou a un salt de línia, per desgràcia s’afegeix un espai addicional al final de la línia abans del salt (reservat per fer lloc a un canvi d’armadura que de totes formes no s’imprimirà). La solució alternativa és afegir un ajustament per a Staff.explicitKeySignatureVisibility com es mostra a l’exemple.

\paper { tagline = ##f }

\score {
  \new StaffGroup \relative c'' {
    \new Staff
    \key f \major
    c1 c^"Unwanted extra space" \break
    << { c1 | c }
       \new Staff {
         \key f \major
         \once \omit Staff.TimeSignature
         c1 | c
       }
    >>
    c1 | c^"Fixed here" \break
    << { c1 | c }
       \new Staff {
         \once \set Staff.explicitKeySignatureVisibility = #end-of-line-invisible
         \key f \major
         \once \omit Staff.TimeSignature
         c1 | c
       }
    >>
  }
}

[image of music]


Canviar la direcció de la plica de les notes de tercera línia automàticament, basat en la melodia

El LilyPond pot alterar la direcció de la plica de les notes que van en la tercera línia d’un pentagrama de forma que segueixi la melodia, mitjançant l’addició del gravador Melody_engraver al context Voice i sobreescrivint el valor de neutral-direction per a l’objecte Stem (plica).

\relative c'' {
  \time 3/4
  a8 b g f b g |
  \set suspendMelodyDecisions = ##t
  a  b g f b g |
  \unset suspendMelodyDecisions
  c  b d c b c |
}

\layout {
  \context {
    \Voice
    \consists "Melody_engraver"
    \autoBeamOff
  }
}

[image of music]


Nombres de compàs centrats

Sovint, les partitures d’obres per a conjunts grnas tenen els nombres de compàs a sota del sistems i centrats horitzontalment sobre l’amplada del compàs. Aquest fragment de codi mostra com pot usar-se el gravador Measure_counter_engraver per simular aquesta pràctica de notació. Aquí hem afegit el gravador a un context Dynamics.

\layout {
  \context {
    \Dynamics
    \consists #Measure_counter_engraver
    \override MeasureCounter.direction = #DOWN
    \override MeasureCounter.font-encoding = #'latin1
    \override MeasureCounter.font-shape = #'italic
    % to control the distance of the Dynamics context from the staff:
    \override VerticalAxisGroup.nonstaff-relatedstaff-spacing.padding = #2
  }
  \context {
    \Score
    \remove "Bar_number_engraver"
  }
}

pattern = \repeat unfold 7 { c'4 d' e' f' }

\new StaffGroup <<
  \new Staff {
    \pattern
  }
  \new Staff {
    \pattern
  }
  \new Dynamics {
    \startMeasureCount
    s1*7
    \stopMeasureCount
  }
>>

[image of music]


Modificar la sortida MIDI perquè tingui un canal per a cada veu

En produir una sortida MIDI, el comportament predeterminat és que cada pentagrama representa un canal MIDI, amb totes les veus d’aquest pentagrama barrejades. Això redueix al mínim el risc que s’esgoti el nombre de canals MIDI disponibles, atès que hi ha un màxim de 16 canals per cada port MIDI, i la majoria dels dispositius sols tenen un port.

No obstant, quan es trasllada l’interpretador Staff_performer al context Voice, cada veu d’un pentagrama pot tenir el seu propi canal MIDI, com es mostra a l’exemple següent: malgrat d’estar sobre el mateix pentagrama, es creen dos canals MIDI, cadascú amb un midiInstrument diferent.

\score {
  \new Staff <<
    \new Voice \relative c''' {
      \set midiInstrument = "flute"
      \voiceOne
      \key g \major
      \time 2/2
      r2 g-"Flute" ~
      g fis ~
      fis4 g8 fis e2 ~
      e4 d8 cis d2
    }
    \new Voice \relative c'' {
      \set midiInstrument = "clarinet"
      \voiceTwo
      b1-"Clarinet"
      a2. b8 a
      g2. fis8 e
      fis2 r
    }
  >>
  \layout { }
  \midi {
    \context {
      \Staff
      \remove "Staff_performer"
    }
    \context {
      \Voice
      \consists "Staff_performer"
    }
    \tempo 2 = 72
  }
}

[image of music]


Modificar el compàs d’una secció polimètrica utilitzant \scaleDurations

La propietat measureLength, junt amb measurePosition, determina quan cal dibuixar una línia divisòria. No obstant, en utilitzar \scaleDurations, l’escalat proporcional de les duracions fa difícil introduir canvis de compàs. En aquest cas s’ha d’establir manualment el valor de measureLength utilitzant la funció ly:make-moment. El segon argument ha de ser el mateix que el segon artgument de \scaleDurations.

\layout {
  \context {
    \Score
    \remove "Timing_translator"
  }
  \context {
    \Staff
    \consists "Timing_translator"
  }
}

<<
  \new Staff {
    \scaleDurations 8/5 {
      \time 6/8
      \set Timing.measureLength = \musicLength 1*6/5
      b8 b b b b b
      \time 2/4
      \set Timing.measureLength = \musicLength 1*4/5
      b4 b
    }
  }
  \new Staff {
    \clef bass
    \time 2/4
    c2 d e f
  }
>>

[image of music]


Notació de responsos o salms

Aquest tipus de notació s’utilitza per als cants salmòdics, en les quals les estrofes no sempre tenen la mateixa longitud.

stemOff = \hide Staff.Stem
stemOn  = \undo \stemOff

\score {
  \new Staff \with { \remove "Time_signature_engraver" }
  {
    \key g \minor
    \cadenzaOn
    \stemOff a'\breve bes'4 g'4
    \stemOn a'2 \section
    \stemOff a'\breve g'4 a'4
    \stemOn f'2 \section
    \stemOff a'\breve^\markup { \italic flexe }
    \stemOn g'2 \fine
  }
}

[image of music]


Crear pentagrames en blanc

Per crear pentagrames en blanc, genereu compassos buits i després elimineu el gravador de números de compàs Bar_number_engraver del context Score, i els gravadors de la indicacó de compàs Time_signature_engraver, de la clau Clef_engraver i dels compassos Bar_engraver del context de Staff.

#(set-global-staff-size 20)

\score {
  {
    \repeat unfold 12 { s1 \break }
  }
  \layout {
    indent = 0\in
    \context {
      \Staff
      \remove "Time_signature_engraver"
      \remove "Clef_engraver"
      \remove "Bar_engraver"
    }
    \context {
      \Score
      \remove "Bar_number_engraver"
    }
  }
}

% uncomment these lines for "letter" size
%{
\paper {
  #(set-paper-size "letter")
  ragged-last-bottom = ##f
  line-width = 7.5\in
  left-margin = 0.5\in
  bottom-margin = 0.25\in
  top-margin = 0.25\in
}
%}

% uncomment these lines for "A4" size
%{
\paper {
  #(set-paper-size "a4")
  ragged-last-bottom = ##f
  line-width = 180
  left-margin = 15
  bottom-margin = 10
  top-margin = 10
}
%}

[image of music]


Creació d’armadures personalitzades

El LilyPond accepta armadures personalitzades. En aquest exemple, es mostra l’armadura de re menor amb una rang estès de bemolls.

\new Staff \with {
  \override StaffSymbol.line-count = #8
  \override KeySignature.flat-positions = #'((-7 . 6))
  \override KeyCancellation.flat-positions = #'((-7 . 6))
  % presumably sharps are also printed in both octaves
  \override KeySignature.sharp-positions = #'((-6 . 7))
  \override KeyCancellation.sharp-positions = #'((-6 . 7))

  \override Clef.stencil = #
  (lambda (grob)(grob-interpret-markup grob
  #{ \markup\combine
    \musicglyph "clefs.C"
    \translate #'(-3 . -2)
    \musicglyph "clefs.F"
   #}))
    clefPosition = #3
    middleCPosition = #3
    middleCClefPosition = #3
}

{
  \key d\minor
  f bes, f bes,
}

[image of music]


Pliques de pentagrama creuat

Aquest fragment de codi mostra l’ús del gravador Span_stem_engraver i de \crossStaff per connectar automàticament pliques d’un pentagrama a un altre. No cal especificar la longitud de la plica perquè la distància variable entre els caps de les notes i els pentagrames es calcula automàticament.

\layout {
  \context {
    \PianoStaff
    \consists "Span_stem_engraver"
  }
}

\new PianoStaff <<
  \new Staff {
    <b d'>4 r d'16\> e'8. g8 r\! |
    e'8 f' g'4
      \voiceTwo \autoBeamOff
      % Down to lower staff
      \crossStaff { e'8 e'8 } e'4 |
  }

  \new Staff {
    \clef bass
    \voiceOne \autoBeamOff
    % Up to upper staff
    \crossStaff { <e g>4 e, g16 a8. c8 } d |
    \autoBeamOn g8 f g4 \voiceTwo g8 g g4 |
    }
>>

[image of music]


Definir un gravador en l’Scheme: gravador d’àmbit o tessitura

Aquest exemple mostra com pot definir-se el gravador d’àmbit o tessitura a l’espai de l’usuari, com un gravador de l’Scheme.

Això és bàsicament una reescriptura en l’Scheme del codi de lily/ambitus-engraver.cc.

#(use-modules (oop goops))

%%%
%%% Grob utilities
%%%
%%% These are literal rewrites of some C++ methods used by the ambitus engraver.

#(define (ly:separation-item::add-conditional-item grob grob-item)
   "Add @var{grob-item} to the array of conditional elements of @var{grob}.
Rewrite of @code{Separation_item::add_conditional_item} from @file{lily/separation-item.cc}."
   (ly:pointer-group-interface::add-grob grob 'conditional-elements grob-item))

#(define (ly:accidental-placement::accidental-pitch accidental-grob)
   "Get the pitch from the grob cause of @var{accidental-grob}.
Rewrite of @code{accidental_pitch} from @file{lily/accidental-placement.cc}."
   (ly:event-property (ly:grob-property (ly:grob-parent accidental-grob Y) 'cause)
                      'pitch))

#(define (ly:accidental-placement::add-accidental grob accidental-grob)
   "Add @var{accidental-grob}, an @code{Accidental} grob, to the
list of the accidental grobs of @var{grob}, an @code{AccidentalPlacement}
grob.
Rewrite of @code{Accidental_placement::add_accidental} from @file{lily/accidental-placement.cc}."
   (let ((pitch (ly:accidental-placement::accidental-pitch accidental-grob)))
     (set! (ly:grob-parent accidental-grob X) grob)
     (let* ((accidentals (ly:grob-object grob 'accidental-grobs))
            (handle (assq (ly:pitch-notename pitch) accidentals))
            (entry (if handle (cdr handle) '())))
       (set! (ly:grob-object grob 'accidental-grobs)
             (assq-set! accidentals
                        (ly:pitch-notename pitch)
                        (cons accidental-grob entry))))))

%%%
%%% Ambitus data structure
%%%

%%% The <ambitus> class holds the various grobs that are created
%%% to print an ambitus:
%%% - ambitus-group: the grob that groups all the components of an ambitus
%%% (Ambitus grob);
%%% - ambitus-line: the vertical line between the upper and lower ambitus
%%% notes (AmbitusLine grob);
%%% - ambitus-up-note and ambitus-down-note: the note head and accidental
%%% for the lower and upper note of the ambitus (see <ambitus-note> class
%%% below).
%%% The other slots define the key and clef context of the engraver:
%%% - start-c0: position of middle c at the beginning of the piece.  It
%%% is used to place the ambitus notes according to their pitch;
%%% - start-key-sig: the key signature at the beginning of the piece.  It
%%% is used to determine if accidentals shall be printed next to ambitus
%%% notes.

#(define-class <ambitus> ()
   (ambitus-group #:accessor ambitus-group)
   (ambitus-line #:accessor ambitus-line)
   (ambitus-up-note #:getter ambitus-up-note
                    #:init-form (make <ambitus-note>))
   (ambitus-down-note #:getter ambitus-down-note
                      #:init-form (make <ambitus-note>))
   (start-c0 #:accessor ambitus-start-c0
             #:init-value #f)
   (start-key-sig #:accessor ambitus-start-key-sig
                  #:init-value '()))

%%% Accessor for the lower and upper note data of an ambitus
#(define-method (ambitus-note (ambitus <ambitus>) direction)
   "If @var{direction} is @code{UP}, then return the upper ambitus note
of @var{ambitus}, otherwise return the lower ambitus note."
   (if (= direction UP)
       (ambitus-up-note ambitus)
       (ambitus-down-note ambitus)))

%%% The <ambitus-note> class holds the grobs that are specific to ambitus
%%% (lower and upper) notes:
%%% - head: an AmbitusNoteHead grob;
%%% - accidental: an AmbitusAccidental grob, to be possibly printed next
%%% to the ambitus note head.
%%% Moreover:
%%% - pitch is the absolute pitch of the note
%%% - cause is the note event that causes this ambitus note, i.e. the lower
%%% or upper note of the considered music sequence.

#(define-class <ambitus-note> ()
   (head #:accessor ambitus-note-head
         #:init-value #f)
   (accidental #:accessor ambitus-note-accidental
               #:init-value #f)
   (cause #:accessor ambitus-note-cause
          #:init-value #f)
   (pitch #:accessor ambitus-note-pitch
          #:init-value #f))

%%%
%%% Ambitus engraving logics
%%%
%%% Rewrite of the code from @file{lily/ambitus-engraver.cc}.

#(define (make-ambitus translator)
   "Build an ambitus object: initialize all the grobs and their relations.

The Ambitus grob contain all other grobs:
 Ambitus
  |- AmbitusLine
  |- AmbitusNoteHead   for upper note
  |- AmbitusAccidental for upper note
  |- AmbitusNoteHead   for lower note
  |- AmbitusAccidental for lower note

The parent of an accidental is the corresponding note head,
and the accidental is set as the 'accidental-grob of the note head
so that is printed by the function that prints notes."
   ;; make the ambitus object
   (let ((ambitus (make <ambitus>)))
     ;; build the Ambitus grob, which will contain all other grobs
     (set! (ambitus-group ambitus) (ly:engraver-make-grob translator 'Ambitus '()))
     ;; build the AmbitusLine grob (line between lower and upper note)
     (set! (ambitus-line ambitus) (ly:engraver-make-grob translator 'AmbitusLine '()))
     ;; build the upper and lower AmbitusNoteHead and AmbitusAccidental
     (for-each (lambda (direction)
                 (let ((head (ly:engraver-make-grob translator 'AmbitusNoteHead '()))
                       (accidental (ly:engraver-make-grob translator 'AmbitusAccidental '()))
                       (group (ambitus-group ambitus)))
                   ;; The parent of the AmbitusAccidental grob is the
                   ;; AmbitusNoteHead grob
                   (set! (ly:grob-parent accidental Y) head)
                   ;; The AmbitusAccidental grob is set as the accidental-grob
                   ;; object of the AmbitusNoteHead.  This is later used by the
                   ;; function that prints notes.
                   (set! (ly:grob-object head 'accidental-grob) accidental)
                   ;; both the note head and the accidental grobs are added
                   ;; to the main ambitus grob.
                   (ly:axis-group-interface::add-element group head)
                   (ly:axis-group-interface::add-element group accidental)
                   ;; the note head and the accidental grobs are added to the
                   ;; ambitus object
                   (set! (ambitus-note-head (ambitus-note ambitus direction))
                         head)
                   (set! (ambitus-note-accidental (ambitus-note ambitus direction))
                         accidental)))
               (list DOWN UP))
     ;; The parent of the ambitus line is the lower ambitus note head
     (set! (ly:grob-parent (ambitus-line ambitus) X)
           (ambitus-note-head (ambitus-note ambitus DOWN)))
     ;; the ambitus line is added to the ambitus main grob
     (ly:axis-group-interface::add-element (ambitus-group ambitus) (ambitus-line ambitus))
     ambitus))

#(define-method (initialize-ambitus-state (ambitus <ambitus>) translator)
   "Initialize the state of @var{ambitus}, by getting the starting
position of middle C and key signature from @var{translator}'s context."
   (if (not (ambitus-start-c0 ambitus))
       (begin
         (set! (ambitus-start-c0 ambitus)
               (ly:context-property (ly:translator-context translator)
                                    'middleCPosition
                                    0))
         (set! (ambitus-start-key-sig ambitus)
               (ly:context-property (ly:translator-context translator)
                                    'keyAlterations)))))

#(define-method (update-ambitus-notes (ambitus <ambitus>) note-grob)
   "Update the upper and lower ambitus pithes of @var{ambitus}, using
@var{note-grob}."
   ;; Get the event that caused the note-grob creation
   ;; and check that it is a note-event.
   (let ((note-event (ly:grob-property note-grob 'cause)))
     (if (ly:in-event-class? note-event 'note-event)
         ;; get the pitch from the note event
         (let ((pitch (ly:event-property note-event 'pitch)))
           ;; if this pitch is lower than the current ambitus lower
           ;; note pitch (or it has not been initialized yet),
           ;; then this pitch is the new ambitus lower pitch,
           ;; and conversely for upper pitch.
           (for-each (lambda (direction pitch-compare)
                       (if (or (not (ambitus-note-pitch (ambitus-note ambitus direction)))
                               (pitch-compare pitch
                                              (ambitus-note-pitch (ambitus-note ambitus direction))))
                           (begin
                             (set! (ambitus-note-pitch (ambitus-note ambitus direction))
                                   pitch)
                             (set! (ambitus-note-cause (ambitus-note ambitus direction))
                                   note-event))))
                     (list DOWN UP)
                     (list ly:pitch<? (lambda (p1 p2)
                                        (ly:pitch<? p2 p1))))))))

#(define-method (typeset-ambitus (ambitus <ambitus>) translator)
   "Typeset the ambitus:
- place the lower and upper ambitus notes according to their pitch and
  the position of the middle C;
- typeset or delete the note accidentals, according to the key signature.
  An accidental, if it is to be printed, is added to an AccidentalPlacement
  grob (a grob dedicated to the placement of accidentals near a chord);
- both note heads are added to the ambitus line grob, so that a line should
  be printed between them."
   ;; check if there are lower and upper pitches
   (if (and (ambitus-note-pitch (ambitus-note ambitus UP))
            (ambitus-note-pitch (ambitus-note ambitus DOWN)))
       ;; make an AccidentalPlacement grob, for placement of note accidentals
       (let ((accidental-placement (ly:engraver-make-grob
                                    translator
                                    'AccidentalPlacement
                                    (ambitus-note-accidental (ambitus-note ambitus DOWN)))))
         ;; For lower and upper ambitus notes:
         (for-each (lambda (direction)
                     (let ((pitch (ambitus-note-pitch (ambitus-note ambitus direction))))
                       ;; set the cause and the staff position of the ambitus note
                       ;; according to the associated pitch
                       (set! (ly:grob-property (ambitus-note-head (ambitus-note ambitus direction))
                                               'cause)
                             (ambitus-note-cause (ambitus-note ambitus direction)))
                       (set! (ly:grob-property (ambitus-note-head (ambitus-note ambitus direction))
                                               'staff-position)
                             (+ (ambitus-start-c0 ambitus)
                                (ly:pitch-steps pitch)))
                       ;; determine if an accidental shall be printed for this note,
                       ;; according to the key signature
                       (let* ((handle (or (assoc (cons (ly:pitch-octave pitch)
                                                       (ly:pitch-notename pitch))
                                                 (ambitus-start-key-sig ambitus))
                                          (assoc (ly:pitch-notename pitch)
                                                 (ambitus-start-key-sig ambitus))))
                              (sig-alter (if handle (cdr handle) 0)))
                         (cond ((= (ly:pitch-alteration pitch) sig-alter)
                                ;; the note alteration is in the key signature
                                ;; => it does not have to be printed
                                (ly:grob-suicide!
                                 (ambitus-note-accidental (ambitus-note ambitus direction)))
                                (set! (ly:grob-object (ambitus-note-head (ambitus-note ambitus direction))
                                                      'accidental-grob)
                                      '()))
                               (else
                                ;; otherwise, the accidental shall be printed
                                (set! (ly:grob-property (ambitus-note-accidental
                                                         (ambitus-note ambitus direction))
                                                        'alteration)
                                      (ly:pitch-alteration pitch)))))
                       ;; add the AccidentalPlacement grob to the
                       ;; conditional items of the AmbitusNoteHead
                       (ly:separation-item::add-conditional-item
                        (ambitus-note-head (ambitus-note ambitus direction))
                        accidental-placement)
                       ;; add the AmbitusAccidental to the list of the
                       ;; AccidentalPlacement grob accidentals
                       (ly:accidental-placement::add-accidental
                        accidental-placement
                        (ambitus-note-accidental (ambitus-note ambitus direction)))
                       ;; add the AmbitusNoteHead grob to the AmbitusLine grob
                       (ly:pointer-group-interface::add-grob
                        (ambitus-line ambitus)
                        'note-heads
                        (ambitus-note-head (ambitus-note ambitus direction)))))
                   (list DOWN UP))
         ;; add the AccidentalPlacement grob to the main Ambitus grob
         (ly:axis-group-interface::add-element (ambitus-group ambitus) accidental-placement))
       ;; no notes ==> suicide the grobs
       (begin
         (for-each (lambda (direction)
                     (ly:grob-suicide! (ambitus-note-accidental (ambitus-note ambitus direction)))
                     (ly:grob-suicide! (ambitus-note-head (ambitus-note ambitus direction))))
                   (list DOWN UP))
         (ly:grob-suicide! ambitus-line))))

%%%
%%% Ambitus engraver definition
%%%
#(define ambitus-engraver
   (lambda (context)
     (let ((ambitus #f))
       ;; when music is processed: make the ambitus object, if not already built
       (make-engraver
    ((process-music translator)
     (if (not ambitus)
         (set! ambitus (make-ambitus translator))))
    ;; set the ambitus clef and key signature state
    ((stop-translation-timestep translator)
     (if ambitus
         (initialize-ambitus-state ambitus translator)))
    ;; when a note-head grob is built, update the ambitus notes
    (acknowledgers
          ((note-head-interface engraver grob source-engraver)
       (if ambitus
           (update-ambitus-notes ambitus grob))))
    ;; finally, typeset the ambitus according to its upper and lower notes
    ;; (if any).
    ((finalize translator)
     (if ambitus
         (typeset-ambitus ambitus translator)))))))

%%%
%%% Example
%%%

\score {
  \new StaffGroup <<
    \new Staff { c'4 des' e' fis' gis' }
    \new Staff { \clef "bass" c4 des ~ des ees b, }
  >>
  \layout { \context { \Staff \consists #ambitus-engraver } }
}

[image of music]


Mostrar un sistema GrandStaff complet si segueix amb vida un sol dels seus pentagrames

A vegades, a les partitures orquestrals es deixen en silenci instruments individuals o grups d’ells durant un període de temps, i els seus pentagrames corresponents es poden suprimir durant aquest temps (amb \removeEmptyStaves).

Quan tornen a sonar, sovint es prefereix mostrar tots els instruments del grup. Això es pot fer afegint el gravador Keep_alive_together_engraver en el context agrupador (per exemple: un GrandStaff o un StaffGroup)

En aquest exemple, els violins estan en silenci durant els sistemes segon i tercer. Sols el violí primer sona a l’últim compàs, però es mostra també el pentagrama del violí segon.

\score {
  <<
    \new StaffGroup = "StaffGroup_woodwinds"
    <<
      \new Staff = "Staff_flute" \with {
        instrumentName = "Flute"
        shortInstrumentName = "Fl"
      }
      \relative c' {
        \repeat unfold 3 { c'4 c c c | c c c c | c c c c | \break }
      }
    >>
    \new StaffGroup = "StaffGroup_Strings"
    <<
      \new GrandStaff = "GrandStaff_violins"
      <<
        \new Staff = "StaffViolinI" \with {
          instrumentName = "Violin I"
          shortInstrumentName = "Vi I"
        }
        \relative c'' {
          a1 \repeat unfold 7 { s1 } \repeat unfold 12 a16  a4
        }
        \new Staff = "StaffViolinII" \with {
          instrumentName = "Violin II"
          shortInstrumentName = "Vi II"
        }
        \relative c' { e1 \repeat unfold 8 { s1 } }
      >>
      \new Staff = "Staff_cello" \with {
        instrumentName = "Cello"
        shortInstrumentName = "Ce"
      }
      \relative c { \clef bass \repeat unfold 9 { c1 }}
    >>
  >>
}

\paper { tagline = ##f }

\layout {
  indent = 3.0\cm
  short-indent = 1.5\cm
  \context {
    \GrandStaff
    \consists Keep_alive_together_engraver
  }
  \context {
    \Staff
    \RemoveEmptyStaves
  }
}

[image of music]


Els gravadors, un per un

Del problema central de la notació, és a dir, crear un determinat símbol, s’encarreguen els «plugins» o complements afegits. Cada un dels complements es coneix com un gravador. A aquest exemple els gravadors es van activant un per un, a l’ordre següent:

- cap de les notes,

- el símbol del pentagrama,

- clau,

- pliques,

- barres, lligadures d’expressió, accents,

- alteracions, línies divisòries, indicació del compàs, i armadura.

Els gravadors es troben agrupats. Per exemple, els caps de nota, les lligadures d’expressió, les barres de corxera, etc., formen un context de veu Voice. Els gravadors de l’armadura, alteracions línies de compàs, etc., formen un context de pentagrama Staff.

\header { tagline = ##f }

topVoice = \relative c' {
  \key d \major
  es8([ g] a[ fis])
  b4
  b16[-. b-. b-. cis-.]
  d4->
}


% empty staff and voice contexts
MyStaff = \context {
  \type Engraver_group
  \name Staff

  \accepts Voice
  \defaultchild Voice
}
MyVoice = \context {
  \type Engraver_group
  \name Voice
}


% add note heads
MyVoice = \context {
  \MyVoice
  \consists Note_heads_engraver
}
\score {
  \topVoice
  \layout {
    \context { \MyStaff }
    \context { \MyVoice }
  }
}

% add staff
MyStaff = \context {
  \MyStaff
  \consists Staff_symbol_engraver
}
\score {
  \topVoice
  \layout {
    \context { \MyStaff }
    \context { \MyVoice }
  }
}

% add clef
MyStaff = \context {
  \MyStaff
  \consists Clef_engraver
}
\score {
  \topVoice
  \layout {
    \context { \MyStaff }
    \context { \MyVoice }
  }
}

% add stems
MyVoice = \context {
  \MyVoice
  \consists Stem_engraver
}
\score {
  \topVoice
  \layout {
    \context { \MyStaff }
    \context { \MyVoice }
  }
}

% add beams, slurs, and accents
MyVoice = \context {
  \MyVoice
  \consists Beam_engraver
  \consists Slur_engraver
  \consists Script_engraver
  \consists Rhythmic_column_engraver
}
\score {
  \topVoice
  \layout {
    \context { \MyStaff }
    \context { \MyVoice }
  }
}

% add accidentals, bar, time signature, and key signature
MyStaff = \context {
  \MyStaff
  \consists Accidental_engraver
  \consists Bar_engraver
  \consists Time_signature_engraver
  \consists Key_engraver
}
\score {
  \topVoice
  \layout {
    \context { \MyStaff }
    \context { \MyVoice }
  }
}

[image of music]


Disposició Mensurstriche (línies divisòries entre pentagrames)

La disposició «mensurstriche» en els quals les línies divisòries no estan dibuixades sobre els pentagrames, sinó entre ells, es pot aconseguir amb un StaffGroup en comptes d’un ChoirStaff. La línia divisòria sobre els pentagrames s’esborra usant \hide.

\layout {
  \context {
    \Staff
    measureBarType = "-span|"
  }
}

music = \fixed c'' {
  c1
  d2 \section e2
  f1 \fine
}

\new StaffGroup <<
  \new Staff \music
  \new Staff \music
>>

[image of music]


Niuat de grups de pentagrames

Es pot utilitzar la propietat systemStartDelimiterHierarchy per crear grups de pentagrames niuats de forma més complexa. L’ordre \set StaffGroup.systemStartDelimiterHierarchy pren una llista alfabètic del nombre de pentagrames produïts. Es pot proporcionar abans de cada pentagrama un delimitador de començament del sistema. Es pot envoltar entre corxets i admetre tants pentagrames com envoltin els corxets. Es poden ometre els elements de la llista, però el primer corxet sempre abasta tots els pentagrames. Les possibilitat són SystemStartBar, SystemStartBracket, SystemStartBrace SystemStartSquare.

\new StaffGroup
\relative c'' <<
  \override StaffGroup.SystemStartSquare.collapse-height = 4
  \set StaffGroup.systemStartDelimiterHierarchy
    = #'(SystemStartSquare (SystemStartBrace (SystemStartBracket a
                             (SystemStartSquare b)  ) c ) d)
  \new Staff { c1 }
  \new Staff { c1 }
  \new Staff { c1 }
  \new Staff { c1 }
  \new Staff { c1 }
>>

[image of music]


Numerar grups de compassos

Aquest fragment de codi mostra l’ús del gravador Measure_counter_engraver per numerar grups de compassos successius. Es pot numerar qualsevol període de compassos tant si té repeticions com si no.

S’ha d’afegir el gravador al context adequat. Aquí s’usa un context Staff; una altra possibilitat seria un context Dynamics.

El comptador s’inicia amb \startMeasureCount i finalitza amb \stopMeasureCount. La numeració comença amb 1, de forma predeterminada, però es pot modificar aquest comportament sobreescrivint la propietat count-from.

Quan un compàs s’estén més enllà d’un salt de línia, el número apareix dues vegades, la segona vegada entre parèntesi.

\layout {
  \context {
    \Staff
    \consists #Measure_counter_engraver
  }
}

\new Staff {
  \startMeasureCount
  \repeat unfold 7 {
    c'4 d' e' f'
  }
  \stopMeasureCount
  \bar "||"
  g'4 f' e' d'
  \override Staff.MeasureCounter.count-from = #2
  \startMeasureCount
  \repeat unfold 5 {
    g'4 f' e' d'
  }
  g'4 f'
  \bar ""
  \break
  e'4 d'
  \repeat unfold 7 {
    g'4 f' e' d'
  }
  \stopMeasureCount
}

\paper { tagline = ##f }

[image of music]


Print ChordNames with same root and different bass as slash and bass-note

To print subsequent ChordNames only differing in its bass note as slash and bass note use the here defined engraver. The behaviour may be controlled in detail by the chordChanges context property.

#(define Bass_changes_equal_root_engraver
  (lambda (ctx)
  "For sequential @code{ChordNames} with same root, but different bass, the root
markup is dropped: D D/C D/B  -> D /C /B
The behaviour may be controlled by setting the @code{chordChanges}
context-property."
    (let ((chord-pitches '())
          (last-chord-pitches '())
          (bass-pitch #f))
      (make-engraver
        ((initialize this-engraver)
          (let ((chord-note-namer (ly:context-property ctx 'chordNoteNamer)))
            ;; Set 'chordNoteNamer, respect user setting if already done
            (ly:context-set-property! ctx 'chordNoteNamer
              (if (procedure? chord-note-namer)
                  chord-note-namer
                  note-name->markup))))
        (listeners
          ((note-event this-engraver event)
            (let* ((pitch (ly:event-property event 'pitch))
                   (pitch-name (ly:pitch-notename pitch))
                   (pitch-alt (ly:pitch-alteration pitch))
                   (bass (ly:event-property event 'bass #f))
                   (inversion (ly:event-property event 'inversion #f)))
            ;; Collect notes of the chord
            ;;  - to compare inversed chords we need to collect the bass note
            ;;    as usual member of the chord, whereas an added bass must be
            ;;    treated separate from the usual chord-notes
            ;;  - notes are stored as pairs containing their
            ;;    pitch-name (an integer), i.e. disregarding their octave and
            ;;    their alteration
            (cond (bass (set! bass-pitch pitch))
                  (inversion
                    (set! bass-pitch pitch)
                    (set! chord-pitches
                          (cons (cons pitch-name pitch-alt) chord-pitches)))
                  (else
                    (set! chord-pitches
                          (cons (cons pitch-name pitch-alt) chord-pitches)))))))
        (acknowledgers
          ((chord-name-interface this-engraver grob source-engraver)
            (let ((chord-changes (ly:context-property ctx 'chordChanges #f)))
              ;; If subsequent chords are equal apart from their bass,
              ;; reset the 'text-property.
              ;; Equality is done by comparing the sorted lists of this chord's
              ;; elements and the previous chord. Sorting is needed because
              ;; inverted chords may have a different order of pitches.
              ;; `chord-changes' needs to be true
              (if (and bass-pitch
                       chord-changes
                       (equal?
                         (sort chord-pitches car<)
                         (sort last-chord-pitches car<)))
                  (ly:grob-set-property! grob 'text
                    (make-line-markup
                      (list
                        (ly:context-property ctx 'slashChordSeparator)
                        ((ly:context-property ctx 'chordNoteNamer)
                         bass-pitch
                         (ly:context-property ctx 'chordNameLowercaseMinor))))))
              (set! last-chord-pitches chord-pitches)
              (set! chord-pitches '())
              (set! bass-pitch #f))))
        ((finalize this-engraver)
          (set! last-chord-pitches '()))))))

myChords = \chordmode {
  %\germanChords

  \set chordChanges = ##t
  d2:m d:m/cis

  d:m/c
  \set chordChanges = ##f
  d:m/b

  e1:7
  \set chordChanges = ##t
  e
  \break
  \once \set chordChanges = ##f
  e1/f
  e2/gis e/+gis e e:m/f d:m d:m/cis d:m/c
  \set chordChanges = ##f
  d:m/b
}

<<
  \new ChordNames
    \with { \consists #Bass_changes_equal_root_engraver }
    \myChords
  \new Staff \myChords
>>

[image of music]


Supressió dels nombres de compàs de tota la partitura

Es poden eliminar completament els nombres de compàs traient el gravador Bar_number_engraver del context de Score.

\layout {
  \context {
    \Score
    \omit BarNumber
    % or:
    %\remove "Bar_number_engraver"
  }
}

\relative c'' {
  c4 c c c \break
  c4 c c c
}

\paper { tagline = ##f }

[image of music]


Us del corxet recte al començament d’un grup de pentagrames

Es pot usar el delimitador de començament d’un sistema SystemStartSquare establint-lo explícitament dins d’un context StaffGroup o ChoirStaffGroup.

\score {
  \new StaffGroup { <<
  \set StaffGroup.systemStartDelimiter = #'SystemStartSquare
    \new Staff { c'4 d' e' f' }
    \new Staff { c'4 d' e' f' }
  >> }
}

[image of music]


Using marklines in a Frenched score

Using MarkLine contexts (such as in LSR1010) in a Frenched score can be problematic if all the staves between two MarkLines are removed in one system. The Keep_alive_together_engraver can be used within each StaffGroup to keep the MarkLine alive only as long as the other staves in the group stay alive.

bars = {
  \tempo "Allegro" 4=120
  s1*2
  \repeat unfold 5 { \mark \default s1*2 }
  \bar "||"
  \tempo "Adagio" 4=40
  s1*2
  \repeat unfold 8 { \mark \default s1*2 }
  \bar "|."
}
winds = \repeat unfold 120 { c''4 }
trumpet = { \repeat unfold 8 g'2 R1*16 \repeat unfold 4 g'2 R1*8 }
trombone = { \repeat unfold 4 c'1 R1*8 d'1 R1*17 }
strings = \repeat unfold 240 { c''8 }

#(set-global-staff-size 16)
\paper {
  systems-per-page = 5
  ragged-last-bottom = ##f
}

\layout {
  indent = 15\mm
  short-indent = 5\mm
  \context {
    \name MarkLine
    \type Engraver_group
    \consists Output_property_engraver
    \consists Axis_group_engraver
    \consists Mark_engraver
    \consists Metronome_mark_engraver
    \consists Staff_collecting_engraver
    \override VerticalAxisGroup.remove-empty = ##t
    \override VerticalAxisGroup.remove-layer = #'any
    \override VerticalAxisGroup.staff-affinity = #DOWN
    \override VerticalAxisGroup.nonstaff-relatedstaff-spacing.padding = 1
    keepAliveInterfaces = #'()
  }
  \context {
    \Staff
    \override VerticalAxisGroup.remove-empty = ##t
    \override VerticalAxisGroup.remove-layer = ##f
  }
  \context {
    \StaffGroup
    \accepts MarkLine
    \consists Keep_alive_together_engraver
  }
  \context {
    \Score
    \remove Mark_engraver
    \remove Metronome_mark_engraver
    \remove Staff_collecting_engraver
  }
}

\score {
  <<
    \new StaffGroup = "winds" \with {
      instrumentName = "Winds"
      shortInstrumentName = "Winds"
    } <<
      \new MarkLine \bars
      \new Staff \winds
    >>
    \new StaffGroup = "brass" <<
      \new MarkLine \bars
      \new Staff = "trumpet" \with {
        instrumentName = "Trumpet"
        shortInstrumentName = "Tpt"
      } \trumpet
      \new Staff = "trombone" \with {
        instrumentName = "Trombone"
        shortInstrumentName = "Tbn"
      } \trombone
    >>
    \new StaffGroup = "strings" \with {
      instrumentName = "Strings"
      shortInstrumentName = "Strings"
    } <<
      \new MarkLine \bars
      \new Staff = "strings" { \strings }
    >>
  >>
}

[image of music]


Plantilla per a conjunt amb lletres alineades a sobre i a sota dels pentagrames

Aquesta plantilla és, bàsicament, la mateixa que la senzilla plantilla “Conjunt vocal”, excepte que aquí totes les línies de lletra es col·loquen utilitzant alignAboveContext i 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
  >>
}

[image of music]


Estrofa per a solista i tornada a dues veus

Aquesta plantilla crea una partitura que comença amb una estrofa per a solista i continua amb una tornada a dues veus. També mostra l’ús de silencis de separació dins de la variable \global per definit canvis de compàs (i altres exemple que són comuns a totes les parts) al llarg de tota la partitura.

\header { tagline = ##f }

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

[image of music]


Tweaks and overrides

Changing defaults

Tweaking output


Afegir una indicació d’octava alta a una sola veu

Si teniu més d’una veu al mateix pentagrama, el canvi d’octavació d’una veu transportarà la posició de les notes en totes les veus mentre duri la clau de l’octava. Si l’octavació es vol aplicar sols a una veu, s’han d’ajustar explícitament la middleCPosition i la clau d’octava. En aquest fragment de codi el valor de middleCPosition per a la clau de Fa és normalment 6, sis posicions per sobre de la línia del Do central, de manera que en la porció de 8va el valor de middleCPosition és encara 7 posicions (una octava) més alta.

\layout {
  \context {
    \Staff
    \remove Ottava_spanner_engraver
  }
  \context {
    \Voice
    \consists Ottava_spanner_engraver
  }
}

{
  \clef bass
  << { <g d'>1~ q2 <c' e'> }
  \\
    {
      r2.
      \ottava -1
      <b,,, b,,>4 ~ |
      q2
      \ottava 0
      <c e>2
    }
  >>
}

[image of music]


Afegir enllaços als objectes

Per afegir un enllaç al segell d’un objecte gràfic, podem usar add-link tal i com es defineix aquí. Funciona amb \override i amb \tweak. Inconvenient: point-and-click (apuntar i clicar) quedarà obstaculitzat pels objectes gràfics enllaçats.

Limitació: funciona sols per a PDF.

Els objectes enllaçats s’acoloreixen amb una ordre a part.

#(define (add-link url-strg)
  (lambda (grob)
    (let* ((stil (ly:grob-property grob 'stencil)))
      (if (ly:stencil? stil)
          (let* ((x-ext (ly:stencil-extent stil X))
                 (y-ext (ly:stencil-extent stil Y))
                 (url-expr `(url-link ,url-strg ,x-ext ,y-ext))
                 (new-stil
                   (ly:stencil-add
                     (ly:make-stencil url-expr x-ext y-ext)
                     stil)))
          (ly:grob-set-property! grob 'stencil new-stil))))))

%%%% test

%% For easier maintenance of this snippet the URL is formatted to use the
%% actually used LilyPond version.
%% Of course a literal URL would work as well.

#(define major.minor-version
  (string-join (take (string-split (lilypond-version) #\.) 2) "."))

urlI =
#(format #f
  "http://lilypond.org/doc/v~a/Documentation/notation/writing-pitches"
  major.minor-version)

urlII =
#(format #f
  "http://lilypond.org/doc/v~a/Documentation/notation/rhythms"
  major.minor-version)

urlIII =
#(format #f
  "http://lilypond.org/doc/v~a/Documentation/notation/note-heads"
  major.minor-version)

urlIV =
#(format #f
  "http://lilypond.org/doc/v~a/Documentation/notation/beams"
  major.minor-version)

urlV =
#(format #f
  "http://lilypond.org/doc/v~a/Documentation/notation/note-head-styles"
  major.minor-version)

urlVI =
#(format #f
  "http://lilypond.org/doc/v~a/Documentation/notation/writing-pitches"
  major.minor-version)

\relative c' {
   \key cis \minor

   \once \override Staff.Clef.color = #green
   \once \override Staff.Clef.after-line-breaking =
     #(add-link urlI)

   \once \override Staff.TimeSignature.color = #green
   \once \override Staff.TimeSignature.after-line-breaking =
     #(add-link urlII)

   \once \override NoteHead.color = #green
   \once \override NoteHead.after-line-breaking =
     #(add-link urlIII)

   cis'1
   \once \override Beam.color = #green
   \once \override Beam.after-line-breaking =
     #(add-link urlIV)
   cis8 dis e fis gis2
   <gis,
    \tweak Accidental.color #green
    \tweak Accidental.after-line-breaking #(add-link urlVI)
    \tweak color #green
    \tweak after-line-breaking #(add-link urlV)
    \tweak style #'harmonic
    bis
    dis
    fis
   >1
   <cis, cis' e>
}

[image of music]


Adding markups in a tablature

By default markups does not show in a tablature.

To make them appear, simply use the command \revert TabStaff.TextScript.stencil

%% http://lsr.di.unimi.it/LSR/Item?id=919
% by P.P.Schneider on June 2014

high  = { r4 r8 <g c'> q r8 r4 }

low = { c4 r4 c8 r8 g,8 b, }

pulse = { s8^"1" s^"&" s^"2" s^"&" s^"3" s^"&" s^"4" s^"&" }

\score {
 \new TabStaff {
   \repeat unfold 2 << \high \\ \low \\ \pulse >>
  }
  \layout {
    \context {
      \TabStaff
      \clef moderntab
      \revert TextScript.stencil
      \override TextScript.font-series = #'bold
      \override TextScript.font-size = #-2
      \override TextScript.color = #red

    }
    \context {
      \Score
      proportionalNotationDuration = \musicLength 8
    }
  }
}

[image of music]


Afegir marques de temps a glissandos llargs

Els temps que se salten a glissandos molt llargs s’indiquen a vegades mitjançant marques de temps, que sovint consisteixen en figures sense cap. Aquestes pliques es poden usar també per allotjar indicacions expressives intermèdies.

Si les pliques no queden ben alineades amb el glissando, podria caldre recol·locar-les lleugerament.

glissandoSkipOn = {
  \override NoteColumn.glissando-skip = ##t
  \hide NoteHead
  \override NoteHead.no-ledgers = ##t
}

glissandoSkipOff = {
  \revert NoteColumn.glissando-skip
  \undo \hide NoteHead
  \revert NoteHead.no-ledgers
}

\relative c'' {
  r8 f8\glissando
  \glissandoSkipOn
  f4 g a a8\noBeam
  \glissandoSkipOff
  a8

  r8 f8\glissando
  \glissandoSkipOn
  g4 a8
  \glissandoSkipOff
  a8 |

  r4 f\glissando \<
  \glissandoSkipOn
  a4\f \>
  \glissandoSkipOff
  b8\! r |
}

[image of music]


Ajustament d’espaiat de les notes d’adorn

Es poden ajustar la separació entre les notes d’adorn utilitzant la propietat spacing-increment de Score.GraceSpacing.

graceNotes = {
  \grace { c4 c8 c16 c32 }
  c8
}

\relative c'' {
  c8
  \graceNotes
  \override Score.GraceSpacing.spacing-increment = #2.0
  \graceNotes
  \revert Score.GraceSpacing.spacing-increment
  \graceNotes
}

[image of music]


Ajustament de l’espaiat vertical de la lletra

Aquest fragment de codi mostra com situar la línia de base de la lletra més a prop del pentagrama.

% Default layout:
<<
  \new Staff \new Voice = melody \relative c' {
    c4 d e f
    g4 f e d
    c1
  }
  \new Lyrics \lyricsto melody { aa aa aa aa aa aa aa aa aa }

  \new Staff {
    \new Voice = melody \relative c' {
      c4 d e f
      g4 f e d
      c1
    }
  }
  % Reducing the minimum space below the staff and above the lyrics:
  \new Lyrics \with {
    \override VerticalAxisGroup.nonstaff-relatedstaff-spacing =
      #'((basic-distance . 1))
  }
  \lyricsto melody { aa aa aa aa aa aa aa aa aa }
>>

[image of music]


Adjusting slur positions vertically

Using \override Slur.positions it is possible to set the vertical position of the start and end points of a slur to absolute values (or rather, forcing LilyPond’s slur algorithm to consider these values as desired). In many cases, this means a lot of trial and error until good values are found. You probably have tried the \offset command next just to find out that it doesn’t work for slurs, emitting a warning instead.

The code in this snippet allows you to tweak the vertical start and end positions by specifying relative changes, similar to \offset.

Syntax: \offsetPositions #'(dy1 . dy2)

offsetPositions =
#(define-music-function (offsets) (number-pair?)
  #{
     \once \override Slur.control-points =
       #(lambda (grob)
          (match-let ((((_ . y1) _ _ (_ . y2))
                       (ly:slur::calc-control-points grob))
                      ((off1 . off2) offsets))
            (set! (ly:grob-property grob 'positions)
                  (cons (+ y1 off1) (+ y2 off2)))
            (ly:slur::calc-control-points grob)))
  #})

\relative c'' {
  c4(^"default" c, d2)
  \offsetPositions #'(0 . 1)
  c'4(^"(0 . 1)" c, d2)
  \offsetPositions #'(0 . 2)
  c'4(^"(0 . 2)" c, d2)
  \bar "||"
  g4(^"default" a d'2)
  \offsetPositions #'(1 . 0)
  g,,4(^"(1 . 0)" a d'2)
  \offsetPositions #'(2 . 0)
  g,,4(^"(2 . 0)" a d'2)
}

[image of music]


Alterar la longitud de les pliques unides per una barra

Es pot variar la longitud de les pliques de les figures unides per una barra mitjançant la sobreescriptura de la propietat beamed-lengths dels detalls (details) de l’objecte Stem. Si s’utilitza un sol valor com argument, la longitud s’aplica a totes les pliques. Si s’usen diversos arguments, el primer s’aplica a les corxeres, el segon a les semicorxeres, i així successivament. L’últim argument també s’aplica a totes les figures que són més curtes que la longitud de la figura de l’últim argument. També es poden usar arguments no enters.

\relative c'' {
  \override Stem.details.beamed-lengths = #'(2)
  a8[ a] a16[ a] a32[ a]
  \override Stem.details.beamed-lengths = #'(8 10 12)
  a8[ a] a16[ a] a32[ a] r8
  \override Stem.details.beamed-lengths = #'(8)
  a8[ a]
  \override Stem.details.beamed-lengths = #'(8.5)
  a8[ a]
  \revert Stem.details.beamed-lengths
  a8[ a] a16[ a] a32[ a] r16
}

[image of music]


Numeració de compassos alternativa

Es poden seleccionar dos mètodes alternatius per a la numeració de compassos, especials quan hi ha repeticions.

music = \relative c' {
  \repeat volta 3 {
    c4 d e f |
    \alternative {
      \volta 1 { c4 d e f | c2 d \break }
      \volta 2 { f4 g a b | f4 g a b | f2 a | \break }
      \volta 3 { c4 d e f | c2 d } } }
  c1 \bar "|."
}

\markup "default"
{
  \music
}

\markup \typewriter "'numbers"
{
  \set Score.alternativeNumberingStyle = #'numbers
  \music
}

\markup \typewriter "'numbers-with-letters"
{
  \set Score.alternativeNumberingStyle = #'numbers-with-letters
  \music
}

\paper { tagline = ##f }

[image of music]


Claus d’anàlisis a sobre del pentagrama

De forma predeterminada s’afegeixen claus d’anàlisis senzills a sota del pentagrama. L’exemple següent mostra una manera de col·locar-los a sobre.

\layout {
  \context {
    \Voice
    \consists "Horizontal_bracket_engraver"
  }
}

\relative c'' {
  \once \override HorizontalBracket.direction = #UP
  c2\startGroup
  d2\stopGroup
}

[image of music]


Analysis brackets with labels

Text markup may be added to analysis brackets through the text property of the HorizontalBracketText grob. Adding different texts to brackets beginning at the same time requires the \tweak command.

Bracket text will be parenthesized after a line break.

\paper { tagline = ##f }

\layout {
  \context {
    \Voice
    \consists "Horizontal_bracket_engraver"
    \override HorizontalBracket.direction = #UP
  }
}

{
  \once\override HorizontalBracketText.text = "a"
    c''\startGroup d''\stopGroup
    \once\override HorizontalBracketText.text = "a'"
    e''\startGroup d''\stopGroup |
  c''-\tweak HorizontalBracketText.text
        \markup \bold \huge "b" \startGroup
     -\tweak HorizontalBracketText.text "a" \startGroup
    d''\stopGroup
    e''-\tweak HorizontalBracketText.text "a'" \startGroup
    d''\stopGroup\stopGroup |
  c''-\tweak HorizontalBracketText.text foo \startGroup
    d'' e'' f'' | \break
  g'' a'' b'' c'''\stopGroup
}

[image of music]


Lligadures asimètriques

Es pot fer que una lligradura d’expressió sigui asimètrica per adaptar-se millor un patró asimètric de notes.

slurNotes = { d,8( a' d f a f' d, a) }

\relative c' {
  \stemDown
  \slurUp
  \slurNotes
  \once \override Slur.eccentricity = #3.0
  \slurNotes
}

[image of music]


Breaking vertical alignment of dynamics and textscripts

By default, LilyPond uses DynamicLineSpanner grobs to vertically align successive dynamic objects like hairpins and dynamic text. However, this is not always wanted. By inserting \breakDynamicSpan, which ends the alignment spanner prematurely, this vertical alignment can be avoided.

{ g1\< |
  e''\f\> |
  c'\p }

{ g1\< |
  e''\breakDynamicSpan\f\> |
  c'\p }

\paper { tagline = ##f }

[image of music]


Cesura tipus "vies del tren" amb calderó

En ocasions es denota una «cesura» mitjançant una doble marca de respiració semblant a les vies d’un tren, amb un calderó a sobre. Aquest fragment de codi presenta una combinació visualment satisfactòria d’aquestes dues marques.

\relative c'' {
  c2.
  % construct the symbol
  \override BreathingSign.text = \markup {
    \override #'(direction . 1)
    \override #'(baseline-skip . 1.8)
    \dir-column {
      \translate #'(0.155 . 0)
        \center-align \musicglyph "scripts.caesura.curved"
      \center-align \musicglyph "scripts.ufermata"
    }
  }
  \breathe c4
  % set the breath mark back to normal
  \revert BreathingSign.text
  c2. \breathe c4
  \bar "|."
}

[image of music]


Modificar la mida d’una nota solta d’una acord

Es poden modificar notes individuals d’un acord amb l’ordre \tweak, alterant la propietat font-size.

Dins d’un acord (entre angles simples < >), abans de la nota que volem alterar, situem l’ordre \tweak seguida per #'font-size i definim la mida adequada com #-2 (un cap petit).

\relative c' {
  <\tweak font-size #+2 c e g c
   \tweak font-size #-2 e>1
   ^\markup { A tiny e }_\markup { A big c }
}

[image of music]


Changing beam thickness and spacing

To make beams thicker or thinner alter the Beam.beam-thickness property. To adjust the spacing between beams alter the Beam.length-fraction property.

\relative f' {
  \time 1/8
  \override Beam.beam-thickness = #0.4
  \override Beam.length-fraction = #0.8
  c32 c c c
  \revert Beam.beam-thickness  % 0.48 is default thickness
  \revert Beam.length-fraction  % 1.0 is default spacing
  c32 c c c
  \override Beam.beam-thickness = #0.6
  \override Beam.length-fraction = #1.3
  c32 c c c
}

[image of music]


Canviar la forma dels silencis multicompàs

Si hi ha deu compassos de silenci o menys, s’imprimeix en el pentagrama una sèrie de silencis de breu i longa (coneguts en alemany com “Kirchenpausen”, «silencis eclesiàstics»); en cas contrari es mostra una barra normal. Aquest nombre predeterminat de deu es pot canviar sobreescrivint la propietat expand-limit:

\relative c'' {
  \compressMMRests {
    R1*2 | R1*5 | R1*9
    \override MultiMeasureRest.expand-limit = 3
    R1*2 | R1*5 | R1*9
  }
}

[image of music]


Modificació de propietats per a objetes gràfics individuals

L’ordre \applyOutput fa possible l’ajustament fi de qualsevol objecte de presentació, en qualsevol context. Requereix una funció de l’Scheme amb tres arguments

#(define (mc-squared grob grob-origin context)
   (let ((sp (ly:grob-property grob 'staff-position)))
     (ly:grob-set-property!
      grob 'stencil
      (grob-interpret-markup grob
			     #{ \markup \lower #0.5
				#(case sp
				   ((-5) "m")
				   ((-3) "c ")
				   ((-2) #{ \markup \teeny \bold 2 #})
				   (else "bla")) #}))))

\relative c' {
  <d f g b>2
  \applyOutput Voice.NoteHead #mc-squared
  <d f g b>2
}

[image of music]


Canviar el text i els estils d’objecte d’extensió per a les indicacions dinàmiques textuals

Es pot modificar el text empleat per als crescendos i decrescendos modificant les propietats de context crescendoText i decrescendoText.

L’estil de la línia d’extensió es pot canviar modificant la propietat 'style de DynamicTextSpanner. El valor predeterminat és 'dashed-line (línia discontínua), i entre d’altres valors possibles es troben 'line (línia), 'dotted-line (línia de punts) i 'none (res):

\relative c'' {
  \set crescendoText = \markup { \italic { cresc. poco } }
  \set crescendoSpanner = #'text
  \override DynamicTextSpanner.style = #'dotted-line
  a2\< a
  a2 a
  a2 a
  a2 a\mf
}

[image of music]


Canviar la família de tipus de lletra predeterminada per al text

Les famílies de tipus de lletra per al text es poden sobreescriure amb make-pango-font-tree.

%{
You may have to install additional fonts.

Red Hat Fedora

  dejavu-fonts-all

Debian GNU/Linux, Ubuntu

  fonts-dejavu-core
  fonts-dejavu-extra
%}

\paper {
  %{
     run
         lilypond -dshow-available-fonts
     to show all fonts available in the process log.
  %}
  property-defaults.fonts.serif = "DejaVu Serif"
  property-defaults.fonts.sans = "DejaVu Sans"
  property-defaults.fonts.typewriter = "DejaVu Sans Mono"
}

{
  g'''4^\markup {
    DejaVu Serif: \bold bold
                  \italic italic
                  \italic \bold { bold italic }
  }
  g4_\markup {
    \override #'(font-family . sans) {
      DejaVu Sans: \bold bold
                   \italic italic
                   \italic \bold { bold italic }
    }
  }
  g''2^\markup {
    \override #'(font-family . typewriter) {
      DejaVu Sans Mono: \bold bold
                        \italic italic
                        \italic \bold { bold italic }
    }
  }
}

[image of music]


Modificar la mida de la pauta

Tot i que la manera més senzilla de redimensionar els pentagrames és usar #(set-global-staff-size xx), la mida d’una pauta individual es pot canviar escalant les propietats de 'staff-space i de fontSize.

<<
  \new Staff {
    \relative c'' {
      \dynamicDown
      c8\ff c c c c c c c
    }
  }
  \new Staff \with {
    fontSize = #-3
    \override StaffSymbol.staff-space = #(magstep -3)
  } {
    \clef bass
    c8 c c c c\f c c c
  }
>>

[image of music]


Canviar el tempo sense indicació metronòmica

Per canviar el tempo a la sortida MIDI sense imprimir res, fem invisible la indicació metronòmica:

\score {
  \new Staff \relative c' {
    \tempo 4 = 160
    c4 e g b
    c4 b d c
    \set Score.tempoHideNote = ##t
    \tempo 4 = 96
    d,4 fis a cis
    d4 cis e d
  }
  \layout { }
  \midi { }
}

[image of music]


Modificar el text de las indicacions de pedal

Es pot usar Staff.pedalSustainStrings per fixar el text de les indicacions de pisar pedal i aixecar pedal. Observeu que les úniques cadenes vàlides són les que estan a la llista de glifs de pedal: els valors que apareixen en aquest fragment de codi són una relació exhaustiva.

sustainNotes = { c4\sustainOn d e\sustainOff\sustainOn f\sustainOff }

\relative c' {
  \sustainNotes
  \set Staff.pedalSustainStrings = #'("P" "P-" "-")
  \sustainNotes
  \set Staff.pedalSustainStrings = #'("d" "de" "e")
  \sustainNotes
  \set Staff.pedalSustainStrings = #'("M" "M-" "-")
  \sustainNotes
  \set Staff.pedalSustainStrings = #'("Ped" "*Ped" "*")
  \sustainNotes
}

[image of music]


Controlar la visibilitat dels objectes d’extensió després d’un salt de línia

La visibilitat dels objectes d’extensió que acaben a la primera nota després d’un salt de línia està controlada per la funció de crida de after-line-breaking ly:spanner::kill-zero-spanned-time.

Per als objectes com els glissandos i els reguladors, el comportament predeterminat és ocultar l’objecte d’extensió després del salt; la inhabilitació de la funció de callblack fa que l’object d’extensió trencat per l’esquerra pot mostrar-se.

De forma inversa, els objectes d’extensió que són visibles normalment, com els objectes d’extensió de text, es poden ocultar habilitant la funció de callback.

\paper {
  ragged-right = ##t
  tagline = ##f
}

\relative c'' {
  \override Hairpin.to-barline = ##f
  \override Glissando.breakable = ##t
  % show hairpin
  \override Hairpin.after-line-breaking = ##t
  % hide text span
  \override TextSpanner.after-line-breaking =
    #ly:spanner::kill-zero-spanned-time
  e2\<\startTextSpan
  % show glissando
  \override Glissando.after-line-breaking = ##t
  f2\glissando
  \break
  f,1\!\stopTextSpan
}

[image of music]


Controlling the appearance of tremolo slashes

Using various properties of the StemTremolo grob it is possible to control the appearance of tremolo slashes.

music = {
  a''4:32 a':
  e''8: \noBeam e':
  a'':[ a':]
  f':[ g':]
  d':[ d':]
}

\new Staff {
  <>^\markup "default"
  \music
}

\new Staff {
  <>^\markup \typewriter "style = #'constant"
  \override StemTremolo.style = #'constant
  \music
}

\new Staff {
  <>^\markup \typewriter "shape = #'rectangle"
  \override StemTremolo.shape = #'rectangle
  \music
}

\new Staff {
  <>^\markup \typewriter "shape = #'beam-like"
  \override StemTremolo.shape = #'beam-like
  \music
}

\new Staff {
  <>^\markup \typewriter "slope = -0.2"
  \override StemTremolo.slope = -0.2
  \music
}

\paper {
  indent = 0
  tagline = ##f
}

[image of music]


Controlar l’ordenació vertical de les inscripcions

L’orden vertical que ocupen les inscripcions gràfiques està controlat amb la propietat 'script-priority. Quant més baix és aquest número, més a prop de la nota es col·locarà. En aquest exemple, el TextScript (el sostingut) té primer la prioritat més baixa, per la qual cosa se situa en la posició més baixa al primer exemple. En el segon, el semitrí (el Script) és el que la té més baixa, per la qual cosa se situa en la part interior. Quan dos objectes tenen la mateixa prioritat, l’ordre en el qual s’introdueixen determina quin serà el que apareix en primer lloc.

\relative c''' {
  \once \override TextScript.script-priority = -100
  a2^\prall^\markup { \sharp }

  \once \override Script.script-priority = -100
  a2^\prall^\markup { \sharp }

  \set fingeringOrientations = #'(up)
  <c-2 a-1>2
  <a-1 c\tweak script-priority -100 -2>2
}

[image of music]


Control de la visibilitat dels corxets de grup especial

El comportament predeterminat de la visibilitat dels corxets de grup de valoració especial és imprimir el corxet a no ser que hi hagi una barra de la mateixa longitud que el grup especial. Per controlas la visibilitat dels corxets de grup, establiu la propietat 'bracket-visibility a #t (sempre imprimir el corxet). #f (no imprimir-lo mai) o #'if-no-beam (imprimir el corxet sols si no hi ha barra).

music = \relative c'' {
  \tuplet 3/2 { c16[ d e } f8]
  \tuplet 3/2 { c8 d e }
  \tuplet 3/2 { c4 d e }
}

\new Voice {
  \relative c' {
    \override Score.TextMark.non-musical = ##f
    \textMark "default" \music
    \override TupletBracket.bracket-visibility = #'if-no-beam
    \textMark \markup \typewriter "'if-no-beam" \music
    \override TupletBracket.bracket-visibility = ##t
    \textMark \markup \typewriter "#t" \music
    \override TupletBracket.bracket-visibility = ##f
    \textMark \markup \typewriter "#f" \music
    \omit TupletBracket
    \textMark \markup \typewriter "omit" \music
  }
}

\paper { tagline = ##f }

[image of music]


Crear un grupet d’anticipació

La creació d’un grupet circular d’anticipació entre dues notes, on la nota inferior del grupet utilitza una alteració, requereix diverses sobreescriptures de propietats. La propietat outside-staff-priority es pot establir al valor #f, atès que en aquest cas tindria prioritat sobre la propietat avoid-slur property. Canviant les fraccions 2/3 i 1/3 pot ajustar-se la posició horitzontal.

\relative c'' {
  \after 2*2/3 \turn c2( d4) r |
  \after 4 \turn c4.( d8)
  \after 4
  {
    \once \set suggestAccidentals = ##t
    \once \override AccidentalSuggestion.outside-staff-priority = ##f
    \once \override AccidentalSuggestion.avoid-slur = #'inside
    \once \override AccidentalSuggestion.font-size = -3
    \once \override AccidentalSuggestion.script-priority = -1
    \once \hideNotes
    cis8\turn \noBeam
  }
  d4.( e8)
}

[image of music]


Creació d’armadures personalitzades

El LilyPond accepta armadures personalitzades. En aquest exemple, es mostra l’armadura de re menor amb una rang estès de bemolls.

\new Staff \with {
  \override StaffSymbol.line-count = #8
  \override KeySignature.flat-positions = #'((-7 . 6))
  \override KeyCancellation.flat-positions = #'((-7 . 6))
  % presumably sharps are also printed in both octaves
  \override KeySignature.sharp-positions = #'((-6 . 7))
  \override KeyCancellation.sharp-positions = #'((-6 . 7))

  \override Clef.stencil = #
  (lambda (grob)(grob-interpret-markup grob
  #{ \markup\combine
    \musicglyph "clefs.C"
    \translate #'(-3 . -2)
    \musicglyph "clefs.F"
   #}))
    clefPosition = #3
    middleCPosition = #3
    middleCClefPosition = #3
}

{
  \key d\minor
  f bes, f bes,
}

[image of music]


Crear digitacions de dues xifres

És possible crear digitacions amb el nombre més gran de 5.

\relative c' {
  c1-10
  c1-50
  c1-36
  c1-29
}

[image of music]


Crear elements de extensió textuals

Les ordres \startTextSpan i \stopTextSpan permeten la creació d’elements d’extensió textuals tan fàcilment com indicacions de pedal o octavacions. Sobreescrivim certes propietats de l’object TextSpanner per modificar la seva sortida.

\paper { ragged-right = ##f }

\relative c'' {
  \override TextSpanner.bound-details.left.text = #"bla"
  \override TextSpanner.bound-details.right.text = #"blu"
  a4 \startTextSpan
  b4 c
  a4 \stopTextSpan

  \override TextSpanner.style = #'line
  \once \override TextSpanner.bound-details.left.stencil-align-dir-y = #CENTER
  a4 \startTextSpan
  b4 c
  a4 \stopTextSpan

  \override TextSpanner.style = #'dashed-line
  \override TextSpanner.bound-details.left.text =
    \markup { \draw-line #'(0 . 1) }
  \override TextSpanner.bound-details.right.text =
    \markup { \draw-line #'(0 . -2) }
  \once \override TextSpanner.bound-details.right.padding = #-2

  a4 \startTextSpan
  b4 c
  a4 \stopTextSpan

  \set Staff.middleCPosition = #-13
  \override TextSpanner.dash-period = #10
  \override TextSpanner.dash-fraction = #0.5
  \override TextSpanner.thickness = #10
  a4 \startTextSpan
  b4 c
  a4 \stopTextSpan
}

[image of music]


Cross-staff chords - beaming problems workaround

Sometimes it is better to use stems from the upper staff for creating cross-staff chords, because no problems with automatic beam collision avoidance then arise. If the stems from the lower staff were used in the following example, it would be necessary to change the automatic beam collision avoidance settings so that it doesn’t detect collisions between staves using \override Staff.Beam.collision-voice-only = ##t

\new PianoStaff <<
  \new Staff = up
    \relative c' {
      <<
        { r4
          \override Stem.cross-staff = ##t
          \override Stem.length = #19 % this is in half-spaces,
              % so it makes stems 9.5 staffspaces long
          \override Stem.Y-offset = #-6 % stems are normally lengthened
              % upwards, so here we must lower the stem by the amount
              % equal to the lengthening - in this case (19 - 7) / 2
              % (7 is default stem length)
          e e e }
        { s4
          \change Staff = "bottom"
          \override NoteColumn.ignore-collision = ##t
          c, c c
        }
      >>
    }
  \new Staff = bottom
    \relative c' {
      \clef bass
      \voiceOne
      g8 a g a g a g a
    }
>>

[image of music]


Pliques de pentagrama creuat

Aquest fragment de codi mostra l’ús del gravador Span_stem_engraver i de \crossStaff per connectar automàticament pliques d’un pentagrama a un altre. No cal especificar la longitud de la plica perquè la distància variable entre els caps de les notes i els pentagrames es calcula automàticament.

\layout {
  \context {
    \PianoStaff
    \consists "Span_stem_engraver"
  }
}

\new PianoStaff <<
  \new Staff {
    <b d'>4 r d'16\> e'8. g8 r\! |
    e'8 f' g'4
      \voiceTwo \autoBeamOff
      % Down to lower staff
      \crossStaff { e'8 e'8 } e'4 |
  }

  \new Staff {
    \clef bass
    \voiceOne \autoBeamOff
    % Up to upper staff
    \crossStaff { <e g>4 e, g16 a8. c8 } d |
    \autoBeamOn g8 f g4 \voiceTwo g8 g g4 |
    }
>>

[image of music]


Custos

Es poden gravar «custos» en diferents estils.

\layout { ragged-right = ##t }

\new Staff \with { \consists "Custos_engraver" } \relative c' {
  \override Staff.Custos.neutral-position = #4

  \override Staff.Custos.style = #'hufnagel
  c1^"hufnagel" \break
  <d a' f'>1

  \override Staff.Custos.style = #'medicaea
  c1^"medicaea" \break
  <d a' f'>1

  \override Staff.Custos.style = #'vaticana
  c1^"vaticana" \break
  <d a' f'>1

  \override Staff.Custos.style = #'mensural
  c1^"mensural" \break
  <d a' f'>1
}

[image of music]


Personalitzar els diagrames de posicions

Es poden establir les propietats dels diagrames de posicions d’acords per mitjà de 'fret-diagram-details. Per als diagrames de posicions de FretBoard, s’apliquen els overrides (sobreescriptures) a l’objecte FretBoards.FretBoard. Com Voice, FretBoards és un context del nivell inferior, i per tant es pot ometre el seu nom a la sobreescriptura de propietats.

\include "predefined-guitar-fretboards.ly"

\storePredefinedDiagram #default-fret-table \chordmode { c' }
                        #guitar-tuning
                        "x;1-1-(;3-2;3-3;3-4;1-1-);"

% shorthand
oo = #(define-music-function
       (grob-path value)
       (list? scheme?)
       #{ \once \override $grob-path = #value #})

<<
  \new ChordNames {
    \chordmode { c1 | c | c | d }
  }
  \new FretBoards {
    % Set global properties of fret diagram
    \override FretBoards.FretBoard.size = 1.2
    \override FretBoard.fret-diagram-details.finger-code = #'in-dot
    \override FretBoard.fret-diagram-details.dot-color = #'white
    \chordmode {
      c
      \oo FretBoard.size #1.0
      \oo FretBoard.fret-diagram-details.barre-type #'straight
      \oo FretBoard.fret-diagram-details.dot-color #'black
      \oo FretBoard.fret-diagram-details.finger-code #'below-string
      c'
      \oo FretBoard.fret-diagram-details.barre-type #'none
      \oo FretBoard.fret-diagram-details.number-type #'arabic
      \oo FretBoard.fret-diagram-details.orientation #'landscape
      \oo FretBoard.fret-diagram-details.mute-string "M"
      \oo FretBoard.fret-diagram-details.label-dir #LEFT
      \oo FretBoard.fret-diagram-details.dot-color #'black
      c'
      \oo FretBoard.fret-diagram-details.finger-code #'below-string
      \oo FretBoard.fret-diagram-details.dot-radius #0.35
      \oo FretBoard.fret-diagram-details.dot-position #0.5
      \oo FretBoard.fret-diagram-details.fret-count #3
      d
    }
  }
  \new Voice {
    c'1 | c' | c' | d'
  }
>>

[image of music]


Personalitzar diagrames de posicions de marcatge

Es poden establir les propietats dels diagrames de posicions a través de 'fret-diagram-details. Per als diagrames de posicions de marcatge, es poden aplicar overrides (sobreescriptures) a l’objecte Voice.TextScript o directament a l’element de marcatge.

<<
  \chords { c1 | c | c | d }

  \new Voice = "mel" {
    \textLengthOn
    % Set global properties of fret diagram
    \override TextScript.size = 1.2
    \override TextScript.fret-diagram-details.finger-code = #'in-dot
    \override TextScript.fret-diagram-details.dot-color = #'white

    %% C major for guitar, no barre, using defaults
       % terse style
    c'1^\markup { \fret-diagram-terse "x;3-3;2-2;o;1-1;o;" }

    %% C major for guitar, barred on third fret
       % verbose style
       % size 1.0
       % roman fret label, finger labels below string, straight barre
    c'1^\markup {
      % standard size
      \override #'(size . 1.0) {
        \override #'(fret-diagram-details . (
                     (number-type . roman-lower)
                     (finger-code . in-dot)
                     (barre-type . straight))) {
          \fret-diagram-verbose #'((mute 6)
                                   (place-fret 5 3 1)
                                   (place-fret 4 5 2)
                                   (place-fret 3 5 3)
                                   (place-fret 2 5 4)
                                   (place-fret 1 3 1)
                                   (barre 5 1 3))
        }
      }
    }

    %% C major for guitar, barred on third fret
       % verbose style
       % landscape orientation, arabic numbers, M for mute string
       % no barre, fret label down or left, small mute label font
    c'1^\markup {
      \override #'(fret-diagram-details . (
                   (finger-code . below-string)
                   (number-type . arabic)
                   (label-dir . -1)
                   (mute-string . "M")
                   (orientation . landscape)
                   (barre-type . none)
                   (xo-font-magnification . 0.4)
                   (xo-padding . 0.3))) {
        \fret-diagram-verbose #'((mute 6)
                                 (place-fret 5 3 1)
                                 (place-fret 4 5 2)
                                 (place-fret 3 5 3)
                                 (place-fret 2 5 4)
                                 (place-fret 1 3 1)
                                 (barre 5 1 3))
      }
    }

    %% simple D chord
       % terse style
       % larger dots, centered dots, fewer frets
       % label below string
    d'1^\markup {
      \override #'(fret-diagram-details . (
                   (finger-code . below-string)
                   (dot-radius . 0.35)
                   (dot-position . 0.5)
                   (fret-count . 3))) {
        \fret-diagram-terse "x;x;o;2-1;3-2;2-3;"
      }
    }
  }
>>

[image of music]


Mostrar claudàtor o clau en grups d’un sol pentagrama

Si hi ha un sols pentagrama en un dels tipus de sistema ChoirStaff o StaffGroup, el comportament predeterminat és que no s’imprimeixi el claudàtor a la barra inicial. Això es pot canviar sobreescrivint collapse-height per fixar el seu valor de manera que sigui menor que el nombre de línies a la pauta.

Observeu que en contextos com PianoStaff i GrandStaff en els quals els sistemes comencen amb una clau en comptes d’un claudàtor, s’ha d’establir el valor d’una propietat diferent, com es veu al segon sistema de l’exemple.

\score {
  \new StaffGroup <<
    % Must be lower than the actual number of staff lines
    \override StaffGroup.SystemStartBracket.collapse-height = 4
    \override Score.SystemStartBar.collapse-height = 4
    \new Staff {
      c'1
    }
  >>
}
\score {
  \new PianoStaff <<
    \override PianoStaff.SystemStartBrace.collapse-height = 4
    \override Score.SystemStartBar.collapse-height = 4
    \new Staff {
      c'1
    }
  >>
}

\paper { tagline = ##f }

[image of music]


Imprimir l’arbre genealògic d’un grob

En treballar amb les crides d’un grob, pot ser de molta utilitat entendre l’arbre genealògic d’un grob. La major part dels grobs tenen pares que influeixen en el posicionament del grob. Els pares X i Y influeixen en les posisions horitzontal i vertical del grob, respectivament. A més, cada pare pot tenir al seu cop pares.

Desafortunadament, hi ha diversos aspectes de la geneaologia d’un grob que pot portar a confusió:

* Els tipus de pare que té un grob poden dependre del context.

* Per a certs grobs, els pares X i Y són el mateix.

* Un "ancestre" concret pot estar relacionat amb un grob de més d’una manera.

* El concepte de "generacions" és enganyós.

Por exemple, el grob System pot ser tant un pare (sobre la vorfa Y) com un avi (dues vegades a la vora X) d’un grob VerticalAlignment.

Aquest macro imprimeix, en la consola, una representació textual de la genealogia d’un grob.

Quan es crida d’aquesta forma:

{ \once \override NoteHead.before-line-breaking = #display-ancestry c }

Es general la sortida següent:

NoteHead X,Y: NoteColumn X: PaperColumn X,Y: System Y: VerticalAxisGroup X: NonMusicalPaperColumn X,Y: System Y: VerticalAlignment X: NonMusicalPaperColumn X,Y: System Y: System

%% http://lsr.di.unimi.it/LSR/Item?id=622

#(define (get-ancestry grob)
  (if (not (null? (ly:grob-parent grob X)))
      (list (grob::name grob)
            (get-ancestry (ly:grob-parent grob X))
            (get-ancestry (ly:grob-parent grob Y)))
      (grob::name grob)))

#(define (format-ancestry lst padding)
   (string-append
    (symbol->string (car lst))
    "\n"
    (let ((X-ancestry
           (if (list? (cadr lst))
               (format-ancestry (cadr lst) (+ padding 3))
               (symbol->string (cadr lst))))
          (Y-ancestry
           (if (list? (caddr lst))
               (format-ancestry (caddr lst) (+ padding 3))
               (symbol->string (caddr lst)))))
      (if (equal? X-ancestry Y-ancestry)
          (string-append
           (format #f "~&")
           (make-string padding #\space)
           "X,Y: "
           (if (list? (cadr lst))
               (format-ancestry (cadr lst) (+ padding 5))
               (symbol->string (cadr lst))))
          (string-append
           (format #f "~&")
           (make-string padding #\space)
           "X: " X-ancestry
           "\n"
           (make-string padding #\space)
           "Y: " Y-ancestry
           (format #f "~&"))))
    (format #f "~&")))

#(define (display-ancestry grob)
   (format (current-error-port)
      "~3&~a~2%~a~&"
      (make-string 36 #\-)
      (if (ly:grob? grob)
          (format-ancestry (get-ancestry grob) 0)
          (format #f "~a is not a grob" grob))))

\relative c' {
  \once \override NoteHead.before-line-breaking = #display-ancestry
  f4
  \once \override Accidental.before-line-breaking = #display-ancestry
  \once \override Arpeggio.before-line-breaking = #display-ancestry
  <f as c>4\arpeggio
}

[image of music]


Harmònics amb puntet

Els harmònics artificials que usen l’ordre \harmonic no tenen puntet. Per sobreescriure aquest comportament, fixeu la propietat de context harmonicDots.

\relative c''' {
  \time 3/4
  \key f \major
  \set harmonicDots = ##t
  <bes f'\harmonic>2. ~
  <bes f'\harmonic>4. <a e'\harmonic>8( <gis dis'\harmonic> <g d'\harmonic>)
  <fis cis'\harmonic>2.
  <bes f'\harmonic>2.
}

[image of music]


Rodejar els objectes gràfics amb rectangles

Es pot sobreescriure la funció print-function per traçar un rectangle al voltant d’un objecte gràfic arbitrari.

\relative c'' {
  \override TextScript.stencil =
    #(make-stencil-boxer 0.1 0.3 ly:text-interface::print)
  c'4^"foo"

  \override Stem.stencil =
    #(make-stencil-boxer 0.05 0.25 ly:stem::print)
  \override Score.RehearsalMark.stencil =
    #(make-stencil-boxer 0.15 0.3 ly:text-interface::print)
  b8

  \revert Stem.stencil
  \revert Flag.stencil
  c4. c4
  \mark \default
  c1
}

[image of music]


Rodejar diversos objectes amb una circumferència

L’ordre de marcatge \circle traça circumferències al voltant de diversos objectes, per exemple les indicacions de digitació. Per a d’altres objectes es poden requerir ajustament específics: aquest exemple mostra dues estratègies per a lletres d’assaig i els números de compàs.

\relative c' {
  c1
  \set Score.rehearsalMarkFormatter =
    #(lambda (mark context)
             (make-circle-markup (format-mark-numbers mark context)))
  \mark \default

  c2 d^\markup {
    \override #'(thickness . 3) {
      \circle \finger 2
    }
  }
  \override Score.BarNumber.break-visibility = #all-visible
  \override Score.BarNumber.stencil =
    #(make-stencil-circler 0.1 0.25 ly:text-interface::print)
}

[image of music]


Objecte personalitzat d’extensió de text de matisos dinàmics, postfix

Funcions postfix per a la creació d’objectes d’extensió de text personalitzats. Els objectes d’extensió han de començar en la primera nota del compàs. Cal utilitzar -\mycresc, en cas contrari el començament de l’objecte d’extensió s’assignarà a la nota següent.

% Two functions for (de)crescendo spanners where you can explicitly
% give the spanner text.
mycresc =
#(define-music-function (mymarkup) (markup?)
   (make-music 'CrescendoEvent
               'span-direction START
               'span-type 'text
               'span-text mymarkup))
mydecresc =
#(define-music-function (mymarkup) (markup?)
   (make-music 'DecrescendoEvent
               'span-direction START
               'span-type 'text
               'span-text mymarkup))

\relative c' {
  c4-\mycresc "custom cresc" c4 c4 c4 |
  c4 c4 c4 c4 |
  c4-\mydecresc "custom decresc" c4 c4 c4 |
  c4 c4\! c4 c4
}

[image of music]


Objectes extensors de text postfix per a dinàmica

Els objectes d’extensió \cresc, \dim i \decresc ara es poden redefinir com a operadors postfix i produir un sols objecte d’extensió de text. La definició d’extensores personalitzats també és fàcil. Es poden barrejar amb facilitat els crescendi textuals i en forma de reguladors. \< i \> produeixen reguladors gràfics de forma predeterminada, \cresc etc. produeixen elements extensors de text de forma predeterminada.

% Some sample text dynamic spanners, to be used as postfix operators
crpoco =
#(make-music 'CrescendoEvent
             'span-direction START
             'span-type 'text
             'span-text "cresc. poco a poco")

\relative c' {
  c4\cresc d4 e4 f4 |
  g4 a4\! b4\crpoco c4 |
  c4 d4 e4 f4 |
  g4 a4\! b4\< c4 |
  g4\dim a4 b4\decresc c4\!
}

[image of music]


Extending a TrillSpanner

For TrillSpanner, the minimum-length property becomes effective only if the set-spacing-rods procedure is called explicitly.

To do this, the springs-and-rods property should be set to ly:spanner::set-spacing-rods.

\relative c' {
  \key c\minor
  \time 2/4
  c16( as') c,-. des-.
  \once\override TrillSpanner.minimum-length = #15
  \once\override TrillSpanner.springs-and-rods = #ly:spanner::set-spacing-rods
  \afterGrace es4
  \startTrillSpan { d16[( \stopTrillSpan es)] }
  c( c' g es c g' es d
  \hideNotes
  c8)
}

[image of music]


Estendre glissandos sobre repeticions

Es pot simular un glissando que s’estén fins a l’interior de diversos blocs \alternative de primera i segona vegada mitjançant l’addició d’una nota d’adorn oculta amb un glissando al començament de cada bloc \alternative. La nota d’adorn ha d’estar a la mateixa alçada que la nota que dona inici al primer glissando., Això s’implementa aquí amb una funció musical que agafa com a argument l’altura de la nota d’adorn.

Observeu que a la música polifònica la nota d’adorn ha de coincidir amb les notes d’adorn corresponents en totes les altres veus.

repeatGliss = #(define-music-function (grace)
  (ly:pitch?)
  #{
    % the next two lines ensure the glissando is long enough
    % to be visible
    \once \override Glissando.springs-and-rods
      = #ly:spanner::set-spacing-rods
    \once \override Glissando.minimum-length = 3.5
    \once \hideNotes
    \grace $grace \glissando
  #})

\score {
  \relative c'' {
    \repeat volta 3 { c4 d e f\glissando }
    \alternative {
      { g2 d }
      { \repeatGliss f g2 e }
      { \repeatGliss f e2 d }
    }
  }
}

music =  \relative c' {
  \voiceOne
  \repeat volta 2 {
    g a b c\glissando
  }
  \alternative {
    { d1 }
    { \repeatGliss c \once \omit StringNumber e1\2 }
  }
}

\score {
  \new StaffGroup <<
    \new Staff <<
      \new Voice { \clef "G_8" \music }
    >>
    \new TabStaff  <<
      \new TabVoice { \clef "moderntab" \music }
    >>
  >>
}

\paper { tagline = ##f }

[image of music]


Ajustament fi de les línies de pedal

Es pot alterar l’aspecte de les línies de pedal de diverses formes.

\paper { ragged-right = ##f }

\relative c'' {
  c2\sostenutoOn c
  c2\sostenutoOff c
  \once \override Staff.PianoPedalBracket.shorten-pair = #'(-7 . -2)
  c2\sostenutoOn c
  c2\sostenutoOff c
  \once \override Staff.PianoPedalBracket.edge-height = #'(0 . 3)
  c2\sostenutoOn c
  c2\sostenutoOff c
}

[image of music]


Flat Ties

The function takes the default Tie.stencil as an argument, calculating the result relying on the extents of this default.

Further tweaking is possible by overriding Tie.details.height-limit or with \shape. It’s also possible to change the custom-definition on the fly.

%% http://lsr.di.unimi.it/LSR/Item?id=1031

#(define ((flared-tie coords) grob)

  (define (pair-to-list pair)
     (list (car pair) (cdr pair)))

  (define (normalize-coords goods x y dir)
    (map
      (lambda (coord)
        ;(coord-scale coord (cons x (* y dir)))
        (cons (* x (car coord)) (* y dir (cdr coord))))
      goods))

  (define (my-c-p-s points thick)
    (make-connected-path-stencil
      points
      thick
      1.0
      1.0
      #f
      #f))

  ;; outer let to trigger suicide
  (let ((sten (ly:tie::print grob)))
    (if (grob::is-live? grob)
        (let* ((layout (ly:grob-layout grob))
               (line-thickness (ly:output-def-lookup layout 'line-thickness))
               (thickness (ly:grob-property grob 'thickness 0.1))
               (used-thick (* line-thickness thickness))
               (dir (ly:grob-property grob 'direction))
               (xex (ly:stencil-extent sten X))
               (yex (ly:stencil-extent sten Y))
               (lenx (interval-length xex))
               (leny (interval-length yex))
               (xtrans (car xex))
               (ytrans (if (> dir 0)(car yex) (cdr yex)))
               (uplist
                 (map pair-to-list
                      (normalize-coords coords lenx (* leny 2) dir))))

   (ly:stencil-translate
       (my-c-p-s uplist used-thick)
     (cons xtrans ytrans)))
   '())))

#(define flare-tie
  (flared-tie '((0 . 0)(0.1 . 0.2) (0.9 . 0.2) (1.0 . 0.0))))

\layout {
  \context {
    \Voice
    \override Tie.stencil = #flare-tie
  }
}

\paper {
  ragged-right = ##f
  tagline = ##f
}

\relative c' {
  a4~a
  \override Tie.height-limit = 4
  a'4~a
  a'4~a
  <a,, c e a c e a c e>~ q

  \break

  a'4~a
  \once \override Tie.details.height-limit = 14
  a4~a

  \break

  a4~a
  \once \override Tie.details.height-limit = 0.5
  a4~a

  \break

  a4~a
  \shape #'((0 . 0) (0 . 0.4) (0 . 0.4) (0 . 0)) Tie
  a4~a

  \break

  a4~a
  \once \override Tie.stencil =
    #(flared-tie '((0 . 0)(0.1 . 0.4) (0.9 . 0.4) (1.0 . 0.0)))
  a4~a

  a4~a
  \once \override Tie.stencil =
    #(flared-tie '((0 . 0)(0.06 . 0.1) (0.94 . 0.1) (1.0 . 0.0)))
  a4~a
}

[image of music]


Force a cancellation natural before accidentals

The following example shows how to force a natural sign before an accidental.

\relative c' {
  \key es \major
  bes c des
  \tweak Accidental.restore-first ##t
  eis
}

[image of music]


Forçar el desplaçament horitzontal de les notes

Quan el motor de gravat no és capaç de tot, es pot usar la sintaxi següent per sobreescriure les decisions de tipografia. Les unitats de mesura que s’usen aquí són espais de pentagrama.

\relative c' <<
  {
    <d g>2 <d g>
  }
  \\
  {
    <b f'>2
    \once \override NoteColumn.force-hshift = 1.7
    <b f'>2
  }
>>

[image of music]


Diagrames de posicions d’acord, explicats i desenvolupats

Aquest fragment de codi presenta moltes possibilitat per obtenir diagrames de posicions d’acord i com ajustar-los.

<<
  \chords {
    a1 a \bar "||" \break
    \repeat unfold 3 {
      c c c d d \bar "||" \break
    }
  }

  \new Voice {
    % Set global properties of fret diagram
    \override TextScript.size = 1.2
    \override TextScript.fret-diagram-details
                .finger-code = #'below-string
    \override TextScript.fret-diagram-details
                .dot-color = #'black

    % 1
    %
    % A chord for ukulele.
    a'1^\markup
      \override #'(fret-diagram-details
                   . ((string-count . 4)
                      (dot-color . white)
                      (finger-code . in-dot)))
      \fret-diagram "4-2-2;3-1-1;2-o;1-o;"

    % 2
    %
    % A chord for ukulele, with formatting defined in definition
    % string: 1.2 * size, 4 strings, 4 frets, fingerings below,
    % string dot radius .35 of fret spacing, dot position 0.55 of
    % fret spacing.
    a'1^\markup
      \override #'(fret-diagram-details
                   . ((dot-color . white)
                      (open-string . "o")))
      \fret-diagram
        "s:1.2;w:4;h:3;f:2;d:0.35;p:0.55;4-2-2;3-1-1;2-o;1-o;"


    %%
    %% These chords will be in normal orientation
    %%


    % 3
    %
    % C major for guitar, barred on third fret: verbose style,
    % roman fret label, finger labels below string, straight barre.
    c'1^\markup
      % 110% of default size
      \override #'(size . 1.1)
      \override #'(fret-diagram-details
                   . ((number-type . roman-lower)
                      (finger-code . below-string)
                      (barre-type . straight)))
      \fret-diagram-verbose #'((mute 6)
                               (place-fret 5 3 1)
                               (place-fret 4 5 2)
                               (place-fret 3 5 3)
                               (place-fret 2 5 4)
                               (place-fret 1 3 1)
                               (barre 5 1 3))

    % 4
    %
    % C major for guitar, barred on third fret: double barre used
    % to test barre function, verbose style.
    c'1^\markup
      % 110% of default size
      \override #'(size . 1.1)
      \override #'(fret-diagram-details
                   . ((number-type . arabic)
                      (dot-label-font-mag . 0.9)
                      (finger-code . in-dot)
                      (fret-label-font-mag . 0.6)
                      (fret-label-vertical-offset . 0)
                      (label-dir . -1)
                      (mute-string . "M")
                      (xo-font-magnification . 0.4)
                      (xo-padding . 0.3)))
      \fret-diagram-verbose #'((mute 6)
                               (place-fret 5 3 1)
                               (place-fret 4 5 2)
                               (place-fret 3 5 3)
                               (place-fret 2 5 4)
                               (place-fret 1 3 1)
                               (barre 4 2 5)
                               (barre 5 1 3))

    % 5
    %
    % C major for guitar, with capo on third fret: verbose style.
    c'1^\markup
      % 110% of default size
      \override #'(size . 1.1)
      \override #'(fret-diagram-details
                   . ((number-type . roman-upper)
                      (dot-label-font-mag . 0.9)
                      (finger-code . none)
                      (fret-label-vertical-offset . 0.5)
                      (xo-font-magnification . 0.4)
                      (xo-padding . 0.3)))
      \fret-diagram-verbose #'((mute 6)
                               (capo 3)
                               (open 5)
                               (place-fret 4 5 1)
                               (place-fret 3 5 2)
                               (place-fret 2 5 3)
                               (open 1))

    % 6
    %
    % Simple D chord.
    d'1^\markup
      \override #'(fret-diagram-details
                   . ((finger-code . below-string)
                      (dot-radius . 0.35)
                      (string-thickness-factor . 0.3)
                      (dot-position . 0.5)
                      (fret-count . 3)))
      \fret-diagram-terse "x;x;o;2-1;3-2;2-3;"

    % 7
    %
    % Simple D chord, large top fret thickness.
    d'1^\markup
      \override #'(fret-diagram-details
                   . ((finger-code . below-string)
                      (dot-radius . 0.35)
                      (dot-position . 0.5)
                      (top-fret-thickness . 7)
                      (fret-count . 3)))
      \fret-diagram-terse "x;x;o;2-1;3-2;2-3;"


    %%
    %% These chords will be in landscape orientation
    %%
    \override TextScript.fret-diagram-details
                .orientation = #'landscape


    % 8
    %
    % C major for guitar, barred on third fret: verbose style,
    % roman fret label, finger labels below string, straight
    % barre.
    c'1^\markup
      % 110% of default size
      \override #'(size . 1.1)
      \override #'(fret-diagram-details
                   . ((number-type . roman-lower)
                      (finger-code . below-string)
                      (barre-type . straight)))
      \fret-diagram-verbose #'((mute 6)
                               (place-fret 5 3 1)
                               (place-fret 4 5 2)
                               (place-fret 3 5 3)
                               (place-fret 2 5 4)
                               (place-fret 1 3 1)
                               (barre 5 1 3))

    % 9
    %
    % C major for guitar, barred on third fret: Double barre
    % used to test barre function, verbose style.
    c'1^\markup
      % 110% of default size
      \override #'(size . 1.1)
      \override #'(fret-diagram-details
                   . ((number-type . arabic)
                      (dot-label-font-mag . 0.9)
                      (finger-code . in-dot)
                      (fret-label-font-mag . 0.6)
                      (fret-label-vertical-offset . 0)
                      (label-dir . -1)
                      (mute-string . "M")
                      (xo-font-magnification . 0.4)
                      (xo-padding . 0.3)))
      \fret-diagram-verbose #'((mute 6)
                               (place-fret 5 3 1)
                               (place-fret 4 5 2)
                               (place-fret 3 5 3)
                               (place-fret 2 5 4)
                               (place-fret 1 3 1)
                               (barre 4 2 5)
                               (barre 5 1 3))

    % 10
    %
    % C major for guitar, with capo on third fret: verbose style.
    c'1^\markup
      % 110% of default size
      \override #'(size . 1.1)
      \override #'(fret-diagram-details
                   . ((number-type . roman-upper)
                      (dot-label-font-mag . 0.9)
                      (finger-code . none)
                      (fret-label-vertical-offset . 0.5)
                      (xo-font-magnification . 0.4)
                      (xo-padding . 0.3)))
      \fret-diagram-verbose #'((mute 6)
                               (capo 3)
                               (open 5)
                               (place-fret 4 5 1)
                               (place-fret 3 5 2)
                               (place-fret 2 5 3)
                               (open 1))

    % 11
    %
    % Simple D chord.
    d'1^\markup
      \override #'(fret-diagram-details
                   . ((finger-code . below-string)
                      (dot-radius . 0.35)
                      (dot-position . 0.5)
                      (fret-count . 3)))
      \fret-diagram-terse "x;x;o;2-1;3-2;2-3;"

    % 12
    %
    % Simple D chord, large top fret thickness.
    d'1^\markup
      \override #'(fret-diagram-details
                   . ((finger-code . below-string)
                      (dot-radius . 0.35)
                      (dot-position . 0.5)
                      (top-fret-thickness . 7)
                      (fret-count . 3)))
      \fret-diagram-terse "x;x;o;2-1;3-2;2-3;"


    %%
    %% These chords will be in opposing-landscape orientation.
    %%
    \override TextScript.fret-diagram-details
                .orientation = #'opposing-landscape


    % 13
    %
    % C major for guitar, barred on third fret: verbose style,
    % roman fret label, finger labels below string, straight
    % barre.
    c'1^\markup
      % 110% of default size
      \override #'(size . 1.1)
      \override #'(fret-diagram-details
                   . ((number-type . roman-lower)
                      (finger-code . below-string)
                      (barre-type . straight)))
      \fret-diagram-verbose #'((mute 6)
                               (place-fret 5 3 1)
                               (place-fret 4 5 2)
                               (place-fret 3 5 3)
                               (place-fret 2 5 4)
                               (place-fret 1 3 1)
                               (barre 5 1 3))

    % 14
    %
    % C major for guitar, barred on third fret: double barre
    % used to test barre function, verbose style.
    c'1^\markup
      % 110% of default size
      \override #'(size . 1.1)
      \override #'(fret-diagram-details
                   . ((number-type . arabic)
                      (dot-label-font-mag . 0.9)
                      (finger-code . in-dot)
                      (fret-label-font-mag . 0.6)
                      (fret-label-vertical-offset . 0)
                      (label-dir . -1)
                      (mute-string . "M")
                      (xo-font-magnification . 0.4)
                      (xo-padding . 0.3)))
      \fret-diagram-verbose #'((mute 6)
                               (place-fret 5 3 1)
                               (place-fret 4 5 2)
                               (place-fret 3 5 3)
                               (place-fret 2 5 4)
                               (place-fret 1 3 1)
                               (barre 4 2 5)
                               (barre 5 1 3))

    % 15
    %
    % C major for guitar, with capo on third fret: verbose style.
    c'1^\markup
      % 110% of default size
      \override #'(size . 1.1)
      \override #'(fret-diagram-details
                   . ((number-type . roman-upper)
                      (dot-label-font-mag . 0.9)
                      (finger-code . none)
                      (fret-label-vertical-offset . 0.5)
                      (xo-font-magnification . 0.4)
                      (xo-padding . 0.3)))
      \fret-diagram-verbose #'((mute 6)
                               (capo 3)
                               (open 5)
                               (place-fret 4 5 1)
                               (place-fret 3 5 2)
                               (place-fret 2 5 3)
                               (open 1))

    % 16
    %
    % Simple D chord.
    d'1^\markup
      \override #'(fret-diagram-details
                   . ((finger-code . below-string)
                      (dot-radius . 0.35)
                      (dot-position . 0.5)
                      (fret-count . 3)))
      \fret-diagram-terse "x;x;o;2-1;3-2;2-3;"

    % 17
    %
    % Simple D chord, large top fret thickness.
    d'1^\markup
      \override #'(fret-diagram-details
                   . ((finger-code . below-string)
                      (dot-radius . 0.35)
                      (dot-position . 0.5)
                      (top-fret-thickness . 7)
                      (fret-count . 3)))
      \fret-diagram-terse "x;x;o;2-1;3-2;2-3;"
  }
>>


\paper {
  tagline = ##f
  ragged-right = ##t
  indent = 0
  system-system-spacing.basic-distance = 20
}

\layout {
  \context {
    \Score
    \override SpacingSpanner.spacing-increment = 3
  }
}

[image of music]


Generar claudàtors personalitzats

La propietat stencil del grob Flag (l’objecte gràfic claudàtor) es pot fixar a un funció de l’Scheme personalitzat que genera el glif del claudàtor.

#(define-public (weight-flag grob)
   (let* ((stem-grob (ly:grob-parent grob X))
          (log (- (ly:grob-property stem-grob 'duration-log) 2))
          (is-up? (eqv? (ly:grob-property stem-grob 'direction) UP))
          (yext (if is-up? (cons (* log -0.8) 0) (cons 0 (* log 0.8))))
          (flag-stencil (make-filled-box-stencil '(-0.4 . 0.4) yext))
          (stroke-style (ly:grob-property grob 'stroke-style))
          (stroke-stencil (if (equal? stroke-style "grace")
                              (make-line-stencil 0.2 -0.9 -0.4 0.9 -0.4)
                              empty-stencil)))
     (ly:stencil-add flag-stencil stroke-stencil)))


% Create a flag stencil by looking up the glyph from the font
#(define (inverted-flag grob)
   (let* ((stem-grob (ly:grob-parent grob X))
          (dir (if (eqv? (ly:grob-property stem-grob 'direction) UP) "d" "u"))
          (flag (retrieve-glyph-flag "" dir "" grob))
          (line-thickness (ly:staff-symbol-line-thickness grob))
          (stem-thickness (ly:grob-property stem-grob 'thickness))
          (stem-width (* line-thickness stem-thickness))
          (stroke-style (ly:grob-property grob 'stroke-style))
          (stencil (if (null? stroke-style)
                       flag
                       (add-stroke-glyph flag stem-grob dir stroke-style "")))
          (rotated-flag (ly:stencil-rotate-absolute stencil 180 0 0)))
     (ly:stencil-translate rotated-flag (cons (- (/ stem-width 2)) 0))))

snippetexamplenotes =
{
  \autoBeamOff c'8 d'16 c'32 d'64 \acciaccatura {c'8} d'64
}

{
  \time 1/4
  \textMark "Normal flags"
  \snippetexamplenotes

  \textMark "Custom flag: inverted"
  \override Flag.stencil = #inverted-flag
  \snippetexamplenotes

  \textMark "Custom flag: weight"
  \override Flag.stencil = #weight-flag
  \snippetexamplenotes

  \textMark "Revert to normal"
  \revert Flag.stencil
  \snippetexamplenotes
}

[image of music]


Glissando per sota d’una objecte gràfic

Els objectes gràfics de columna de nota (els grobs NoteColumn) poder ser sobrepassats pels glissandos.

\relative c' {
  a2 \glissando
  \once \override NoteColumn.glissando-skip = ##t
  f''4 d,
}

[image of music]


Reguladors amb diferents estils de línia

Els reguladors poden imprimir-se en qualsevol dels estils de line-interface: discontinu, puntejat, línia, tri o zig-zag.

\relative c' {
  c2\< c\!
  \override Hairpin.style = #'dashed-line
  c2\< c\!
  \override Hairpin.style = #'dotted-line
  c2\< c\!
  \override Hairpin.style = #'line
  c2\< c\!
  \override Hairpin.style = #'trill
  c2\< c\!
  \override Hairpin.style = #'zigzag
  c2\< c\!
  \revert Hairpin.style
  c2\< c\!
}

[image of music]


Alinear horitzontalment indicacions dinàmiques personalitzades (per exemple "sempre pp""piu f""subito p")

Algunes expressions de matís dinàmic porten text addicional, com "sempre pp". Considerant que els matisos solen anar centrats sota la nota, el \p s’imprimiria molt després de la nota a la qual s’aplica el matís.

Per alinear correctament el "sempre pp" en sentit horitzontal, de manera que s’alineï com si estigués solament el \pp, hi h a diversos enfocaments:

* Senzillament usar \once\override DynamicText.X-offset = #-9.2 abans de la nota que porta el matís, per desplaçar-lo manualment a la posició correcta. Inconvenient: cal fer-ho manualment cada cop que usem aquesta indicació dinàmica.

* Afegir una mica de farciment (#:hspace 7.1) dins de la definició de la nostra indicació dinàmica personalitzada, de forma que després que el LilyPond l’hagi centrat, ja estigui alineada correctament. Inconvenient: el farciment realment ocupa aquest espai i no permet que es gravi cap altre element de marcatge o matís dinàmic en aquesta posició.

* Desplaçar la inscripció dinàmica \once\override ... .X-offset = ... Inconvenient: ¡cal \once\override per a cada una de les invocacions!

* Fixar les dimensions del text addicional a zero (usant #:with-dimensions '(0 . 0) '(0 . 0)). Inconvenient: per al LilyPond "sempre" no té dimensions, per la qual cosa podria gravar altres elements en el seu mateix lloc i produir col·lisions (que no serien advertides pel mecanisme de detecció de col·lisions). Així mateix, aparentment hi ha algun espai, i per tant no és exactament la mateixa alineació que sense el text addicional.

* Afegir un desplaçament explicit directament dins de la funció de l’Scheme que produeix l’element dynamic-script.

* Fixar una alineació explícita dins del dynamic-script. De forma predeterminada, això no tindria cap efecte, a no ser que fixéssim un valor per a X-offset. Inconvenient: hem de donar un valor a DynamicText.X-offset que s’aplicaria a tots els textos de dinàmica. A més a més, s’alinea amb l’extrem dret del text addicional, no amb el centre del pp.

\paper {
  ragged-right = ##f
  indent = 2.5\cm
  tagline = ##f
}

% Solution 1: Using a simple markup with a particular halign value
% Drawback: It's a markup, not a dynamic command, so \dynamicDown
%           etc. will have no effect
semppMarkup = \markup { \halign #1.4 \italic "sempre" \dynamic "pp" }

% Solution 2: Using a dynamic script & shifting with
%             \once \override ...X-offset = ..
% Drawback: \once \override needed for every invocation
semppK =
#(make-dynamic-script
  (markup #:line
          (#:normal-text
           #:italic "sempre"
           #:dynamic "pp")))

% Solution 3: Padding the dynamic script so the center-alignment
%             puts it at the correct position
% Drawback: the padding really reserves the space, nothing else can be there
semppT =
#(make-dynamic-script
  (markup #:line
          (#:normal-text
           #:italic "sempre"
           #:dynamic "pp"
           #:hspace 7.1)))

% Solution 4: Dynamic, setting the dimensions of the additional text to 0
% Drawback: To lilypond "sempre" has no extent, so it might put
%           other stuff there => collisions
% Drawback: Also, there seems to be some spacing, so it's not exactly the
%           same alignment as without the additional text
semppM =
#(make-dynamic-script
  (markup #:line
          (#:with-dimensions '(0 . 0) '(0 . 0)
                             #:right-align
                             #:normal-text
                             #:italic "sempre"
                             #:dynamic "pp")))

% Solution 5: Dynamic with explicit shifting inside the scheme function
semppG =
#(make-dynamic-script
  (markup #:hspace 0
          #:translate '(-18.85 . 0)
          #:line (#:normal-text
                  #:italic "sempre"
                  #:dynamic "pp")))

% Solution 6: Dynamic with explicit alignment. This has only effect
%             if one sets X-offset!
% Drawback: One needs to set DynamicText.X-offset!
% Drawback: Aligned at the right edge of the additional text,
%           not at the center of pp
semppMII =
#(make-dynamic-script
  (markup #:line (#:right-align
                  #:normal-text
                  #:italic "sempre"
                  #:dynamic "pp")))

\new StaffGroup <<
  \new Staff = "s" \with { instrumentName = \markup \column { Normal } }
  <<
    \relative c'' {
      \key es \major
      c4\pp c\p c c | c\ff c c\pp c
    }
  >>
  \new Staff = "sMarkup" \with {
    instrumentName = \markup \column { Normal markup }
  }
  <<
    \relative c'' {
      \key es \major
      c4-\semppMarkup c\p c c | c\ff c c-\semppMarkup c
    }
  >>
  \new Staff = "sK" \with {
    instrumentName = \markup \column { Explicit shifting }
  }
  <<
    \relative c'' {
      \key es \major
      \once \override DynamicText.X-offset = #-9.2
      c4\semppK c\p c c
      c4\ff c
      \once \override DynamicText.X-offset = #-9.2
      c4\semppK c
    }
  >>
  \new Staff = "sT" \with {
    instrumentName = \markup \column { Right padding }
  }
  <<
    \relative c'' {
      \key es \major
      c4\semppT c\p c c | c\ff c c\semppT c
    }
  >>
  \new Staff = "sM" \with {
    instrumentName = \markup \column { Set dimension "to zero" }
  }
  <<
    \relative c'' {
      \key es \major
      c4\semppM c\p c c | c\ff c c\semppM c
    }
  >>
  \new Staff = "sG" \with {
    instrumentName = \markup \column { Shift inside dynamics}
  }
  <<
    \relative c'' {
      \key es \major
      c4\semppG c\p c c | c\ff c c\semppG c
    }
  >>
  \new Staff = "sMII" \with {
    instrumentName = \markup \column { Alignment inside dynamics }
  }
  <<
    \relative c'' {
      \key es \major
      % Setting to ##f (false) gives the same result
      \override DynamicText.X-offset = #0
      c4\semppMII c\p c c | c\ff c c\semppMII c
    }
  >>
>>

\layout { \override Staff.InstrumentName.self-alignment-X = #LEFT }

[image of music]


Com canviar la posició d’un diagrama de posicions

Si volem moure un diagrama de posicions d’acord, per exemple, per evitar una col·lisió, o situar-lo entre dues notes, tenim diverses possibilitats:

1) modificar els valors de farciment #’padding o del desplaçament addicional #’extra-offset (como es mostra en el primer exemple)

2) podem afegir una veu invisible i adjuntar els diagrames de posicions a les notes invisibles d’aquesta veu (com es veu en el segon exemple).

Si hem de moure el diagrama segons una posició rítmica dins del compàs (a l’exemple, la tercera part del compàs) és millor el segon exemple, perquè el diagrama s’alinea amb la tercera pulsació per si sol

\header { tagline = ##f }

harmonies = \chordmode
{
  a8:13
% THE FOLLOWING IS THE COMMAND TO MOVE THE CHORD NAME
  \once \override ChordNames.ChordName.extra-offset = #'(10 . 0)
  b8:13 s2.
% THIS LINE IS THE SECOND METHOD
    s4 s4  b4:13
}

\score
{
  <<
    \new ChordNames \harmonies
    \new Staff
    {a8^\markup { \fret-diagram  "6-x;5-0;4-2;3-0;2-0;1-2;"  }
% THE FOLLOWING IS THE COMMAND TO MOVE THE FRET DIAGRAM
     \once \override TextScript.extra-offset = #'(10 . 0)
     b4.~^\markup { \fret-diagram  "6-x;5-2;4-4;3-2;2-2;1-4;"  } b4. a8\break
% HERE IS THE SECOND METHOD
     <<
       { a8 b4.~ b4. a8}
       { s4 s4 s4^\markup { \fret-diagram  "6-x;5-2;4-4;3-2;2-2;1-4;"  }
       }
     >>
   }
  >>
}

[image of music]


Inserir una cesura

Les marques de cesura es poden crear sobreescrivint la propietat 'text de l’objecte BreathingSign. També està disponible una marca de cesura corba.

\relative c'' {
  \override BreathingSign.text = \markup {
    \musicglyph "scripts.caesura.straight"
  }
  c8 e4. \breathe g8. e16 c4

  \override BreathingSign.text = \markup {
    \musicglyph "scripts.caesura.curved"
  }
  g8 e'4. \breathe g8. e16 c4
}

[image of music]


Mantenir la mida del símbol en els canvis de clau

Quan es produeix un canvi de clau, el símbol de clau s’imprimeix a una mida més petita que la clau inicial. Això es pot ajustar amb full-size-change.

\relative c' {
  \clef "treble"
  c1
  \clef "bass"
  c1
  \clef "treble"
  c1
  \override Staff.Clef.full-size-change = ##t
  \clef "bass"
  c1
  \clef "treble"
  c1
  \revert Staff.Clef.full-size-change
  \clef "bass"
  c1
  \clef "treble"
  c1
}

[image of music]


Puntes de fletxa per a les línies

Es poden aplicar puntes de fletxa als elements d’extensió de text i de línia (com el Glissando).

\relative c'' {
  \override TextSpanner.bound-padding = #1.0
  \override TextSpanner.style = #'line
  \override TextSpanner.bound-details.right.arrow = ##t
  \override TextSpanner.bound-details.left.text = #"fof"
  \override TextSpanner.bound-details.right.text = #"gag"
  \override TextSpanner.bound-details.right.padding = #0.6

  \override TextSpanner.bound-details.right.stencil-align-dir-y = #CENTER
  \override TextSpanner.bound-details.left.stencil-align-dir-y = #CENTER

  \override Glissando.bound-details.right.arrow = ##t
  \override Glissando.arrow-length = #0.5
  \override Glissando.arrow-width = #0.25

  a8\startTextSpan gis a4 b\glissando b,
  g'4 c\stopTextSpan c2
}

[image of music]


Fer invisible un objecte amb la propietat ’transparent

Si s’ajusta la propietat transparent d’un objecte, s’imprimeix en “tinta invisible”: l’objecte no s’imprimeix però es retenen tots els seus altres comportaments. L’objecte encara ocupa espai, participa en les col·lisions i se li poden afegir lligadures d’expressió, lligadures d’unió i barres de corxera.

Aquest fragment de codi mostra com connectar diferents veus usant lligadures d’únió. Normalment les lligadures d’unió sols connecten dues notes que estiguin a la mateixa veu. Mitjançant la introducció d’una lligadura en una veu diferent i pintant de color blanc la primera plica cap a amunt dins d’aquesta veu, la lligadura sembla creuar d’una veu a l’altra.

\relative {
  \time 2/4
  <<
    {
      \once \hide Stem
      \once \override Stem.length = #8
      b'8 ~ 8\noBeam
      \once \hide Stem
      \once \override Stem.length = #8
      g8 ~ 8\noBeam
    }
    \\
    {
      b8 g g e
    }
  >>
}

[image of music]


Making glissandi breakable

Si s’ajusta la propietat breakable al valor #t en combinació amb after-line-breaking, podem fer que un glissando es divideixi en el salt de línia:

\paper { tagline = ##f }

glissandoSkipOn = {
  \override NoteColumn.glissando-skip = ##t
  \hide NoteHead
  \override NoteHead.no-ledgers = ##t
}

\relative c'' {
  \override Glissando.breakable = ##t
  \override Glissando.after-line-breaking = ##t
  f1\glissando |
  \break
  a4 r2. |
  f1\glissando
  \once \glissandoSkipOn
  \break
  a2 a4 r4 |
}

[image of music]


Control manual de les posicions de les barres

Es poden controlar manualment les posicions de les barres de corxera sobreescrivint el valor del paràmetre positions de l’objecte gràfic Beam.

\relative c' {
  \time 2/4
  % from upper staff-line (position 2) to center (position 0)
  \override Beam.positions = #'(2 . 0)
  c8 c
  % from center to one above center (position 1)
  \override Beam.positions = #'(0 . 1)
  c8 c
}

[image of music]


Measure-centered bar numbers

For film scores, a common convention is to center bar numbers within their measure. This is achieved through setting the centerBarNumbers context property to true. When this is used, the type of the bar number grobs is CenteredBarNumber rather than BarNumber.

This example demonstrates a number of settings: the centered bar numbers are boxed and placed below the staves.

\layout {
  \context {
    \Score
    centerBarNumbers = ##t
    barNumberVisibility = #all-bar-numbers-visible
    \override CenteredBarNumber.stencil
      = #(make-stencil-boxer 0.1 0.25 ly:text-interface::print)
    \override CenteredBarNumberLineSpanner.direction = #DOWN
  }
}

\new StaffGroup <<
  \new Staff \relative c' {
    d4-. f8( e d4) bes'-> |
    d,-. f8( e d4) cis'-> |
    g-. f8( d e4) g-> |
    a,1-> |
  }
  \new Staff \relative c {
    \clef bass
    d4 f8 e d2~ |
    4 f8 e d2~ |
    4 4 2 |
    a1 |
  }
>>

[image of music]


Disposició Mensurstriche (línies divisòries entre pentagrames)

La disposició «mensurstriche» en els quals les línies divisòries no estan dibuixades sobre els pentagrames, sinó entre ells, es pot aconseguir amb un StaffGroup en comptes d’un ChoirStaff. La línia divisòria sobre els pentagrames s’esborra usant \hide.

\layout {
  \context {
    \Staff
    measureBarType = "-span|"
  }
}

music = \fixed c'' {
  c1
  d2 \section e2
  f1 \fine
}

\new StaffGroup <<
  \new Staff \music
  \new Staff \music
>>

[image of music]


Modifying the Ottava spanner slope

It is possible to change the slope of the Ottava spanner.

\relative c'' {
  \override Staff.OttavaBracket.stencil = #ly:line-spanner::print
  \override Staff.OttavaBracket.bound-details =
    #`((left . ((Y . 0)
                (attach-dir . ,LEFT)
                (padding . 0)
                (stencil-align-dir-y . ,CENTER)))
       (right . ((Y . 5.0) ; Change the number here
                 (padding . 0)
                 (attach-dir . ,RIGHT)
                 (text . ,(make-draw-dashed-line-markup
                           (cons 0 -1.2))))))
  \override Staff.OttavaBracket.left-bound-info =
     #ly:horizontal-line-spanner::calc-left-bound-info-and-text
  \override Staff.OttavaBracket.right-bound-info =
     #ly:horizontal-line-spanner::calc-right-bound-info
  \ottava 1
  c1
  c'''1
}

[image of music]


Desplaçament de les notes amb puntet en polifonia

Quan una nota amb puntet a la veu superior es mou per evitar la col·lisió amb una nota de una altra veu, el comportament predeterminat és desplaçar la nota superior a la dreta. Es pot canviar usant la propietat prefer-dotted-right de NoteCollision.

\new Staff \relative c' <<
  {
    f2. f4
    \override Staff.NoteCollision.prefer-dotted-right = ##f
    f2. f4
    \override Staff.NoteCollision.prefer-dotted-right = ##t
    f2. f4
  }
  \\
  { e4 e e e e e e e e e e e }
>>

[image of music]


Desplaçament de les lligadures d’expressió verticalment

Es pot ajustar la posició vertical d’una lligadura d’expressió utilitzant la propietat positions de l’objecte Slur. La propietat de dos paràmetres, on el primer es refereix a l’extrem esquerre de la lligadura i el segon al dret. Els valors dels paràmetres no s’utilitzen per part del LilyPond per produir un desplaçament exacte de la lligadura: més bé selecciona la col·locació que té un aspecte millor, tenint en compte els valors dels paràmetres. Els valors positius desplacen la lligadura cap amunt, i són adequats a notes que tenen les pliques cap avall. Els valors negatius desplacen les lligadures baixes encara més cap avall.

\relative c' {
  \stemDown
  e4( a)
  \override Slur.positions = #'(1 . 1)
  e4( a)
  \override Slur.positions = #'(2 . 2)
  e4( a)
  \override Slur.positions = #'(3 . 3)
  e4( a)
  \override Slur.positions = #'(4 . 4)
  e4( a)
  \override Slur.positions = #'(5 . 5)
  e4( a)
  \override Slur.positions = #'(0 . 5)
  e4( a)
  \override Slur.positions = #'(5 . 0)
  e4( a)
  \stemUp
  \override Slur.positions = #'(-5 . -5)
  e4( a)
  \stemDown
  \revert Slur.positions
  e4( a)
}

[image of music]


Niuat de grups de pentagrames

Es pot utilitzar la propietat systemStartDelimiterHierarchy per crear grups de pentagrames niuats de forma més complexa. L’ordre \set StaffGroup.systemStartDelimiterHierarchy pren una llista alfabètic del nombre de pentagrames produïts. Es pot proporcionar abans de cada pentagrama un delimitador de començament del sistema. Es pot envoltar entre corxets i admetre tants pentagrames com envoltin els corxets. Es poden ometre els elements de la llista, però el primer corxet sempre abasta tots els pentagrames. Les possibilitat són SystemStartBar, SystemStartBracket, SystemStartBrace SystemStartSquare.

\new StaffGroup
\relative c'' <<
  \override StaffGroup.SystemStartSquare.collapse-height = 4
  \set StaffGroup.systemStartDelimiterHierarchy
    = #'(SystemStartSquare (SystemStartBrace (SystemStartBracket a
                             (SystemStartSquare b)  ) c ) d)
  \new Staff { c1 }
  \new Staff { c1 }
  \new Staff { c1 }
  \new Staff { c1 }
  \new Staff { c1 }
>>

[image of music]


Modificació d’articulacions de diversos tipus

A vegades volem modificar un sol temps d’articulació. Tot i que sempre és possible usar l’ordre \tweak, podria fer-se tediós fer-lo per a tots i cada un dels símbols d’una partitura completa. L’exemple mostra com ajustar articulacions amb una llista d’ajustaments personalitzats. Un cas seria la creació d’un full d’estils.

Amb 2.16.2 és possible introduir la funció proposada, \customScripts, en un bloc \layout.

% Code by David Nalesnik and Thomas Morley

#(define (custom-script-tweaks ls)
  (lambda (grob)
    (let* ((type (ly:event-property
                    (ly:grob-property grob 'cause)
                    'articulation-type))
           (tweaks (assoc-ref ls type)))
      (if tweaks
          (for-each
            (lambda (x) (ly:grob-set-property! grob (car x) (cdr x)))
            tweaks)))))

customScripts =
#(define-music-function (settings) (list?)
#{
  \override Script.before-line-breaking =
    #(custom-script-tweaks settings)
#})

revertCustomScripts = \revert Script.before-line-breaking

%%%%%%%%%%%%%
% Example:
%%%%%%%%%%%%%

% Predefine a list of desired tweaks.
#(define my-settings-1
  '(
    (staccato . ((color . (1 0 0))
                 (padding . 0.5)))
    (accent . ((font-size . 0)
               (color . (1 0 0))))
    (tenuto . ((rotation . (45 0 0))
               (padding . 2)
               (font-size . 10)))
    (staccatissimo . ((padding . 1)
                      (color . (1 0 0))))
    (segno . ((font-size . 0)
              (color . (1 0 0))))
    ))

#(define my-settings-2
  '(
    (staccato . ((color . (0 1 0))))
    (accent . ((font-size . 4)
               (color . (0 1 0))
               (padding . 1.5)))
    (tenuto . ((font-size . 10)))
    (staccatissimo . ((padding . 2)
                      (color . (0 1 0))))
    (coda . ((color . (0 1 0))
             (padding . 1)))
    ))

one =
\relative c'' {
  f1--
  \customScripts #my-settings-1
  f-. f-! f-> f-- f-!\segno
  \revertCustomScripts
  f-> f-.
}

two =
\relative c' {
  f1--
  \customScripts #my-settings-2
  f-. f-! f-> f---> f-!
  f-> f-.\coda
}

\new Staff
  <<
    \new Voice { \voiceOne \one }
    \new Voice { \voiceTwo \two }
  >>

[image of music]


Overriding articulations of distinct type

Sometimes you may want to affect a single articulation type. Although it is always possible to use \tweak, it might become tedious to do so for every single sign of a whole score. The following shows how to tweak articulations with a list of custom settings. One use case might be to create a style sheet.

With 2.16.2 it is possible to put the proposed function, \customScripts, into a \layout block.

% Code by David Nalesnik and Thomas Morley

#(define (custom-script-tweaks ls)
  (lambda (grob)
    (let* ((type (ly:prob-property
                    (ly:grob-property grob 'cause)
                    'articulation-type))
           (tweaks (assoc-ref ls type)))
      (if tweaks
          (for-each
            (lambda (x) (ly:grob-set-property! grob (car x) (cdr x)))
            tweaks)))))

customScripts =
#(define-music-function (settings)(list?)
#{
  \override Script.before-line-breaking =
    #(custom-script-tweaks settings)
#})

revertCustomScripts = { \revert Script.before-line-breaking }

%%%%%%%%%%%%%
% Example:
%%%%%%%%%%%%%

% Predefine a list of desired tweaks.
#(define my-settings-1
  '(
    ("staccato" . ((color . (1 0 0))(padding . 0.5)))
    ("accent" . ((font-size . 0)(color . (1 0 0))))
    ("tenuto" . ((rotation . (45 0 0)) (padding . 2)(font-size . 10)))
    ("staccatissimo" . ((padding . 1) (color . (1 0 0))))
    ("segno" . ((font-size . 0)(color . (1 0 0))))
    ))

#(define my-settings-2
  '(
    ("staccato" . ((color . (0 1 0))))
    ("accent" . ((font-size . 4)(color . (0 1 0))(padding . 1.5)))
    ("tenuto" . ((font-size . 10)))
    ("staccatissimo" . ((padding . 2) (color . (0 1 0))))
    ("coda" . ((color . (0 1 0)) (padding . 1)))
    ))

one =
\relative c'' {
  f1--
  \customScripts #my-settings-1
  f-. f-! f-> f-- f-!\segno
  \revertCustomScripts
  f-> f-.
}

two =
\relative c' {
  f1--
  \customScripts #my-settings-2
  f-. f-! f-> f---> f-!
  f-> f-.\coda
}

\new Staff <<
   \new Voice { \voiceOne \one }
   \new Voice { \voiceTwo \two }
   >>

[image of music]


Visibilitat del comptador de repeticions de tipus percentatge

Es poden mostrar els comptadors de les repeticions del tipus percentatge a intervals regulars mitjançant l’establiment de la propietat de context repeatCountVisibility.

\relative c'' {
  \set countPercentRepeats = ##t
  \set repeatCountVisibility = #(every-nth-repeat-count-visible 5)
  \repeat percent 10 { c1 } \break
  \set repeatCountVisibility = #(every-nth-repeat-count-visible 2)
  \repeat percent 6 { c1 d1 }
}

[image of music]


Posicionar símbols d’arpegi

Si cal fer més llargs o més curts un símbol d’arpegi, es pot modificar independentment els extrems superior i inferior.

\relative c' {
  <c e g b>1\arpeggio
  \once \override Arpeggio.positions = #'(-5 . 0)
  <c e g b>1\arpeggio
  \once \override Arpeggio.positions = #'(0 . 5)
  <c e g b>1\arpeggio
  \once \override Arpeggio.positions = #'(-5 . 5)
  <c e g b>1\arpeggio
}

[image of music]


Posicionar els silencis multicompàs

A diferència dels silencis normals, no existeix una ordre predefinida per modificar la posició predeterminada d’un símbol de silenci multicompàs sobre el pentagrama, adjuntant-lo a una nota, independentment de quin sigui la seva forma. No obstant, en la música polifònica els silencis multicompàs de les veus de numeració parell i imparell estan separats verticalment. La col·locació dels silencis multicompàs es pot controlar com es ve a continuació:

\relative c'' {
  % Multi-measure rests by default are set under the fourth line
  R1
  % They can be moved using an override
  \override MultiMeasureRest.staff-position = -2
  R1
  \override MultiMeasureRest.staff-position = 0
  R1
  \override MultiMeasureRest.staff-position = 2
  R1
  \override MultiMeasureRest.staff-position = 3
  R1
  \override MultiMeasureRest.staff-position = 6
  R1
  \revert MultiMeasureRest.staff-position
  \break

  % In two Voices, odd-numbered voices are under the top line
  << { R1 } \\ { a1 } >>
  % Even-numbered voices are under the bottom line
  << { a1 } \\ { R1 } >>
  % Multi-measure rests in both voices remain separate
  << { R1 } \\ { R1 } >>

  % Separating multi-measure rests in more than two voices
  % requires an override
  << { R1 } \\ { R1 } \\
     \once \override MultiMeasureRest.staff-position = 0
     { R1 }
  >>

  % Using compressed bars in multiple voices requires another override
  % in all voices to avoid multiple instances being printed
  \compressMMRests
  <<
   \revert MultiMeasureRest.direction
    { R1*3 }
    \\
   \revert MultiMeasureRest.direction
    { R1*3 }
  >>
}

[image of music]


Situar els elements de marcatge de text por dins de les lligadures

Els elements de marcatge de text han de tenir la propietat outside-staff-priority establerta al valor fals perquè s’imprimeixin per dins de les lligadures d’expressió.

\relative c'' {
  \override TextScript.avoid-slur = #'inside
  \override TextScript.outside-staff-priority = ##f
  c2(^\markup { \halign #-10 \natural } d4.) c8
}

[image of music]


Impressió de nombre de compàs dins de rectangles o circumferències

Els nombres de compàs també es poden imprimir dins de rectangles o de circumferències.

\relative c' {
  % Prevent bar numbers at the end of a line and permit them elsewhere
  \override Score.BarNumber.break-visibility = #end-of-line-invisible
  \set Score.barNumberVisibility = #(every-nth-bar-number-visible 4)

  % Increase the size of the bar number by 2
  \override Score.BarNumber.font-size = 2

  % Draw a box round the following bar number(s)
  \override Score.BarNumber.stencil
    = #(make-stencil-boxer 0.1 0.25 ly:text-interface::print)
  \repeat unfold 5 { c1 }

  % Draw a circle round the following bar number(s)
  \override Score.BarNumber.stencil
    = #(make-stencil-circler 0.1 0.25 ly:text-interface::print)
  \repeat unfold 4 { c1 } \bar "|."
}

[image of music]


Impressió d’indicacions de metrònom i lletres d’assaig a sota del pentagrama

De forma predeterminada, les indicacions de metrònom i les lletres d’assaig s’imprimeixen a sobre del pentagrama. Per col·locar-les a sota del pentagrama, simplement ajustem adequadament la propietat direction de MetronomeMark o de RehearsalMark.

\layout {
  indent = 0
  ragged-right = ##f
}

{
  % Metronome marks below the staff
  \override Score.MetronomeMark.direction = #DOWN
  \tempo 8. = 120
  c''1

  % Rehearsal marks below the staff
  \override Score.RehearsalMark.direction = #DOWN
  \mark \default
  c''1
}

[image of music]


Impressió dels noms de les notes amb o sense indicació de l’octava

Es pot usar el context NoteNames per imprimir el valor textual de les notes. La propietat printOctaveNames activa o desactiva la representació de l’octava de les notes.

scale = \relative c' {
  a4 b c d
  e4 f g a
}

\new Staff {
  <<
    \scale
    \context NoteNames {
      \set printOctaveNames = ##f
      \scale
    }
  >>
  R1
  <<
    \scale
    \context NoteNames {
      \set printOctaveNames = ##t
      \scale
    }
  >>
}

[image of music]


Printing tuplet brackets on the note head side

Whichever option you choose for controlling the tuplet bracket visibility, it will show or hide the tuplet bracket irrespectively of tuplet bracket placement (stem side or note head side). However, when placing the tuplet bracket on the note head side some authors recommend always printing the tuplet bracket. The option visible-over-note-heads can be used to achieve this.

music = \relative c'' {
  \tupletNeutral \tuplet 3/2 { c16[ d e } f8]
  \tupletUp \tuplet 3/2 { c8 d e }
}

\new Voice {
  \relative c' {
    \time 2/4
    \override TupletBracket.visible-over-note-heads = ##t
    \override Score.TextMark.non-musical = ##f
    { \textMark \markup "default" \music }
    \override TupletBracket.bracket-visibility = #'if-no-beam
    { \textMark \markup \typewriter "'if-no-beam" \music }
  }
}

[image of music]


Espaiat de les notes estrictament proporcional

Si s’ha establert strict-note-spacing, l’espaiat de les notes no es veu influït pels compassos o claus que pugui haver-hi dins d’un sistema. En comptes d’això, es col·loquen just abans de la nota que té lloc en el mateix moment temporal. Això pot produir col·lisions.

\relative c'' <<
  \override Score.SpacingSpanner.strict-note-spacing = ##t
  \set Score.proportionalNotationDuration = \musicLength 16
  \new Staff {
    c8[ c \clef alto c c \grace { d16 } c8 c] c4
    c2 \grace { c16[ c16] } c2
  }
  \new Staff {
    c2 \tuplet 3/2 { c8 \clef bass cis,, c } c4
    c1
  }
>>

[image of music]


Removing brace on first line of piano score

This snippet removes the first brace from a PianoStaff or a GrandStaff, together with the clefs.

It may be useful when cutting and pasting the engraved image into existing music.

It uses \alterBroken.

someMusic =  {
  \once \override Staff.Clef.stencil = ##f
  \once \override Staff.TimeSignature.stencil = ##f
  \repeat unfold 3 c1 \break
  \repeat unfold 5 c1 \break
  \repeat unfold 5 c1
}

\score {
  \new PianoStaff
  <<
    \new Staff = "right" \relative c'' \someMusic
    \new Staff = "left" \relative c' { \clef F \someMusic }
  >>
  \layout {
    indent=75
    \context {
      \PianoStaff
      \alterBroken transparent #'(#t) SystemStartBrace
    }
  }
}

\paper { tagline = ##f }

[image of music]


Treure les barres de compàs entre els pentagrames d’un StaffGroup PianoStaff o GrandStaff

De forma predeterminada, les línies divisòries als grups StaffGroup, PianoStaff o GrandStaff es connecten entre els pentagrames. Es pot alterar aquest comportament pentagrama a pentagrama.

\relative c' {
  \new StaffGroup <<
    \new Staff {
      e1 | e
      \once \override Staff.BarLine.allow-span-bar = ##f
      e1 | e | e
    }
    \new Staff {
      c1 | c | c
      \once \override Staff.BarLine.allow-span-bar = ##f
      c1 | c
    }
    \new Staff {
      a1 | a | a | a | a
    }
  >>
}

[image of music]


Supressió de la primera línia buida

El primer pentagrama buit també es pot suprimir de la partitura establint la propietat remove-first de VerticalAxisGroup. Això es pot fer globalment dins del bloc \layout, o localment dins del pentagrama concret que es vol suprimir. En aquest últim cas, hem d’especificar el contex (Staff s’aplica sols al pentagrama actual) davant de la propietat.

El pentagrama inferior del segon grup no s’elimina, perquè l’ajustament sols s’aplica al pentagraa concret dins del que s’escriu.

\layout {
  \context {
    \Staff \RemoveEmptyStaves
    % To use the setting globally, uncomment the following line:
    % \override VerticalAxisGroup.remove-first = ##t
  }
}
\new StaffGroup <<
  \new Staff \relative c' {
    e4 f g a \break
    c1
  }
  \new Staff {
    % To use the setting globally, comment this line,
    % uncomment the line in the \layout block above
    \override Staff.VerticalAxisGroup.remove-first = ##t
    R1 \break
    R
  }
>>
\new StaffGroup <<
  \new Staff \relative c' {
    e4 f g a \break
    c1
  }
  \new Staff {
    R1 \break
    R
  }
>>

\paper { tagline = ##f }

[image of music]


Estils de silencis

Els silencis es poden imprimir en diferents estils.

restsA = {
  r\maxima r\longa r\breve r1 r2 r4 r8 r16 s32
  s64 s128 s256 s512 s1024 s1024
}
restsB = {
  r\maxima r\longa r\breve r1 r2 r4 r8 r16 r32
  r64 r128 r256 r512 r1024 s1024
}

\new Staff \relative c {
  \omit Score.TimeSignature
  \cadenzaOn

  \override Staff.Rest.style = #'mensural
  <>^\markup \typewriter { mensural } \restsA \bar "" \break

  \override Staff.Rest.style = #'neomensural
  <>^\markup \typewriter { neomensural } \restsA \bar "" \break

  \override Staff.Rest.style = #'classical
  <>^\markup \typewriter { classical } \restsB \bar "" \break

  \override Staff.Rest.style = #'z
  <>^\markup \typewriter { z-style } \restsB \bar "" \break

  \override Staff.Rest.style = #'default
  <>^\markup \typewriter { default } \restsB \bar "" \break
}

\paper {
  indent = 0
  tagline = ##f
}

[image of music]


Barres rítmiques

Als fulls guia d’acords o fulls guia “senzilles”, a vegades no s’imprimeix realment cap nota, i en el seu lloc es fa una notació que té sols “patrons rítmics” i acords a sobre dels compassos, donant l’estructura de la cançó. Aquesta funcionalitat és útil, per exemple, en crear o transcriure l’estructura d’una cançó i també si es volen compartir els fulls guia amb guitarristes o músics de jazz. La forma estàndard en la qual hi ha suport per a aquesta modalitat usant \repeat percent no és adequada aquí perquè el primer compàs hauria de ser una nota o silenci normals. Aquest exemple mostra dues solucions al problema, redefinint els silencis normals perquè s’imprimeixin com a barres inclinades (si la duració de cada pols no és una negra, substituirem el r4 que apareix a les definicions amb un silenci de la duració adequada).

startPat = {
  \improvisationOn
  \omit Stem
}
stopPat = {
  \improvisationOff
  \undo \omit Stem
}

\new Voice \with {
  \consists Pitch_squash_engraver
} {
  c'4 d' e' f' |
  \startPat
  4 4 4 4 |
  \stopPat
  f'4 e' d' c'
}

[image of music]


Separar les cancel·lacions de tonalitat dels canvis d’armadura

De forma predeterminada, les alteracions accidentals que s’usen per a les cancel·lacions a les armadures es col·loquen adjacents a les que s’usen per als canvis de tonalitat. Aquest comportament es pot canviar sobreescrivint la propietat 'break-align-orders de l’objecte gràfic BreakAlignment.

El valor de 'break-align-orders és un vector de longitud 3, amb llistes entre cometes els elements de les quals són objectes que es poden dividir en un salt. Aquest exemple sols modifica la segona llista, movent key-cancellation abans de staff-bar; modificant la segona llista, el comportament d’alineació dels salts canvia en la meitat d’un sistema, no al principi ni al final.

#(define (insert-before where what lst)
   (cond
    ((null? lst)           ; If the list is empty,
     (list what))          ; return a single-element list.
    ((eq? where (car lst)) ; If we find symbol `where`,
     (cons what lst))      ; insert `what` before curr. position.
    (else                  ; Otherwise keep building the list by
     (cons (car lst)       ; adding the current element and
                           ; recursing with the next element.
           (insert-before where what (cdr lst))))))

cancellationFirst =
\override Score.BreakAlignment.break-align-orders =
#(grob-transformer
  'break-align-orders
  (lambda (grob orig)
    (let* ((middle (vector-ref orig 1))
           (middle (delq 'key-cancellation middle))
           (middle (insert-before
                    'staff-bar 'key-cancellation middle)))
      (vector
       ;; end of line
       (vector-ref orig 0)
       ;; middle of line
       middle
       ;; beginning of line
       (vector-ref orig 2)))))

music = { \key es \major d'1 \bar "||"
          \key a \major d'1 }

{ <>^\markup "default"
  \music }

{ <>^\markup "cancellation first"
  \cancellationFirst
  \music }

\paper { tagline = ##f }

[image of music]


Establir el comportament dels reguladors a les barres de compàs

Si la nota que acaba un regulador cau sobre la primera part d’un compàs, el regulador s’atura en la línia divisòria immediatament precedent. Es pot controlar aquest comportament sobreescrivint la propietat 'to-barline.

\relative c'' {
  e4\< e2.
  e1\!
  \override Hairpin.to-barline = ##f
  e4\< e2.
  e1\!
}

[image of music]


Fixació d’un separador entre els sistemes

Es poden inserir separadors de sistema entre els sistemes d’una pàgina. Es pot usar qualsevol element de marcatge, però hi ha \slashSeparator com una elecció predeterminada adequada.

\paper {
  system-separator-markup = \slashSeparator
  line-width = 120
  tagline = ##f
}

notes = \relative c' {
  c1 | c \break
  c1 | c \break
  c1 | c
}

\book {
  \score {
    \new GrandStaff <<
      \new Staff \notes
      \new Staff \notes
    >>
  }
}

[image of music]


Impressió de la mateixa articulació a sobre i a sota de la mateixa nota o acord

De forma predeterminada, el LilyPond no permet posar la mateixa articulació (per exemple un accent, un calderó, un cercle d’harmònic, etc.) a sobre i a sota de la nota. Per exemple, c4_\fermata^\fermata imprimeix sols el calderó inferior. El calderó superior senzillament s’ignora. No obstant, es poden adjuntar inscripcions (de igual forma que les digitacions) dins d’un acord, soca que significa que és possible tenir tantes articulacions com es vulgui. Aquest enfocament té l’avantatge que ignora la plica i posiciona l’articulació de forma relativa al cap de la nota. Pot veure’s això en el cas dels flageolets (indicacions d’harmònic)) que apareixen en el fragment de codi. Per recrear el comportament de les inscripcions fora de l’acord, es requereix ’add-stem-support. D’aquesta manera la solució consisteix en escriure la nota com un acord i afegir les articulacions dins dels parèntesis en angle <...>. La direcció sempre serà cap a dalt, però podem retocar això per mitjà d’una ordre \tweak: <c-\tweak direcció #DOWN-\fermata^\fermata>

\relative c' {
  <>^"Wrong"
  c2_\fermata^\fermata % The second fermata is ignored!
  <e d'>2^\flageolet_\flageolet

  \stopStaff s1 \startStaff

  <>^"Works if written inside a chord"
  <e_\flageolet d'^\flageolet>2
  <e_\flageolet d'^\flageolet>2
  <e_\flageolet^\flageolet>2
  <e_\fermata^\fermata>2
}

[image of music]


Línies d’extensió per a nombre de corda

Fem una línia extensora per a les indicacions de nombre de corda, mostrant que una sèrie de notes s’han de tocar sobre la mateixa corda.

stringNumberSpanner =
  #(define-music-function (StringNumber) (string?)
    #{
      \override TextSpanner.style = #'solid
      \override TextSpanner.font-size = #-5
      \override TextSpanner.bound-details.left.stencil-align-dir-y = #CENTER
      \override TextSpanner.bound-details.left.text =
        \markup { \circle \number $StringNumber }
    #})


\relative c {
  \clef "treble_8"
  \stringNumberSpanner "5"
  \textSpannerDown
  a8\startTextSpan
  b c d e f\stopTextSpan
  \stringNumberSpanner "4"
  g\startTextSpan a
  bes4 a g2\stopTextSpan
}

[image of music]


Evitar els advertiments sobre columnes de notes que xoquen

Si es col·loquen sobre la mateixa posició notes de dues veus diferents amb les pliques en la mateixa direcció, i cap de les veus té un desplaçament o ambdues tenen el mateix desplaçament, apareix el missatge d’error ‘advertiment: massa columnes de notes en col·lisió, s'ignora’ en compilar el fitxer del LilyPond. Aquest missatge es pot evitar fixant la propietat 'ignore-collision de l’objecte NoteColumn al valor #t. Observeu que això no elimina sols els advertiments, sinó que fa que el LilyPond deixi d’intentar resoldre les col·lisions en absolut, per la qual cosa poden obtenir-se resultats diferents dels esperats si no s’usa amb prudència.

ignore = \override NoteColumn.ignore-collision = ##t

\relative c' {
  \new Staff <<
    \new Voice { \ignore \stemDown f2 g }
    \new Voice { c2 \stemDown c, }
  >>
}

[image of music]


Time signature in brackets

The time signature can be enclosed within brackets.

\relative c'' {
  \override Staff.TimeSignature.stencil = #(lambda (grob)
    (bracketify-stencil (ly:time-signature::print grob) Y 0.1 0.2 0.1))
  \time 2/4
  a4 b8 c
}

[image of music]


Compàs entre parèntesis

La indicació de compàs pot envoltar-se entre parèntesi.

\relative c'' {
  \override Staff.TimeSignature.stencil = #(lambda (grob)
    (parenthesize-stencil (ly:time-signature::print grob) 0.1 0.4 0.4 0.1))
  \time 2/4
  a4 b8 c
}

[image of music]


Indicació de compàs imprimint sols el numerador (en lloc de la fracció)

A vegades, la indicació de compàs no ha d’imprimir la fracció completa (per exemple 7/4), sinó sols el numerador (7 en aquest cas). Això es pot fer fàcilment utilitzant \override Staff.TimeSignature.style = #'single-number per canviar l’estil permanentment. Usant \revert Staff.TimeSignature.style, es pot revertir el canvi. Per aplicar l’estil d’un dígit únic a una sola indicació de compàs, utilitzeu l’ordre \override i anteposeu l’ordre \once.

\relative c'' {
  \time 3/4
  c4 c c
  % Change the style permanently
  \override Staff.TimeSignature.style = #'single-number
  \time 2/4
  c4 c
  \time 3/4
  c4 c c
  % Revert to default style:
  \revert Staff.TimeSignature.style
  \time 2/4
  c4 c
  % single-number style only for the next time signature
  \once \override Staff.TimeSignature.style = #'single-number
  \time 5/4
  c4 c c c c
  \time 2/4
  c4 c
}

[image of music]


Tuplet bracket and change staff

This snippet shows how to set a tuplet starting in a lower staff and finishing in the upper one.

aigues = \relative c' {
  \time 6/8
  s4.
  \stemDown
  c16[ bes' e]
  \stemUp
  g c e
  \stemDown
  g8
}

basses = \relative c {
  \time 3/4
  \clef F
  \tweak positions #'(4.5 . 9.5)
  \tweak edge-height #'(1 . -1)
  \tuplet 7/6 {
    c16[ bes' e]
    \change Staff = md
    \stemUp
    g[ c e g]
  }
  s4.s8
}

\new PianoStaff
\with { \omit TimeSignature }
<<
  \new Staff = md \aigues
  \new Staff = mg \basses
>>

[image of music]


Ajustament de les propietats de clau

La modificació del glif de la clau, la seva posició o octava, no canvien ’per se’ la posició de les notes següents del pentagrama. Per aconseguir armadures adequades de tonalitat sobre les línies del pentagrama, s’ha d’especificar també middleCClefPosition, amb valor positius o negatius que moguin Do central cap amunt o cap avall, respectivament, en relació amb la línia central del pentagrama (usualment la tercera).

Per exemple, l’ordre \clef "treble_8" equival a un ajustament de clefGlyph, clefPosition (que controla la posició vertical de la clau sobre el pentagrama), middleCPosition i clefTransposition. Se imprimeix la clau cada cop que es modifica qualsevol de les propietats excepte middleCPosition.

Els exemple següents mostren les possibilitats quan s’ajusten aquestes propietats manualment. En la primera línia, els canvis manuals preserven la posició relativa estàndard de les clau i les notes, però no ho fan a la segona línia.

{
  % The default treble clef
  \key f \major
  c'1
  % The standard bass clef
  \set Staff.clefGlyph = "clefs.F"
  \set Staff.clefPosition = 2
  \set Staff.middleCPosition = 6
  \set Staff.middleCClefPosition = 6
  \key g \major
  c'1
  % The baritone clef
  \set Staff.clefGlyph = "clefs.C"
  \set Staff.clefPosition = 4
  \set Staff.middleCPosition = 4
  \set Staff.middleCClefPosition = 4
  \key f \major
  c'1
  % The standard choral tenor clef
  \set Staff.clefGlyph = "clefs.G"
  \set Staff.clefPosition = -2
  \set Staff.clefTransposition = -7
  \set Staff.middleCPosition = 1
  \set Staff.middleCClefPosition = 1
  \key f \major
  c'1
  % A non-standard clef
  \set Staff.clefPosition = 0
  \set Staff.clefTransposition = 0
  \set Staff.middleCPosition = -4
  \set Staff.middleCClefPosition = -4
  \key g \major
  c'1 \break

  % The following clef changes do not preserve
  % the normal relationship between notes, key signatures
  % and clefs:

  \set Staff.clefGlyph = "clefs.F"
  \set Staff.clefPosition = 2
  c'1
  \set Staff.clefGlyph = "clefs.G"
  c'1
  \set Staff.clefGlyph = "clefs.C"
  c'1
  \set Staff.clefTransposition = 7
  c'1
  \set Staff.clefTransposition = 0
  \set Staff.clefPosition = 0
  c'1

  % Return to the normal clef:

  \set Staff.middleCPosition = 0
  c'1
}

\paper { tagline = ##f }

[image of music]


Ajustament de la disposició de les notes d’adorn dins de la música

La disposició de les expressions d’adorn es pot canviar al llarg de tota la música usant les funcions add-grace-property i remove-grace-property. L’exemple següent esborra la definició de la direcció de la plica per a aquest nota d’adorn, de manera que les pliques no sempre apunten cap a dalt, i canvia la forma predeterminada dels caps a aspes.

\relative c'' {
  \new Staff {
    $(remove-grace-property 'Voice 'Stem 'direction)
    $(add-grace-property 'Voice 'NoteHead 'style 'cross)
    \new Voice {
       \acciaccatura { f16 } g4
       \grace { d16 e } f4
       \appoggiatura { f,32 g a } e2
    }
  }
}

[image of music]


Ús d’estils alternatius per als corxets

Es poden imprimir estils alternatius del corxet o ganxo de les corxeres i figures menors, mitjançant la sobreescriptura de la propietat stencil de l’objecte Flag. Són valors vàlids modern-straight-flag, old-straight-flag i flat-flag.

testnotes = {
  \autoBeamOff
  c8 d16 c32 d64 \acciaccatura { c8 } d64 r4
}

\score {
  \relative c' {
    \time 2/4
    \testnotes

    \override Flag.stencil = #modern-straight-flag
    \testnotes

    \override Flag.stencil = #old-straight-flag
    \testnotes

    \override Flag.stencil = #flat-flag
    \testnotes

    \revert Flag.stencil
    \testnotes
  }
  \layout {
    indent = 0
    \context {
      \Score
      \override NonMusicalPaperColumn.line-break-permission = ##f
    }
  }
}

[image of music]


Utilitzar ly:grob-object per accedir als grobs amb \tweak

Es pot accedir "lateralment" a alguns grobs des de dins de la funció de callbak d’un altre grob. Aquests es troben relacionats normalment com "layout objects" (objectes de presentació) en la secció "Internal properties" (propietats internes) d’una interfície de grob. S’usa la funció ly:grob-object per a accedir a aquests grobs.

Es presenten més avall com a exemple algunes formes d’accedir a grobs des de dins d’una funció de callblack de NoteHead, però la tècnica no es limita als caps de nota. No obstant, la funció de callblack de NoteHead és especialment important, perquè és la funció de callback implícita que utilitza l’ordre \tweak.

La funció d’exemple que es defineix sota ("display-grobs") no és probablement tan útil, però mostra que s’està accedint efectivament als grobs.

Sortida d’exemple de la consola:

--------------------
#-Grob Accidental -
#-Grob Arpeggio -
#-Grob Stem -
#(define (notehead-get-accidental notehead)
   ;; notehead is grob
   (ly:grob-object notehead 'accidental-grob))

#(define (notehead-get-arpeggio notehead)
   ;; notehead is grob
   (let ((notecolumn (notehead-get-notecolumn notehead)))
     (ly:grob-object notecolumn 'arpeggio)))

#(define (notehead-get-notecolumn notehead)
   ;; notehead is grob
   (ly:grob-parent notehead X))

#(define (notehead-get-stem notehead)
   ;; notehead is grob
   (let ((notecolumn (notehead-get-notecolumn notehead)))
     (ly:grob-object notecolumn 'stem)))

#(define (display-grobs notehead)
   ;; notehead is grob
   (let ((accidental (notehead-get-accidental notehead))
         (arpeggio (notehead-get-arpeggio notehead))
         (stem (notehead-get-stem notehead)))
     (format (current-error-port) "~2&~a\n" (make-string 20 #\-))
     (for-each
      (lambda (x) (format (current-error-port) "~a\n" x))
      (list accidental arpeggio stem))))

\relative c' {
  %% display grobs for each note head:
  %\override NoteHead.before-line-breaking = #display-grobs
  <c
  %% or just for one:
  \tweak before-line-breaking #display-grobs
  es
  g>1\arpeggio
}

[image of music]


Ús del llenguatge PostSript per generar caps de nota de formes especials

Quan el cap d’una nota amb una forma especial no es pot generar fàcilment mitjançant elements de marcatge gràfic, es pot usar codi de Postscript per generar la forma. Aquest exemple mostra com es genera un cap en forma de paral·lelogram.

%% Updaters remark:
%% For unkown reasons this snippet returns a gs-error, but only, if compiled
%% with multiple others like: lilypond *.ly
%% Thus changing to a path-stencil.
%% TODO description needs to get adjusted  --harm

parallelogram =
  #(ly:make-stencil
    '(path 0.1
        (rmoveto 0 0.25
         lineto 1.3125 0.75
         lineto 1.3125 -0.25
         lineto 0 -0.75)
         round
         round
         #t)
    (cons 0 1.3125)
    (cons -.75 .75))

myNoteHeads = \override NoteHead.stencil = \parallelogram
normalNoteHeads = \revert NoteHead.stencil

\relative c'' {
  \myNoteHeads
  g4 d'
  \normalNoteHeads
  <f, \tweak stencil \parallelogram b e>4 d
}

[image of music]


Ús de l’ordre \tweak per retocar objectes gràfics individuals

Amb l’ordre d’ajustament \tweak tots els objectes gràfics es poden retocar directament. Aquí presentem exemples dels tipus de retocament disponibles.

\relative c' {
  \time 2/4
  \set fingeringOrientations = #'(right)
  <
    \tweak font-size #3 c
    \tweak color #red d-\tweak font-size #8 -4
    \tweak style #'cross g
    \tweak duration-log #2 a
  >2
}

[image of music]


Indicacions dinàmiques i textuals alineades verticalment

Tots els objectes DynamicLineSpanner (reguladors i indicacions dinàmiques de text) se situen amb la seva línia de referència a una distància d’almenys 'staff-padding del pentagrama, a no ser que d’altres elements de notació els forci a col·locar-se a més distància. Si s’ajusta 'staff-padding a un valor suficientment gran, les indicacions dinàmiques quedaran alineades.

S’usa una idea semblant junt a \textLengthOn per alinear les inscripcions de text al llarg de la seva línia de base.

music = \relative c' {
  a'2\p b\f
  e4\p f\f\> g, b\p
  c2^\markup { \huge gorgeous } c^\markup { \huge fantastic }
}

{
  \music
  \break
  \override DynamicLineSpanner.staff-padding = 3
  \textLengthOn
  \override TextScript.staff-padding = 1
  \music
}

\paper { tagline = ##f }

[image of music]


Alineació vertical de la lletra i els compassos d’ossia

Aquest fragment de codi mostra l’ús de les propietats de context alignBelowContext i alignAboveContext per a controlar la posició de la lletra i els compassos d’ossia.

\relative c' <<
  \new Staff = "1" { c4 c s2 }
  \new Staff = "2" { c4 c s2 }
  \new Staff = "3" { c4 c s2 }
  { \skip 2
    <<
      \lyrics {
        \set alignBelowContext = "1"
        lyrics4 below
      }
      \new Staff \with {
        alignAboveContext = "3"
        fontSize = -2
        \override StaffSymbol.staff-space = #(magstep -2)
        \remove "Time_signature_engraver"
      } {
        \tuplet 6/4 {
          \override TextScript.padding = 3
          c8[^"ossia above" d e d e f]
        }
      }
    >>
  }
>>

\paper {
  ragged-right = ##t
}

[image of music]


Centrat vertical de les línies de baix xifrat emparellades

Al lloc on s’utilitzin línies extensores per al baix xifrat mitjançant l’establiment de useBassFigureExtenders al valor vertader, les parelles de línies extensores congruents se centren verticalment si el valor de figuredBassCenterContinuations té el valor vertader.

<<
  \relative c' {
    c8 c b b a a c16 c b b
    c8 c b b a a c16 c b b
    c8 c b b a a c c b b
  }
  \figures {
    \set useBassFigureExtenders = ##t
    <6+ 4 3>4 <6 4 3>8 r
    <6+ 4 3>4 <6 4 3>8 <4 3+>16 r
    \set figuredBassCenterContinuations = ##t
    <6+ 4 3>4 <6 4 3>8 r
    <6+ 4 3>4 <6 4 3>8 <4 3+>16 r
    \set figuredBassCenterContinuations = ##f
    <6+ 4 3>4 <6 4 3>8 r
    <6+ 4 3>4 <6 4 3>8 <4 3+>8
  }
>>

[image of music]


Paper and layout

Spacing issues


Alinear i centrar els noms dels instruments

L’alineació horitzontal dels noms d’instruments es pot ajustar modificant la propietat Staff.InstrumentName #'self-alignment-X. Les variables de \layout, indent i short-indent defineixen l’espai en el qual s’alineen els noms d’instrument abans del primer sistema i dels següents, respectivament.

\paper { left-margin = 3\cm }

\score {
  \new StaffGroup <<

    \new Staff \with {
      \override InstrumentName.self-alignment-X = #LEFT
      instrumentName = \markup \left-column {
        "Left aligned"
        "instrument name"
        }
        shortInstrumentName = "Left"
      }

      {  c''1 \break c''1 }

    \new Staff \with {
      \override InstrumentName.self-alignment-X = #CENTER
      instrumentName = \markup \center-column {
        Centered
        "instrument name"
        }
      shortInstrumentName = "Centered"
    }

    { g'1 g'1}

    \new Staff \with {
      \override InstrumentName.self-alignment-X = #RIGHT
      instrumentName = \markup \right-column {
        "Right aligned"
        "instrument name"
      }
      shortInstrumentName = "Right"
    }

    { e'1 e'1 }

  >>

  \layout {
    ragged-right = ##t
    indent = 4\cm
    short-indent = 2\cm
  }
}

[image of music]


Arranging separate lyrics on a single line

Sometimes you may want to put lyrics for different performers on a single line: where there is rapidly alternating text, for example. This snippet shows how this can be done with \override VerticalAxisGroup.nonstaff-nonstaff-spacing.minimum-distance = ##f.

\header { tagline = ##f }

\layout {
  \context {
    \Lyrics
    \override VerticalAxisGroup
              .nonstaff-nonstaff-spacing
              .minimum-distance = ##f
  }
}

aliceSings = \markup { \smallCaps "Alice" }
eveSings = \markup { \smallCaps "Eve" }

<<
  \new Staff <<
    \new Voice = "alice" {
      f'4^\aliceSings g' r2 |
      s1 |
      f'4^\aliceSings g' r2 |
      s1 | \break
      % ...

      \voiceOne
      s2 a'8^\aliceSings a' b'4 |
      \oneVoice
      g'1
    }
    \new Voice = "eve" {
      s1 |
      a'2^\eveSings g' |
      s1 |
      a'2^\eveSings g'
      % ...

      \voiceTwo
      f'4^\eveSings a'8 g' f'4 e' |
      \oneVoice
      s1
    }
  >>
  \new Lyrics \lyricsto "alice" {
    may -- be
    sec -- ond
    % ...
    Shut up, you fool!
  }
  \new Lyrics \lyricsto "eve" {
    that the
    words are
    % ...
    …and then I was like–
  }
>>

[image of music]


Parts de llibre

Es pot usar \bookpart per dividir un llibre en diverses parts. L’última pàgina de cada part pot quedar afectada pel valor de ragged-last-bottom. Els elements de marcatge d’encapçalament i peu de pàgina pot detectar que estiguin en la ultima pàgina d’una part, i presentar diferències amb l’última pàgina del llibre.

#(set-default-paper-size "a6")

\book {
  %% book paper, which is inherited by all children bookparts
  \paper {
    ragged-last-bottom = ##t
    %% Page footer: add a different part-tagline at part last page
    oddFooterMarkup = \markup {
      \column {
        \fill-line {
          %% Copyright header field only on book first page.
          \if \on-first-page \fromproperty #'header:copyright
        }
        \fill-line {
          %% Part tagline header field only on each part last page.
          \if \on-last-page-of-part \fromproperty #'header:parttagline
        }
        \fill-line {
          %% Tagline header field only on book last page.
          \if \on-last-page \fromproperty #'header:tagline
        }
      }
    }
  }

  %% book header, which is inherited by the first bookpart
  \header {
    title = "Book title"
    copyright = "Copyright line on book first page"
    parttagline = "Part tagline"
    tagline = "Book tagline"
  }

  \bookpart {
    %% a different page breaking function may be used on each part
    \paper { page-breaking = #ly:minimal-breaking }
    \header { subtitle = "First part" }
    \markup { The first book part }
    \markup { a page break }
    \pageBreak
    \markup { first part last page }
    \markup \wordwrap { with ragged-last-bottom (see the space below this text) }
  }

  \bookpart {
    \header { subtitle = "Second part" }
    { c'4 }
  }

}

[image of music]


Modificar la mida de la pauta

Tot i que la manera més senzilla de redimensionar els pentagrames és usar #(set-global-staff-size xx), la mida d’una pauta individual es pot canviar escalant les propietats de 'staff-space i de fontSize.

<<
  \new Staff {
    \relative c'' {
      \dynamicDown
      c8\ff c c c c c c c
    }
  }
  \new Staff \with {
    fontSize = #-3
    \override StaffSymbol.staff-space = #(magstep -3)
  } {
    \clef bass
    c8 c c c c\f c c c
  }
>>

[image of music]


Retallada de sistemes

This code shows how to clip (extract) snippets from a full score.

This file needs to be run separately with -dclip-systems; the snippets page may not adequately show the results. The result will be files named ‘base-from-start-to-end[-count].eps’.

If system starts and ends are included, they include extents of the System grob, e.g., instrument names.

Grace notes at the end point of the region are not included.

Regions can span multiple systems. In this case, multiple EPS files are generated.

#(ly:set-option 'clip-systems)
#(ly:set-option 'separate-page-formats "ps")
#(define output-suffix "1")

origScore = \score {
  \relative c' {
    \new Staff \with { instrumentName = "Instrument" }
    c1
    d1
    \grace c16 e1
    \key d \major
    f1 \break
    \clef bass
    g,1
    fis1
  }
}

\book {
  \score {
    \origScore
    \layout {
      % Each clip-region is a (START . END) pair
      % where both are rhythmic-locations.

      % (make-rhythmic-locations BAR-NUMBER NUM DEN)
      % means NUM/DEN whole-notes into bar numbered BAR-NUMBER

      clip-regions = #(list
      (cons
       (make-rhythmic-location 2 0 1)
       (make-rhythmic-location 4 0 1))

      (cons
       (make-rhythmic-location 0 0 1)
       (make-rhythmic-location 4 0 1))

      (cons
       (make-rhythmic-location 0 0 1)
       (make-rhythmic-location 6 0 1))
      )
    }
  }
}

#(ly:set-option 'clip-systems #f)
#(ly:set-option 'separate-page-formats #f)
#(define output-suffix #f)

\book {
  \score { \origScore }
  \markup { \bold \fontsize #6 clips }
  \score {
    \lyrics {
      \markup { from-2.0.1-to-4.0.1-clip.eps }
      \markup {
        \epsfile #X #30.0 #(format #f "~a-1-from-2.0.1-to-4.0.1-clip.eps"
                            (ly:parser-output-name)) }
    }
  }
}

[image of music]


Crear pentagrames en blanc

Per crear pentagrames en blanc, genereu compassos buits i després elimineu el gravador de números de compàs Bar_number_engraver del context Score, i els gravadors de la indicacó de compàs Time_signature_engraver, de la clau Clef_engraver i dels compassos Bar_engraver del context de Staff.

#(set-global-staff-size 20)

\score {
  {
    \repeat unfold 12 { s1 \break }
  }
  \layout {
    indent = 0\in
    \context {
      \Staff
      \remove "Time_signature_engraver"
      \remove "Clef_engraver"
      \remove "Bar_engraver"
    }
    \context {
      \Score
      \remove "Bar_number_engraver"
    }
  }
}

% uncomment these lines for "letter" size
%{
\paper {
  #(set-paper-size "letter")
  ragged-last-bottom = ##f
  line-width = 7.5\in
  left-margin = 0.5\in
  bottom-margin = 0.25\in
  top-margin = 0.25\in
}
%}

% uncomment these lines for "A4" size
%{
\paper {
  #(set-paper-size "a4")
  ragged-last-bottom = ##f
  line-width = 180
  left-margin = 15
  bottom-margin = 10
  top-margin = 10
}
%}

[image of music]


Mostra de cadascú dels encapçalaments possibles

Mostra de tots els tipus d’encapçalament.

\header {
  copyright = "copyright"
  title = "title"
  subtitle = "subtitle"
  composer = "composer"
  arranger = "arranger"
  instrument = "instrument"
  meter = "meter"
  opus = "opus"
  piece = "piece"
  poet = "poet"
  texidoc = "All header fields with special meanings."
  copyright = "public domain"
  enteredby = "jcn"
  source = "urtext"
}

\layout {
  ragged-right = ##f
}

\score {
  \relative c'' { c1 | c | c | c }
}

\score {
   \relative c'' { c1 | c | c | c }
   \header {
     title = "localtitle"
     subtitle = "localsubtitle"
     composer = "localcomposer"
     arranger = "localarranger"
     instrument = "localinstrument"
     metre = "localmetre"
     opus = "localopus"
     piece = "localpiece"
     poet = "localpoet"
     copyright = "localcopyright"
   }
}

[image of music]


Fixació d’un separador entre els sistemes

Es poden inserir separadors de sistema entre els sistemes d’una pàgina. Es pot usar qualsevol element de marcatge, però hi ha \slashSeparator com una elecció predeterminada adequada.

\paper {
  system-separator-markup = \slashSeparator
  line-width = 120
  tagline = ##f
}

notes = \relative c' {
  c1 | c \break
  c1 | c \break
  c1 | c
}

\book {
  \score {
    \new GrandStaff <<
      \new Staff \notes
      \new Staff \notes
    >>
  }
}

[image of music]


Índex general (taul de continguts)

Es pot incloure un índex general (taula de continguts) mitjançant ús de \markuplines \table-of-contents. Els elements de la taula de continguts s’afageixen amb l’ordre \tocItem.

#(set-default-paper-size "a6")

\book {
  \markuplist \table-of-contents
  \pageBreak
  \tocItem \markup { The first score }
  \score {
    {
      c'1 \pageBreak
      \mark \default \tocItem \markup { Mark A }
      d'1
    }
  }
  \pageBreak
  \tocItem \markup { The second score }
  \score {
    { e'1 }
    \header { piece = "Second score" }
  }
}

[image of music]


Vertically aligned StaffGroups without connecting SystemStartBar

This snippet shows how to achieve vertically aligned StaffGroups with a SystemStartBar for each StaffGroup, but without connecting them.

#(set-global-staff-size 18)

\header { tagline = ##f }

\paper {
  indent = 0
  ragged-right = ##f
  print-all-headers = ##t
}

\layout {
  \context {
    \StaffGroup
    \consists Text_mark_engraver
    \consists Staff_collecting_engraver
    systemStartDelimiterHierarchy =
      #'(SystemStartBrace (SystemStartBracket a b))
  }

  \context {
    \Score
    \remove Text_mark_engraver
    \remove Staff_collecting_engraver
    \override SystemStartBrace.style = #'bar-line
    \omit SystemStartBar
    \override SystemStartBrace.padding = #-0.1
    \override SystemStartBrace.thickness = #1.6
    \override StaffGrouper.staffgroup-staff-spacing.basic-distance = #15
  }
}

%%%% EXAMPLE

txt =
\lyricmode {
  Wer4 nur den lie -- ben Gott läßt wal2 -- ten4
  und4 hof -- fet auf ihn al -- le Zeit2.
}

% First StaffGroup "exercise"

eI =
\relative c' {
  \textMark \markup {
          \bold Teacher:
          This is a simple setting of the choral. Please improve it.
          }
  \key a \minor
  \time 4/4
  \voiceOne

  \partial 4
  e4
  a b c b
  a b gis2
  e4\fermata g! g f
  e a a gis
  a2.\fermata
  \bar ":|."
}

eII =
\relative c' {
  \key a \minor
  \time 4/4
  \voiceTwo
  \partial 4
  c4
  e e e gis
  a f e2
  b4 b d d
  c c d d
  c2.
  \bar ":|."
}

eIII =
\relative c' {
  \key a \minor
  \time 4/4
  \clef bass
  \voiceOne

  \partial 4
  a4
  c b a b
  c d b2
  gis4 g g b
  c a f e
  e2.
}

eIV =
\relative c' {
  \key a \minor
  \time 4/4
  \clef bass
  \voiceTwo

  \partial 4
  a,4
  a' gis a e
  a, d e2
  e,4\fermata e' b g
  c f d e
  a,2.\fermata
  \bar ":|."
}

exercise =
\new StaffGroup = "exercise"
<<

  \new Staff
    <<
      \new Voice \eI
      \new Voice \eII
    >>

  \new Lyrics \txt

  \new Staff
    <<
      \new Voice \eIII
      \new Voice \eIV
    >>
>>

% Second StaffGroup "simple Bach"

sbI =
\relative c' {
  \textMark \markup { \bold" Pupil:" Here's my version! }
  \key a \minor
  \time 4/4
  \voiceOne

  \partial 4
  e4
  a b c b
  a b gis2
  e4\fermata g! g f
  e a a gis
  a2.\fermata
  \bar ":|."
}

sbII =
\relative c' {
  \key a \minor
  \time 4/4
  \voiceTwo
  \partial 4
  c8 d
  e4 e e8 f g4
  f f e2
  b4 b8 c d4 d
  e8 d c4 b8 c d4
  c2.
  \bar ":|."
}

sbIII =
\relative c' {
  \key a \minor
  \time 4/4
  \clef bass
  \voiceOne

  \partial 4
  a8 b
  c4 b a b8 c
  d4 d8 c b2
  gis4 g g8 a b4
  b a8 g f4 e
  e2.
}

sbIV =
\relative c' {
  \key a \minor
  \time 4/4
  \clef bass
  \voiceTwo

  \partial 4
  a,4
  a' gis a e
  f8 e d4 e2
  e,4\fermata e' b a8 g
  c4 f8 e d4 e
  a,2.\fermata
  \bar ":|."
}

simpleBach =
\new StaffGroup = "simple Bach"
<<

  \new Staff
    <<
      \new Voice \sbI
      \new Voice \sbII
    >>

  \new Lyrics \txt

  \new Staff
    <<
      \new Voice \sbIII
      \new Voice \sbIV
    >>
>>

% Third StaffGroup "chromatic Bach"

cbI =
\relative c' {
  \textMark \markup {
    \bold "Teacher:"
    \column {
      "Well, you simply copied and transposed a version of J.S.Bach."
      "Do you know this one?"
    }
  }
  \key a \minor
  \time 4/4
  \voiceOne

  \partial 4
  e4
  a b c b
  a b gis4. fis8
  e4\fermata g! g f
  e a a8 b gis4
  a2.\fermata
  \bar ":|."
}

cbII =
\relative c' {
  \key a \minor
  \time 4/4
  \voiceTwo
  \partial 4
  c8 d
  e4 e e8 fis gis4
  a8 g! f!4 e2
  b4 e e d
  d8[ cis] d dis e fis e4
  e2.
  \bar ":|."
}

cbIII =
\relative c' {
  \key a \minor
  \time 4/4
  \clef bass
  \voiceOne

  \partial 4
  a8 b
  c[ b] a gis8 a4 d,
  e8[ e'] d c b4. a8
  gis4 b c d8 c
  b[ a] a b c b b c16 d
  c2.
}

cbIV =
\relative c' {
  \key a \minor
  \time 4/4
  \clef bass
  \voiceTwo

  \partial 4
  a4
  c, e a, b
  c d e2
  e4\fermata e a b8 c
  gis[ g] fis f e dis e4
  a,2.\fermata
  \bar ":|."
}

chromaticBach =
\new StaffGroup = "chromatic Bach"
<<

  \new Staff
    <<
      \new Voice \cbI
      \new Voice \cbII
    >>

  \new Lyrics \txt

  \new Staff
    <<
      \new Voice \cbIII
      \new Voice \cbIV
    >>
>>


% Score

\score {
  <<
    \exercise
    \simpleBach
    \chromaticBach
  >>

  \header {
    title = \markup
               \column {
                 \combine \null \vspace #1
                 "Exercise: Improve the given choral"
                 " "
                }
  }
  \layout {
    \context {
      \Lyrics
      \override LyricText.X-offset = #-1
    }
  }
}

[image of music]


Titles

Titles and headers


Afegir la data actual a una partitura

Amb quelcom de codi de l’Scheme, es pot afegir fàcilment la data actual a una partitura.

\paper { tagline = ##f }

% first, define a variable to hold the formatted date:
date = #(strftime "%d-%m-%Y" (localtime (current-time)))

% use it in the title block:
\header {
  title = "Including the date!"
  subtitle = \date
}

\score {
  \relative c'' {
    c4 c c c
  }
}
% and use it in a \markup block:
\markup {
  \date
}

[image of music]


Alinear i centrar els noms dels instruments

L’alineació horitzontal dels noms d’instruments es pot ajustar modificant la propietat Staff.InstrumentName #'self-alignment-X. Les variables de \layout, indent i short-indent defineixen l’espai en el qual s’alineen els noms d’instrument abans del primer sistema i dels següents, respectivament.

\paper { left-margin = 3\cm }

\score {
  \new StaffGroup <<

    \new Staff \with {
      \override InstrumentName.self-alignment-X = #LEFT
      instrumentName = \markup \left-column {
        "Left aligned"
        "instrument name"
        }
        shortInstrumentName = "Left"
      }

      {  c''1 \break c''1 }

    \new Staff \with {
      \override InstrumentName.self-alignment-X = #CENTER
      instrumentName = \markup \center-column {
        Centered
        "instrument name"
        }
      shortInstrumentName = "Centered"
    }

    { g'1 g'1}

    \new Staff \with {
      \override InstrumentName.self-alignment-X = #RIGHT
      instrumentName = \markup \right-column {
        "Right aligned"
        "instrument name"
      }
      shortInstrumentName = "Right"
    }

    { e'1 e'1 }

  >>

  \layout {
    ragged-right = ##t
    indent = 4\cm
    short-indent = 2\cm
  }
}

[image of music]


Mostra de cadascú dels encapçalaments possibles

Mostra de tots els tipus d’encapçalament.

\header {
  copyright = "copyright"
  title = "title"
  subtitle = "subtitle"
  composer = "composer"
  arranger = "arranger"
  instrument = "instrument"
  meter = "meter"
  opus = "opus"
  piece = "piece"
  poet = "poet"
  texidoc = "All header fields with special meanings."
  copyright = "public domain"
  enteredby = "jcn"
  source = "urtext"
}

\layout {
  ragged-right = ##f
}

\score {
  \relative c'' { c1 | c | c | c }
}

\score {
   \relative c'' { c1 | c | c | c }
   \header {
     title = "localtitle"
     subtitle = "localsubtitle"
     composer = "localcomposer"
     arranger = "localarranger"
     instrument = "localinstrument"
     metre = "localmetre"
     opus = "localopus"
     piece = "localpiece"
     poet = "localpoet"
     copyright = "localcopyright"
   }
}

[image of music]


Imprimir el número de versió

Introduint la sortida de lilypond-version en la lletra d’una cançó, és possible imprimir el número de versió del LilyPond dins d’una partitura, o en un document generat amb lilypond-book. Una altra possibilitat és afegir el número de versió al final de la doc-string, d’aquesta forma:

\markup { Processed with LilyPond version #(lilypond-version) }

[image of music]


Spacing

Spacing issues


Ajustament de l’espaiat vertical de la lletra

Aquest fragment de codi mostra com situar la línia de base de la lletra més a prop del pentagrama.

% Default layout:
<<
  \new Staff \new Voice = melody \relative c' {
    c4 d e f
    g4 f e d
    c1
  }
  \new Lyrics \lyricsto melody { aa aa aa aa aa aa aa aa aa }

  \new Staff {
    \new Voice = melody \relative c' {
      c4 d e f
      g4 f e d
      c1
    }
  }
  % Reducing the minimum space below the staff and above the lyrics:
  \new Lyrics \with {
    \override VerticalAxisGroup.nonstaff-relatedstaff-spacing =
      #'((basic-distance . 1))
  }
  \lyricsto melody { aa aa aa aa aa aa aa aa aa }
>>

[image of music]


Permetre que les digitacions s’imprimeixen del pentagrama

Les xifres de digitació orientades verticalment es col·loquen de forma predeterminada fora del pentagrama. Malgrat això, aquest comportament es pot desactivar. Nota: s’ha d’usar una construcció d’acord <>, tot i que sigui una sola nota.

\relative c' {
  <c-1 e-2 g-3 b-5>2
  \override Fingering.staff-padding = #'()
  <c-1 e-2 g-3 b-5>4 g'-0
  a8[-1 b]-2 g-0 r
  \override Fingering.add-stem-support = ##f
  a[-1 b]-2 g-0 r
  \override Fingering.add-stem-support = ##t
  a[-1 b]-2 g-0 r
  \override Fingering.add-stem-support = #only-if-beamed
  a[-1 b]-2 g-0 r
}

[image of music]


Breaking vertical alignment of dynamics and textscripts

By default, LilyPond uses DynamicLineSpanner grobs to vertically align successive dynamic objects like hairpins and dynamic text. However, this is not always wanted. By inserting \breakDynamicSpan, which ends the alignment spanner prematurely, this vertical alignment can be avoided.

{ g1\< |
  e''\f\> |
  c'\p }

{ g1\< |
  e''\breakDynamicSpan\f\> |
  c'\p }

\paper { tagline = ##f }

[image of music]


Etiqueta de pàgina

Es poden posar etiquetes de pàgina dins de la música on al nivell superior, i ser referenciades des d’altres elements de marcatge.

\label license
\markup "This snippet is available under the Creative Commons
Public Domain Dedication license."

{
  \repeat volta 2 {
    \label startRepeat
    \repeat unfold 20 { c'2 2 }
    \pageBreak
    2 2
  }
  \textEndMark \markup {
    \with-link #'startRepeat \line {
      To page \page-ref #'startRepeat "0" "?"
    }
  }
}

\markup {
  See page \page-ref #'license "0" "?" for
  licensing information.
}

[image of music]


Espaiat de les notes estrictament proporcional

Si s’ha establert strict-note-spacing, l’espaiat de les notes no es veu influït pels compassos o claus que pugui haver-hi dins d’un sistema. En comptes d’això, es col·loquen just abans de la nota que té lloc en el mateix moment temporal. Això pot produir col·lisions.

\relative c'' <<
  \override Score.SpacingSpanner.strict-note-spacing = ##t
  \set Score.proportionalNotationDuration = \musicLength 16
  \new Staff {
    c8[ c \clef alto c c \grace { d16 } c8 c] c4
    c2 \grace { c16[ c16] } c2
  }
  \new Staff {
    c2 \tuplet 3/2 { c8 \clef bass cis,, c } c4
    c1
  }
>>

[image of music]


Indicacions dinàmiques i textuals alineades verticalment

Tots els objectes DynamicLineSpanner (reguladors i indicacions dinàmiques de text) se situen amb la seva línia de referència a una distància d’almenys 'staff-padding del pentagrama, a no ser que d’altres elements de notació els forci a col·locar-se a més distància. Si s’ajusta 'staff-padding a un valor suficientment gran, les indicacions dinàmiques quedaran alineades.

S’usa una idea semblant junt a \textLengthOn per alinear les inscripcions de text al llarg de la seva línia de base.

music = \relative c' {
  a'2\p b\f
  e4\p f\f\> g, b\p
  c2^\markup { \huge gorgeous } c^\markup { \huge fantastic }
}

{
  \music
  \break
  \override DynamicLineSpanner.staff-padding = 3
  \textLengthOn
  \override TextScript.staff-padding = 1
  \music
}

\paper { tagline = ##f }

[image of music]


Alineació vertical de la lletra i els compassos d’ossia

Aquest fragment de codi mostra l’ús de les propietats de context alignBelowContext i alignAboveContext per a controlar la posició de la lletra i els compassos d’ossia.

\relative c' <<
  \new Staff = "1" { c4 c s2 }
  \new Staff = "2" { c4 c s2 }
  \new Staff = "3" { c4 c s2 }
  { \skip 2
    <<
      \lyrics {
        \set alignBelowContext = "1"
        lyrics4 below
      }
      \new Staff \with {
        alignAboveContext = "3"
        fontSize = -2
        \override StaffSymbol.staff-space = #(magstep -2)
        \remove "Time_signature_engraver"
      } {
        \tuplet 6/4 {
          \override TextScript.padding = 3
          c8[^"ossia above" d e d e f]
        }
      }
    >>
  }
>>

\paper {
  ragged-right = ##t
}

[image of music]


MIDI

Creating MIDI output


Modificar la sortida MIDI perquè tingui un canal per a cada veu

En produir una sortida MIDI, el comportament predeterminat és que cada pentagrama representa un canal MIDI, amb totes les veus d’aquest pentagrama barrejades. Això redueix al mínim el risc que s’esgoti el nombre de canals MIDI disponibles, atès que hi ha un màxim de 16 canals per cada port MIDI, i la majoria dels dispositius sols tenen un port.

No obstant, quan es trasllada l’interpretador Staff_performer al context Voice, cada veu d’un pentagrama pot tenir el seu propi canal MIDI, com es mostra a l’exemple següent: malgrat d’estar sobre el mateix pentagrama, es creen dos canals MIDI, cadascú amb un midiInstrument diferent.

\score {
  \new Staff <<
    \new Voice \relative c''' {
      \set midiInstrument = "flute"
      \voiceOne
      \key g \major
      \time 2/2
      r2 g-"Flute" ~
      g fis ~
      fis4 g8 fis e2 ~
      e4 d8 cis d2
    }
    \new Voice \relative c'' {
      \set midiInstrument = "clarinet"
      \voiceTwo
      b1-"Clarinet"
      a2. b8 a
      g2. fis8 e
      fis2 r
    }
  >>
  \layout { }
  \midi {
    \context {
      \Staff
      \remove "Staff_performer"
    }
    \context {
      \Voice
      \consists "Staff_performer"
    }
    \tempo 2 = 72
  }
}

[image of music]


Canviar el tempo sense indicació metronòmica

Per canviar el tempo a la sortida MIDI sense imprimir res, fem invisible la indicació metronòmica:

\score {
  \new Staff \relative c' {
    \tempo 4 = 160
    c4 e g b
    c4 b d c
    \set Score.tempoHideNote = ##t
    \tempo 4 = 96
    d,4 fis a cis
    d4 cis e d
  }
  \layout { }
  \midi { }
}

[image of music]


Creació de marques dinàmiques a la sortida MIDI

L’exemple següent mostra com crear un marcatge dinàmic, que no està inclòs a llista predeterminada, i assignar-lo a un valor específic de manera que es pugui usar per afectar la sortida MIDI.

A la marca dinàmica \rfz se li assigna un valor de 0.9.

#(define (myDynamics dynamic)
    (if (equal? dynamic "rfz")
      0.9
      (default-dynamic-absolute-volume dynamic)))

\score {
  \new Staff {
    \set Staff.midiInstrument = "cello"
    \set Score.dynamicAbsoluteVolumeFunction = #myDynamics
    \new Voice {
      \relative {
        a'4\pp b c-\rfz
      }
    }
  }
  \layout {}
  \midi {}
}

[image of music]


Customized drum notation in printed and MIDI output

Customized drum “pitch” names (suitable for a custom drum style, for example) may be used both in printed and MIDI output by defining such variables as drumPitchNames, drumStyleTable and midiDrumPitches, as demonstrated here.

In short, this snippet

%% This snippet tries to amend
%% NR 2.5.1 Common notation for percussion - Custom percussion staves
%% http://lilypond.org/doc/v2.24/Documentation/notation/common-notation-for-percussion#custom-percussion-staves

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% To use custom drum pitch names for your score and midi you need to follow
%% this route:
%%
%%%%%%%%%%%%
%% LAYOUT:
%%%%%%%%%%%%
%%
%% (1) Define a name and put it in `drumPitchNames'
%%     This can be done at toplevel with
%%         drumPitchNames.my-name  = #'my-name
%%     It's possible to add an alias as well.
%% (2) Define how it should be printed
%%     Therefore put them into a top-level list, where each entry should
%%     be of the form:
%%         (my-name
%%           note-head-style-or-default
%%             articulation-type-or-#f
%%               staff-position)
%%     Example:
%%         #(define my-style
%%           '(
%%             (my-name default tenuto -1)
%%             ; ...
%%             ))
%% (3) Tell LilyPond to use these custom definitions, with
%%         drumStyleTable = #(alist->hash-table my-style)
%%     in a \layout or \with block
%%
%%     Now we're done for layout. Here is a short but complete example:
%%         \new DrumStaff
%%           \with { drumStyleTable = #(alist->hash-table my-style) }
%%           \drummode { my-name }
%%
%%%%%%%%%%%%
%% MIDI:
%%%%%%%%%%%%
%%
%% (1) Again at top-level, assign a pitch to your custom note name
%%         midiDrumPitches.my-name = ges
%%     Note that you have to use the name, which is in drumPitchNames, no alias
%% (2) Tell LilyPond to use this pitch(es), with
%%         drumPitchTable = #(alist->hash-table midiDrumPitches)
%%
%%     Example:
%%         \score {
%%            \new DrumStaff
%%             \with {
%%               drumStyleTable = #(alist->hash-table my-style)
%%               drumPitchTable = #(alist->hash-table midiDrumPitches)
%%             }
%%             \drummode { my-name4 }
%%           \layout {}
%%           \midi {}
%%         }
%%
%%%%%%%%%%%%
%% TESTING
%%%%%%%%%%%%
%%
%% To test whether all is fine, run the following sequence in terminal:
%%         lilypond my-file.ly
%%         midi2ly my-file.midi
%%         gedit my-file-midi.ly
%%
%% This will do the following:
%% 1. create pdf and midi
%% 2. transform the midi back to a .ly-file
%%    (note: midi2ly is not always good in correctly identifying enharmonic pitches)
%% 3. open this file in gedit (or use another editor)
%% Now watch what you've got.
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% FULL EXAMPLE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

drumPitchNames.dbass      = #'dbass
drumPitchNames.dba        = #'dbass  % 'db is in use already
drumPitchNames.dbassmute  = #'dbassmute
drumPitchNames.dbm        = #'dbassmute
drumPitchNames.do         = #'dopen
drumPitchNames.dopenmute  = #'dopenmute
drumPitchNames.dom        = #'dopenmute
drumPitchNames.dslap      = #'dslap
drumPitchNames.ds         = #'dslap
drumPitchNames.dslapmute  = #'dslapmute
drumPitchNames.dsm        = #'dslapmute

#(define djembe
  '((dbass      default  #f         -2)
    (dbassmute  default  stopped    -2)
    (dopen      default  #f          0)
    (dopenmute  default  stopped     0)
    (dslap      default  #f          2)
    (dslapmute  default  stopped     2)))

midiDrumPitches.dbass = g
midiDrumPitches.dbassmute = fis
midiDrumPitches.dopen =  a
midiDrumPitches.dopenmute = gis
midiDrumPitches.dslap =  b
midiDrumPitches.dslapmute = ais

one = \drummode { r4 dba4 do ds r dbm dom dsm }

\score {
   \new DrumStaff
    \with {
      \override StaffSymbol.line-count =  #3
      instrumentName = #"Djembe "
      drumStyleTable = #(alist->hash-table djembe)
      drumPitchTable = #(alist->hash-table midiDrumPitches)
    }
    \one
  \layout {}
  \midi {}
}

[image of music]


Demo de MidiInstruments

Problema: com saber quin instrument MIDI midiInstrument va millor per a la nostra composició? Solució: un fitxer de demostració del Lilygpond.

\header {
  title = "Demo of all midi sounds"
  arranger = "Myself "
}

baseMelody = \relative c' {
  c4.\mf g c16 b' c d
  e16 d e f g4 g'4 r
  R1
}
melody = {
  \tempo 4 = 150
  \baseMelody
}

\score {
  \new Staff <<
    \new Voice \melody
  >>
  \layout { }
}

\score {
  \new Staff <<
    \new Voice {
      r\mf
      \set Staff.midiInstrument = "acoustic grand" \melody
      \set Staff.midiInstrument = "bright acoustic" \melody
      \set Staff.midiInstrument = "electric grand" \melody
      \set Staff.midiInstrument = "honky-tonk" \melody
      \set Staff.midiInstrument = "electric piano 1" \melody
      \set Staff.midiInstrument = "electric piano 2" \melody
      \set Staff.midiInstrument = "harpsichord" \melody
      \set Staff.midiInstrument = "clav" \melody
      \set Staff.midiInstrument = "celesta" \melody
      \set Staff.midiInstrument = "glockenspiel" \melody
      \set Staff.midiInstrument = "music box" \melody
      \set Staff.midiInstrument = "vibraphone" \melody
      \set Staff.midiInstrument = "marimba" \melody
      \set Staff.midiInstrument = "xylophone" \melody
      \set Staff.midiInstrument = "tubular bells" \melody
      \set Staff.midiInstrument = "dulcimer" \melody
      \set Staff.midiInstrument = "drawbar organ" \melody
      \set Staff.midiInstrument = "percussive organ" \melody
      \set Staff.midiInstrument = "rock organ" \melody
      \set Staff.midiInstrument = "church organ" \melody
      \set Staff.midiInstrument = "reed organ" \melody
      \set Staff.midiInstrument = "accordion" \melody
      \set Staff.midiInstrument = "harmonica" \melody
      \set Staff.midiInstrument = "concertina" \melody
      \set Staff.midiInstrument = "acoustic guitar (nylon)" \melody
      \set Staff.midiInstrument = "acoustic guitar (steel)" \melody
      \set Staff.midiInstrument = "electric guitar (jazz)" \melody
      \set Staff.midiInstrument = "electric guitar (clean)" \melody
      \set Staff.midiInstrument = "electric guitar (muted)" \melody
      \set Staff.midiInstrument = "overdriven guitar" \melody
      \set Staff.midiInstrument = "distorted guitar" \melody
      \set Staff.midiInstrument = "acoustic bass" \melody
      \set Staff.midiInstrument = "electric bass (finger)" \melody
      \set Staff.midiInstrument = "electric bass (pick)" \melody
      \set Staff.midiInstrument = "fretless bass" \melody
      \set Staff.midiInstrument = "slap bass 1" \melody
      \set Staff.midiInstrument = "slap bass 2" \melody
      \set Staff.midiInstrument = "synth bass 1" \melody
      \set Staff.midiInstrument = "synth bass 2" \melody
      \set Staff.midiInstrument = "violin" \melody
      \set Staff.midiInstrument = "viola" \melody
      \set Staff.midiInstrument = "cello" \melody
      \set Staff.midiInstrument = "contrabass" \melody
      \set Staff.midiInstrument = "tremolo strings" \melody
      \set Staff.midiInstrument = "pizzicato strings" \melody
      \set Staff.midiInstrument = "orchestral harp" \melody
      \set Staff.midiInstrument = "timpani" \melody
      \set Staff.midiInstrument = "string ensemble 1" \melody
      \set Staff.midiInstrument = "string ensemble 2" \melody
      \set Staff.midiInstrument = "synthstrings 1" \melody
      \set Staff.midiInstrument = "synthstrings 2" \melody
      \set Staff.midiInstrument = "choir aahs" \melody
      \set Staff.midiInstrument = "voice oohs" \melody
      \set Staff.midiInstrument = "synth voice" \melody
      \set Staff.midiInstrument = "orchestra hit" \melody
      \set Staff.midiInstrument = "trumpet" \melody
      \set Staff.midiInstrument = "trombone" \melody
      \set Staff.midiInstrument = "tuba" \melody
      \set Staff.midiInstrument = "muted trumpet" \melody
      \set Staff.midiInstrument = "french horn" \melody
      \set Staff.midiInstrument = "brass section" \melody
      \set Staff.midiInstrument = "synthbrass 1" \melody
      \set Staff.midiInstrument = "synthbrass 2" \melody
      \set Staff.midiInstrument = "soprano sax" \melody
      \set Staff.midiInstrument = "alto sax" \melody
      \set Staff.midiInstrument = "tenor sax" \melody
      \set Staff.midiInstrument = "baritone sax" \melody
      \set Staff.midiInstrument = "oboe" \melody
      \set Staff.midiInstrument = "english horn" \melody
      \set Staff.midiInstrument = "bassoon" \melody
      \set Staff.midiInstrument = "clarinet" \melody
      \set Staff.midiInstrument = "piccolo" \melody
      \set Staff.midiInstrument = "flute" \melody
      \set Staff.midiInstrument = "recorder" \melody
      \set Staff.midiInstrument = "pan flute" \melody
      \set Staff.midiInstrument = "blown bottle" \melody
      \set Staff.midiInstrument = "shakuhachi" \melody
      \set Staff.midiInstrument = "whistle" \melody
      \set Staff.midiInstrument = "ocarina" \melody
      \set Staff.midiInstrument = "lead 1 (square)" \melody
      \set Staff.midiInstrument = "lead 2 (sawtooth)" \melody
      \set Staff.midiInstrument = "lead 3 (calliope)" \melody
      \set Staff.midiInstrument = "lead 4 (chiff)" \melody
      \set Staff.midiInstrument = "lead 5 (charang)" \melody
      \set Staff.midiInstrument = "lead 6 (voice)" \melody
      \set Staff.midiInstrument = "lead 7 (fifths)" \melody
      \set Staff.midiInstrument = "lead 8 (bass+lead)" \melody
      \set Staff.midiInstrument = "pad 1 (new age)" \melody
      \set Staff.midiInstrument = "pad 2 (warm)" \melody
      \set Staff.midiInstrument = "pad 3 (polysynth)" \melody
      \set Staff.midiInstrument = "pad 4 (choir)" \melody
      \set Staff.midiInstrument = "pad 5 (bowed)" \melody
      \set Staff.midiInstrument = "pad 6 (metallic)" \melody
      \set Staff.midiInstrument = "pad 7 (halo)" \melody
      \set Staff.midiInstrument = "pad 8 (sweep)" \melody
      \set Staff.midiInstrument = "fx 1 (rain)" \melody
      \set Staff.midiInstrument = "fx 2 (soundtrack)" \melody
      \set Staff.midiInstrument = "fx 3 (crystal)" \melody
      \set Staff.midiInstrument = "fx 4 (atmosphere)" \melody
      \set Staff.midiInstrument = "fx 5 (brightness)" \melody
      \set Staff.midiInstrument = "fx 6 (goblins)" \melody
      \set Staff.midiInstrument = "fx 7 (echoes)" \melody
      \set Staff.midiInstrument = "fx 8 (sci-fi)" \melody
      \set Staff.midiInstrument = "sitar" \melody
      \set Staff.midiInstrument = "banjo" \melody
      \set Staff.midiInstrument = "shamisen" \melody
      \set Staff.midiInstrument = "koto" \melody
      \set Staff.midiInstrument = "kalimba" \melody
      \set Staff.midiInstrument = "bagpipe" \melody
      \set Staff.midiInstrument = "fiddle" \melody
      \set Staff.midiInstrument = "shanai" \melody
      \set Staff.midiInstrument = "tinkle bell" \melody
      \set Staff.midiInstrument = "agogo" \melody
      \set Staff.midiInstrument = "steel drums" \melody
      \set Staff.midiInstrument = "woodblock" \melody
      \set Staff.midiInstrument = "taiko drum" \melody
      \set Staff.midiInstrument = "melodic tom" \melody
      \set Staff.midiInstrument = "synth drum" \melody
      \set Staff.midiInstrument = "reverse cymbal" \melody
      \set Staff.midiInstrument = "guitar fret noise" \melody
      \set Staff.midiInstrument = "breath noise" \melody
      \set Staff.midiInstrument = "seashore" \melody
      \set Staff.midiInstrument = "bird tweet" \melody
      \set Staff.midiInstrument = "telephone ring" \melody
      \set Staff.midiInstrument = "helicopter" \melody
      \set Staff.midiInstrument = "applause" \melody
      \set Staff.midiInstrument = "gunshot" \melody
    }
  >>
  \midi { }
}

\paper { tagline = ##f }

[image of music]


Replacing default MIDI instrument equalization

The default MIDI instrument equalizer can be replaced by setting the instrumentEqualizer property in the Score context to a user-defined Scheme procedure that uses a MIDI instrument name as its argument along with a pair of fractions indicating the minimum and maximum volumes respectively to be applied to that specific instrument.

The following example sets the minimum and maximum volumes for flute and clarinet respectively."

#(define my-instrument-equalizer-alist '())

#(set! my-instrument-equalizer-alist
  (append
    '(
      ("flute" . (0.7 . 0.9))
      ("clarinet" . (0.3 . 0.6)))
    my-instrument-equalizer-alist))

#(define (my-instrument-equalizer s)
  (let ((entry (assoc s my-instrument-equalizer-alist)))
    (if entry
      (cdr entry))))

\score {
  <<
    \new Staff {
      \key g \major
      \time 2/2
      \set Score.instrumentEqualizer = #my-instrument-equalizer
      \set Staff.midiInstrument = "flute"
      \new Voice \relative {
        r2 g''\mp g fis~
        4 g8 fis e2~
        4 d8 cis d2
      }
    }
    \new Staff {
      \key g \major
      \set Staff.midiInstrument = "clarinet"
      \new Voice \relative {
        b'1\p a2. b8 a
        g2. fis8 e
        fis2 r
      }
    }
  >>
  \layout { }
  \midi {  }
}

[image of music]


Templates


Plantilla per a notació de música antiga (transcripció moderna de cant gregorià)

Aquest exemple mostra com fer una transcripció moderna de cant gregorià. El cant gregorià no té compàs ni pliques; utilitza sols caps de nota de blanca i de negra, i unes marques especials que indiquen silencis de diferents longituds.

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 GregorianTranscriptionStaff <<
    \new GregorianTranscriptionVoice = "melody" \chant
    \new GregorianTranscriptionLyrics = "one" \lyricsto melody \verba
  >>
}

[image of music]


Plantilla de salm del cant anglicà

Aquesta plantilla mostra una forma de preparar un càntic salmòdic anglicà. També mostra com es poden afegir estrofes addicionals com text independent per sota de la música. Les dues estrofes es codifiquen en estils diferents per il·lustrar més possibilitats.

\paper { tagline = ##f }

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 =
                      \musicLength 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.
        }
      }
    }
  }
}

[image of music]


Plantilla per a himnes

Aquest fragment de codi mostra una forma de preparar un himne quan cada línia comença amb un compàs parcial. També mostra com afegir els versos com a text independent a sota de la música.

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

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

\layout {
  \context {
    \Score
    caesuraType = #'((bar-line . "||"))
    fineBarType = "||"
  }
}

\paper {  % Start paper block
  indent = 0     % don't indent first system
  line-width = 130   % shorten line length to suit music
  tagline = ##f % Don't print tag line, can be removed
}  % End paper block

[image of music]


Plantilla per a combo de jazz

Això és una plantilla força avançada, per a un conjunt de jazz. Observeu que la notació de tots els instruments està a \key c \major (Do major). Això es refereix al to de concert; l’armadura es transporta automàticament si la música està dins d’una secció \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 { }
}

[image of music]


Plantilla d’orquestra amb cor i piano

Aquesta plantilla mostra l’ús de contextos StaffGroup i GrandStaff niuats per sub-agrupar instruments del mateix tipus, i una forma d’usar \transpose de manera que unes variables continguin la música per a instruments transpositors en afinació de concert.

#(set-global-staff-size 17)

\paper {
  indent = 3.0\cm  % add space for instrumentName
  short-indent = 1.5\cm  % add less space for shortInstrumentName
}

\header { tagline = ##f }


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

[image of music]


Plantilla de piano (senzilla)

Presentem a continuació una plantilla de piano senzilla amb algunes 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 { }
}

[image of music]


Plantilla de piano amb lletra centrada

En comptes de tenir un pentagrama dedicat a la melodia i la lletra, la lletra es pot centrar entre els pentagrames d’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 { }
}

[image of music]


Plantilla de piano amb melodia i lletra

Vet aquí el típic format d’una cançó: un pentagrama amb la melodia i la lletra, i el acompanyament de piano per sota.

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

[image of music]


Plantilla de cor SATB, a quatre pentagrames

Plantilla de cor SATB (en quatre pentagrames)

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

[image of music]


Partitura per acordió diatònic

Plantilla per escriure una partitura per a acordió diatònic.

- Hi ha una pauta horitzontal que indica si l’acordió s’ha de tancar (línia gruixuda) o obrir (línia prima).

- Hi ha una pauta rítmica petita amb lletra que descriu els botons que cal polsar en el baix. Les barres de compàs estan fetes a partir de línies de reixeta.

- La pauta del tabulador per acordions diatònics mostra la posició geogràfica dels botons i no (com a d’altres instruments) l’alçada de les notes; les claus sobre el costat de la melodia de l’acordió es posen en tres columnes i unes dotze files.

A la notació de la pauta del tabulador, la columna més externa es descriu amb notes entre línies, la columna més interna es descriu amb notes entre línies i unes aspes com a alteració accidental, i la columna central es descriu amb notes sobre una línia, mentre que la fila del mig es representa sobre la línia central del pentagrama.

A continuació algunes notes sobre la forma de transcriure notes de piano a acordió diatònic:

1. Tot acordió diatònic està construït sols per a un cert conjunt de tonalitats (per exemple, per a les tonalitats de Do major i Fa major), per la qual cosa és important transportar una melodia de piano que correspongui exactament a una d’aquestes tonalitats. Transporteu el codi font, no sols la sortida perquè aquest codi cal després per traduir-lo de nou a la pauta del tabulador. Això es pot fer amb l’ordre displayLilyMusic.

2. Hem d’alterar les direccions d’obrir i de tancar el fuelle de forma regular. Si l’intèrpret té un període d’obrir el fuelle excessivament llarg, l’acordió pot trencar-se. Per una altra banda, algunes harmonies sols estan disponibles en una direcció. Tenint això en compte, hem de decidir quines parts de la melodia són les parts de tancar i quines les d’obrir.

3. Per a cada una de les parts d’obrir i tancar, transcriviu les notes del piano a la representació de tabulatura corresponent.

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
}


\header { tagline = ##f }

\layout {
  \context {
    \Score
    % The vertical line (simulating a bar-line) in
    % the staffBassRhythm is a gridline
    \consists "Grid_line_span_engraver"
  }
  \context {
    \Staff
    \consists "Grid_point_engraver"
    gridInterval = \musicLength 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
}

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

staffBassRhythm =
\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 = "VoiceBassRhythm"
    \stemDown \AltOn #0.6
    \relative c''
    {
      \BassRhythm
    }
    \AltOff
    \bar "|."
  }
}

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

[image of music]


Plantilla de pentagrama únic amb música, lletra i acords

Aquesta plantilla facilita la preparació d’una cançó amb melodia, lletra i acords.

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

[image of music]


Plantilla per a un pentagrama únic amb música, lletra, acords i trastos

A continuació presentem un exemple de plantilla per a un full guia d’acords amb melodia, lletra, acords i diagrama de trastos.

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

[image of music]


Plantilla de pentagrama únic amb música i acords

Voleu preparar un full guia d’acords (o «lead sheet») amb melodia i acords? No busqueu 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 { }
}

[image of music]


Plantilla de pentagrama únic amb notes i lletra

Aquesta petita plantilla mostra una melodia senzilla amb lletra. Talleu-la i pegueu-la, escriviu les notes i després la lletra. Aquest exemple desactiva el barrat automàtic, que és el més freqüent a les parts vocals antigues. Per usar el barrat automàtic modifiqueu o marqueu com un comentari la línia corresponent.

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

[image of music]


Plantilla d’un sol pentagrama, amb notes únicament

Aquesta plantilla senzilla prepara un pentagrama amb notes, adequat per a un instrument solista o un fragment melòdic. Talleu-lo i pegueu-lo a un fitxer, escriviu les notes, i ja està!

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

  a4 b c d
}

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

[image of music]


Plantilla de quartet de cordas (senzilla)

Aquesta plantilla mostra un quartet de corda normal. També utilitza una secció \global per al compàs i l’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 { }
}

[image of music]


Plantilla de quartet de corda amb particel·les independents

El fragment de codi “Plantilla de quartet de corda” produeix un resultat satisfactori per al quartet, però, i si hem d’imprimir les particel·les? Aquesta nova plantilla mostra com usar la funcionalitat \tag (etiqueta) per dividir fàcilment una peça en particel·les individuals.

Hem de dividir aquesta plantilla en fitxers independents; els noms de fitxer estan dins dels comentaris al principi de cada fitxer. piece.ly conté totes les definicions de música. Els altres fitxers (score.ly, vn1.ly, vn2.ly, vla.ly i vlc.ly) produeixen la particel·la corresponent.

No oblideu treure els comentaris que hem especificat quan useu els fitxers independents!

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

%}

[image of music]


Plantilla de conjunt vocal

Vet aquí una partitura vocal estàndard per a quatre veus SATB. Amb grups més grans, sol ser útil incloure una secció que aparegui a totes les parts. Per exemple, el compàs i l’armadura gairebé sempre son els mateixos per a totes. Com a la plantilla “Himne”, les quatre veus es reagrupen en sols dos pentagrames.

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

[image of music]


Plantilla de conjunt vocal amb reducció de piano automàtica

Aquesta plantilla afegeix una reducció de piano automàtica a la partitura vocal SATB estàndard que es va mostrar a la “Plantilla de conjunt vocal”. Això presenta un dels punts forts del LilyPond: podem usar una definició de música més d’un cop. Si es fa qualsevol canvi a les notes de la part vocal (diguem tenorMusic), aleshores els canvis s’aplicaran també a la reducció 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 >>
      >>
    >>
  >>
}

[image of music]


Plantilla per a conjunt amb lletres alineades a sobre i a sota dels pentagrames

Aquesta plantilla és, bàsicament, la mateixa que la senzilla plantilla “Conjunt vocal”, excepte que aquí totes les línies de lletra es col·loquen utilitzant alignAboveContext i 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
  >>
}

[image of music]


Estrofa per a solista i tornada a dues veus

Aquesta plantilla crea una partitura que comença amb una estrofa per a solista i continua amb una tornada a dues veus. També mostra l’ús de silencis de separació dins de la variable \global per definit canvis de compàs (i altres exemple que són comuns a totes les parts) al llarg de tota la partitura.

\header { tagline = ##f }

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

[image of music]


Table of Contents


Fragments del LilyPond v2.25.14 (branca de desenvolupament).