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 = #(ly:make-moment 1/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.

\relative c'{
  \set Score.alternativeNumberingStyle = #'numbers
  \repeat volta 3 { c4 d e f | }
    \alternative {
      { c4 d e f | c2 d \break }
      { f4 g a b | f4 g a b | f2 a | \break }
      { c4 d e f | c2 d }
    }
  c1 \break
  \set Score.alternativeNumberingStyle = #'numbers-with-letters
  \repeat volta 3 { c,4 d e f | }
    \alternative {
      { c4 d e f | c2 d \break }
      { f4 g a b | f4 g a b | f2 a | \break }
      { c4 d e f | c2 d }
    }
  c1
}

[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))))))
#})

\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 = #(ly:make-moment 1/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 = #(ly:make-moment 1/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
}

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

parallelogram =
  #(ly:make-stencil (list 'embedded-ps
    "gsave
      currentpoint translate
      newpath
      0 0.25 moveto
      1.3125 0.75 lineto
      1.3125 -0.25 lineto
      0 -0.75 lineto
      closepath
      fill
      grestore" )
    (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]


LilyPond — Fragments v2.23.82 (branca de desenvolupament).