These snippets illustrate the Notation Reference, section Expressive marks.
LilyPond syntax can involve many unusual placements for parentheses, brackets etc., which might sometimes have to be interleaved. For example, when entering a manual beam, the left square bracket has to be placed after the starting note and its duration, not before. Similarly, the right square bracket should directly follow the note which is to be at the end of the requested beaming, even if this note happens to be inside a tuplet section. This snippet demonstrates how to combine manual beaming, manual slurs, ties and phrasing slurs with tuplet sections (enclosed within curly braces).
{ r16[ g16 \times 2/3 { r16 e'8] } g16( a \times 2/3 { b d e') } g8[( a \times 2/3 { b d') e']~ } \time 2/4 \times 4/5 { e'32\( a b d' e' } a'4.\) }
The \parenthesize
function is a special tweak that encloses
objects in parentheses. The associated grob is
Score.ParenthesesItem
.
\relative c' { c2-\parenthesize -> \override ParenthesesItem #'padding = #0.1 \override ParenthesesItem #'font-size = #-4 <d \parenthesize fis a>2 }
The shortest-duration-space
property may have to be tweaked to
adjust the shape of falls and doits.
\relative c'' { \override Score.SpacingSpanner #'shortest-duration-space = #4.0 c2-\bendAfter #+5 c2-\bendAfter #-3 c2-\bendAfter #+8 c2-\bendAfter #-6 }
In order to make parts of a crescendo hairpin invisible, the following method is used: A white rectangle is drawn on top of the respective part of the crescendo hairpin, making it invisible. The rectangle is defined as postscript code within a text markup.
To fine-tune the position and size of the markup, the number
preceding setgray
in the postscript definition can be set to a
value less than one, making it grey. The two numbers before scale
in the postscript code are responsible for the width and height of the
rectangle, the two numbers before translate
change the x- and
y-origin of the rectangle.
Make sure to put the hairpin in a lower layer than the text markup to draw the rectangle over the hairpin.
\relative c' { << { \dynamicUp \override DynamicLineSpanner #'staff-padding = #4 r2 r16 c'8.\pp r4 } \\ { \override DynamicLineSpanner #'layer = #0 des,2\mf\< ~ \override TextScript #'layer = #2 des16_\markup { \postscript #"1.9 -8 translate 5 4 scale 1 setgray 0 0 moveto 0 1 lineto 1 1 lineto 1 0 lineto 0 0 lineto fill" } r8. des4 ~ des16->\sff } >> }
A caesura is sometimes denoted with a double "railtracks" breath mark with a fermata sign positioned above. This snippet should present an optically pleasing combination of railtracks and a fermata.
{ c''2. % construct the symbol \override BreathingSign #'text = \markup { \line { \musicglyph #"scripts.caesura.curved" \translate #'(-1.75 . 1.6) \musicglyph #"scripts.ufermata" } } \breathe c''4 % set the breathe mark back to normal \revert BreathingSign #'text c''2. \breathe c''4 \bar "|." }
This example provides a function to typeset a hairpin (de)crescendo with some additional text below it, such as "molto" or "poco". The example also illustrates how to modify the way an object is normally printed, using some Scheme code.
hairpinWithCenteredText = #(define-music-function (parser location text) (markup?) #{ \override Voice.Hairpin #'stencil = #(lambda (grob) (ly:stencil-aligned-to (ly:stencil-combine-at-edge (ly:stencil-aligned-to (ly:hairpin::print grob) X CENTER) Y DOWN (ly:stencil-aligned-to (ly:text-interface::print grob) X CENTER)) X LEFT)) \override Voice.Hairpin #'text = $text #}) hairpinMolto = \hairpinWithCenteredText \markup { \italic molto } hairpinMore = \hairpinWithCenteredText \markup { \bigger moltissimo } \layout { ragged-right = ##f } { \hairpinMolto c'2\< c'\f \hairpinMore c'2\< c'\f }
To make the \flageolet
circle smaller use the following Scheme
function.
smallFlageolet = #(let ((m (make-music 'ArticulationEvent 'articulation-type "flageolet"))) (set! (ly:music-property m 'tweaks) (acons 'font-size -3 (ly:music-property m 'tweaks))) m) \layout { ragged-right = ##f } \relative c'' { d4^\flageolet_\markup { default size } d_\flageolet c4^\smallFlageolet_\markup { smaller } c_\smallFlageolet }
The text used for crescendos and decrescendos can be
changed by modifying the context properties crescendoText
and decrescendoText
. The style of the spanner line can
be changed by modifying the 'style
property of
DynamicTextSpanner
. The default value is
'hairpin
, and other possible values include
'line
, 'dashed-line
, and
'dotted-line
:
\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 }
The appearance of slurs may be changed from solid to dotted or dashed.
\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) }
The glyph of the breath mark can be tuned by overriding the text
property of the BreathingSign
layout object with any markup
text.
\relative c'' { c2 \override BreathingSign #'text = \markup { \musicglyph #"scripts.rvarcomma" } \breathe d2 }
Some dynamics may involve text indications (such as "più forte" or
"piano subito"). They can be produced using a \markup
block.
piuF = \markup { \italic più \dynamic f } \layout { ragged-right = ##f } \relative c'' { c2\f c-\piuF }
A contemporary glissando without a final note can be typeset using a hidden note and cadenza timing.
\relative c'' { \time 3/4 \override Glissando #'style = #'zigzag c4 c \cadenzaOn c4\glissando \hideNotes c,,4 \unHideNotes \cadenzaOff \bar "|" }
The vertical ordering of scripts is controlled with the
script-priority
property. The lower this number, the closer it
will be put to the note. In this example, the TextScript
(the
sharp symbol) first has the lowest priority, so it is put lowest in the
first example. In the second, the prall trill (the Script
) has
the lowest, so it is on the inside. When two objects have the same
priority, the order in which they are entered determines which one
comes first.
\relative c''' { \once \override TextScript #'script-priority = #-100 a2^\prall^\markup { \sharp } \once \override Script #'script-priority = #-100 a2^\prall^\markup { \sharp } }
An arpeggio can be drawn across notes in different voices on the same
staff if the Span_arpeggio_engraver
is moved to the Staff
context:
\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 } >> }
In a PianoStaff
, it is possible to let an arpeggio cross between
the staves by setting the property 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 } } >>
Cross-staff arpeggios can be created in contexts other than
PianoStaff
if the Span_arpeggio_engraver
is included in
the Score
context.
\score { \new StaffGroup { \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" } } }
Although the easiest way to add parentheses to a dynamic mark is to use
a \markup
block, this method has a downside: the created
objects will behave like text markups, and not like dynamics.
However, it is possible to create a similar object using the equivalent
Scheme code (as described in "Markup programmer interface"), combined
with the make-dynamic-script
function. This way, the markup will
be regarded as a dynamic, and therefore will remain compatible with
commands such as \dynamicUp
or \dynamicDown
.
\paper { ragged-right = ##t } parenF = #(make-dynamic-script (markup #:line (#:normal-text #:italic #:fontsize 2 "(" #:hspace -0.8 #:dynamic "f" #:normal-text #:italic #:fontsize 2 ")" ))) \relative c'' { c4\parenF c c \dynamicUp c\parenF }
Unlike text scripts, rehearsal marks cannot be stacked at a particular point
in a score: only one RehearsalMark
object is created. Using an
invisible measure and bar line, an extra rehearsal mark can be added, giving
the appearance of two marks in the same column.
This method may also prove useful for placing rehearsal marks at both the end of one system and the start of the following system.
{ \key a \major \set Score.markFormatter = #format-mark-box-letters \once \override Score.RehearsalMark #'outside-staff-priority = #5000 \once \override Score.RehearsalMark #'self-alignment-X = #LEFT \once \override Score.RehearsalMark #'break-align-symbols = #'(key-signature) \mark \markup { \bold { Senza denti } } % the hidden measure and bar line \once \override Score.TimeSignature #'stencil = ##f \time 1/16 s16 \bar "" \time 4/4 \once \override Score.RehearsalMark #'self-alignment-X = #LEFT \once \override Score.RehearsalMark #'break-align-symbols = #'(bar-line) \mark \markup { \box \bold Intro } d'1 \mark \default d'1 }
In some situations, it may be necessary to create slurs between notes from different voices.
The solution is to add invisible notes to one of the voices, using
\hideNotes
.
This example is measure 235 of the Ciaconna from Bach's 2nd Partita for solo violin, BWV 1004.
\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) } >> }
The \startTextSpan
and \stopTextSpan
commands allow the
creation of text spanners as easily as pedal indications or
octavations. Override some properties of the TextSpanner
object
to modify its output.
\relative c'' { \override TextSpanner #'edge-text = #'("bla" . "blu") a \startTextSpan b c a \stopTextSpan \override TextSpanner #'dash-period = #2 \override TextSpanner #'dash-fraction = #0.0 a \startTextSpan b c a \stopTextSpan \revert TextSpanner #'style \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) } a \startTextSpan b c a \stopTextSpan \set Staff.middleCPosition = #-13 \override TextSpanner #'dash-period = #10 \override TextSpanner #'dash-fraction = #0.5 \override TextSpanner #'thickness = #10 a \startTextSpan b c a \stopTextSpan \set Staff.middleCPosition = #-6 }
Text style dynamic changes (such as cresc. and dim.) are printed with a dashed line showing their extent. This line can be suppressed in the following way:
\relative c'' { \override DynamicTextSpanner #'dash-period = #-1.0 \crescTextCresc c1\< | d | b | c\! }
Some dynamic expressions involve additional text, like "sempre pp". Since lilypond aligns all dynamics centered on the note, the \pp would be displayed way after the note it applies to.
To correctly align the "sempre \pp" horizontally, so that it is aligned as if it were only the \pp, there are several approaches:
* Simply use \once\override DynamicText #'X-offset = #-9.2
before the note with the dynamics to manually shift it to the correct
position. Drawback: This has to be done manually each time you use that
dynamic markup... * Add some padding (#:hspace 7.1
) into the
definition of your custom dynamic mark, so that after lilypond
center-aligns it, it is already correctly aligned. Drawback: The
padding really takes up that space and does not allow any other markup
or dynamics to be shown in that position.
* Shift the dynamic script \once\override ... #'X-offset = ..
.
Drawback: \once\override
is needed for every invocation!
* Set the dimensions of the additional text to 0 (using
#:with-dimensions '(0 . 0) '(0 . 0)
). Drawback: To lilypond
"sempre" has no extent, so it might put other stuff there and create
collisions (which are not detected by the collision dection!). Also,
there seems to be some spacing, so it's not exactly the same alignment
as without the additional text
* Add an explicit shifting directly inside the scheme function for the dynamic-script.
* Set an explicit alignment inside the dynamic-script. By default, this
won't have any effect, only if one sets X-offset! Drawback: One needs
to set DynamicText #'X-offset
, which will apply to all dynamic
texts! Also, it is aligned at the right edge of the additional text,
not at the center of pp.
\header { title = "Horizontally aligning custom dynamics" } \layout { ragged-right = ##t } % 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 and 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 to 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 (cons -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"))) \context StaffGroup << \context Staff="s" << \set Staff.instrumentName = "Normal" \relative c'' { \key es \major c4\pp c\p c c | c\ff c c\pp c } >> \context Staff="sMarkup" << \set Staff.instrumentName = \markup\column{"Normal" "Markup"} \relative c'' { \key es \major c4-\semppMarkup c\p c c | c\ff c c-\semppMarkup c} >> \context Staff="sK" << \set Staff.instrumentName = \markup\column{"Explicit" "shifting"} \relative c'' { \key es \major \once \override DynamicText #'X-offset = #-9.2 c4\semppK c\p c c | c\ff c \once \override DynamicText #'X-offset = #-9.2 c\semppK c } >> \context Staff="sT" << \set Staff.instrumentName = \markup\column{"Right" "padding"} \relative c'' { \key es \major c4\semppT c\p c c | c\ff c c\semppT c } >> \context Staff="sM" << \set Staff.instrumentName = \markup\column{"Setting" "dimension" "to zero"} \relative c'' { \key es \major c4\semppM c\p c c | c\ff c c\semppM c } >> \context Staff="sG" << \set Staff.instrumentName = \markup\column{"Shifting" "inside" "dynamics"} \relative c'' { \key es \major c4\semppG c\p c c | c\ff c c\semppG c} >> \context Staff="sMII" << \set Staff.instrumentName = \markup\column{"Alignment" "inside" "dynamics"} \relative c'' { \key es \major \override DynamicText #'X-offset = #0 % Setting to ##f (false) gives the same resul c4\semppMII c\p c c | c\ff c c\semppMII c } >> >>
Caesura marks can be created by overriding the 'text
property of the BreathingSign
object. A curved caesura
mark is also available.
\relative c'' { \override BreathingSign #'text = #(make-musicglyph-markup "scripts.caesura.straight") c8 e4. \breathe g8. e16 c4 \override BreathingSign #'text = #(make-musicglyph-markup "scripts.caesura.curved") g8 e'4. \breathe g8. e16 c4 }
Laissez vibrer ties have a fixed size. Their formatting can be tuned
using '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 }
Arrows can be applied to text-spanners and line-spanners (such as the Glissando).
\relative c'' { \override TextSpanner #'bound-padding = #1.0 \override TextSpanner #'dash-fraction = #'() \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 }
The shorthands are defined in ‘ly/script-init.ly’, where the
variables dashHat
, dashPlus
, dashDash
,
dashBar
, dashLarger
, dashDot
, and
dashUnderscore
are assigned default values. The default values
for the shorthands can be modified. For example, to associate the
-+
(dashPlus
) shorthand with the trill symbol instead of
the default + symbol, assign the value trill
to the variable
dashPlus
:
\relative c'' { c1-+ } dashPlus = "trill" \relative c'' { c1-+ }
Many piano scores have the dynamics centered between the two staves. This requires a bit of tweaking to implement, but since the template is right here, you don't have to do the tweaking yourself.
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 } dynamics = { s2\fff\> s4 s\!\pp } pedal = { s2\sustainOn s\sustainOff } \score { \new PianoStaff << \new Staff = "upper" \upper \new Dynamics = "dynamics" \dynamics \new Staff = "lower" << \clef bass \lower >> \new Dynamics = "pedal" \pedal >> \layout { \context { \type "Engraver_group" \name Dynamics % So that \cresc works, for example. \alias Voice \consists "Output_property_engraver" \override VerticalAxisGroup #'minimum-Y-extent = #'(-1 . 1) \override DynamicLineSpanner #'Y-offset = #0 pedalSustainStrings = #'("Ped." "*Ped." "*") pedalUnaCordaStrings = #'("una corda" "" "tre corde") \consists "Piano_pedal_engraver" \consists "Script_engraver" \consists "Dynamic_engraver" \consists "Text_engraver" \override TextScript #'font-size = #2 \override TextScript #'font-shape = #'italic \consists "Skip_event_swallow_translator" \consists "Axis_group_engraver" } \context { \PianoStaff \accepts Dynamics } } } \score { \new PianoStaff << \new Staff = "upper" << \upper \dynamics \pedal >> \new Staff = "lower" << \lower \dynamics \pedal >> >> \midi { } }
Hairpins may be printed with a circled tip (al niente notation) by
setting the circled-tip
property of the Hairpin
object to
#t
.
\relative c'' { \override Hairpin #'circled-tip = ##t c2\< c\! c4\> c\< c2\! }
By default, metronome and rehearsal marks are printed above the staff.
To place them below the staff simply set the direction
property
of MetronomeMark
or RehearsalMark
appropriately.
\layout { 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 }
If the note which ends a hairpin falls on a downbeat,
the hairpin stops at the bar line immediately preceding. This behavior
can be controlled by overriding the to-barline
property.
\relative c'' { e4\< e2. e1\! \override Hairpin #'to-barline = ##f e4\< e2. e1\! }
If hairpins are too short, they can be lengthened by modifying the
minimum-length
property of the Hairpin
object.
\relative c'' { c4\< c\! d\> e\! \override Hairpin #'minimum-length = #5 << f1 { s4 s\< s\> s\! } >> }
Some composers write two slurs when they want legato chords. This can
be achieved by setting doubleSlurs
.
\relative c' { \set doubleSlurs = ##t <c e>4( <d f> <c e> <d f>) }
Dynamics that occur at, begin on, or end on the same note will be
vertically aligned. To ensure that dynamics are aligned when they do
not occur on the same note, increase the staff-padding
property
of the DynamicLineSpanner
object.
\relative c' { \override DynamicLineSpanner #'staff-padding = #4 c2\p f\mf g2\< b4\> c\! }
This page is for LilyPond-2.11.58 (development-branch).
Report errors to http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs.
Your suggestions for the documentation are welcome.