Editorial annotations

Editorial annotations


Adding fingerings to a score

Fingering instructions can be entered using a simple syntax.

\relativec''{
c4-1d-2f-4e-3
}

[image of music]


Adding links to objects

To add a link to a grob stencil you can use add-link as defined here. It works both with \override and \tweak.

Drawback: point-and-click is disturbed for the linked grobs.

Limitation: Works for PDF only.

The linked objects are colored with a separate command. Note that the links are not displayed and are not clickable from inside the LSR.

#(define(add-linkurl-strg)
(lambda(grob)
(let*((stil(ly:grob-propertygrob'stencil)))
(if(ly:stencil?stil)
(let*((x-ext(ly:stencil-extentstilX))
(y-ext(ly:stencil-extentstilY))
(url-expr`(url-link,url-strg,x-ext,y-ext))
(new-stil
(ly:stencil-add
(ly:make-stencilurl-exprx-exty-ext)
stil)))
(ly:grob-set-property!grob'stencilnew-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.
#(definemajor.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)
\relativec'{
\keycis\minor
\once\overrideStaff.Clef.color=#green
\once\overrideStaff.Clef.after-line-breaking=
#(add-linkurlI)
\once\overrideStaff.TimeSignature.color=#green
\once\overrideStaff.TimeSignature.after-line-breaking=
#(add-linkurlII)
\once\overrideNoteHead.color=#green
\once\overrideNoteHead.after-line-breaking=
#(add-linkurlIII)
cis'1
\once\overrideBeam.color=#green
\once\overrideBeam.after-line-breaking=
#(add-linkurlIV)
cis8disefisgis2
<gis,
\tweakAccidental.color#green
\tweakAccidental.after-line-breaking#(add-linkurlVI)
\tweakcolor#green
\tweakafter-line-breaking#(add-linkurlV)
\tweakstyle#'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={r4r8<gc'>qr8r4}
low={c4r4c8r8g,8b,}
pulse={s8^"1"s^"&"s^"2"s^"&"s^"3"s^"&"s^"4"s^"&"}
\score{
\newTabStaff{
\repeatunfold2<<\high\\\low\\\pulse>>
}
\layout{
\context{
\TabStaff
\clefmoderntab
\revertTextScript.stencil
\overrideTextScript.font-series=#'bold
\overrideTextScript.font-size=#-2
\overrideTextScript.color=#red
}
\context{
\Score
proportionalNotationDuration=#(ly:make-moment1/8)
}
}
}

[image of music]


Allowing fingerings to be printed inside the staff

By default, vertically oriented fingerings are positioned outside the staff; that behavior, however, may be disabled. Attention needs to be paid to situations where fingerings and stems are in the same direction: by default, fingerings will avoid only beamed stems. That setting can be changed to avoid no stems or all stems; the following example demonstrates these two options, as well as how to go back to the default behavior.

\relativec'{
<c-1e-2g-3b-5>2
\overrideFingering.staff-padding=#'()
<c-1e-2g-3b-5>4g'-0
a8[-1b]-2g-0r
\overrideFingering.add-stem-support=##f
a[-1b]-2g-0r
\overrideFingering.add-stem-support=##t
a[-1b]-2g-0r
\overrideFingering.add-stem-support=#only-if-beamed
a[-1b]-2g-0r
}

[image of music]


Alternative bar numbering

Two alternative methods for bar numbering can be set, especially for when using repeated music.

\relativec'{
\setScore.alternativeNumberingStyle=#'numbers
\repeatvolta3{c4def|}
\alternative{
{c4def|c2d\break}
{f4gab|f4gab|f2a|\break}
{c4def|c2d}
}
c1\break
\setScore.alternativeNumberingStyle=#'numbers-with-letters
\repeatvolta3{c,4def|}
\alternative{
{c4def|c2d\break}
{f4gab|f4gab|f2a|\break}
{c4def|c2d}
}
c1
}

[image of music]


Analysis brackets above the staff

Simple horizontal analysis brackets are added below the staff by default. The following example shows a way to place them above the staff instead.

\layout{
\context{
\Voice
\consists"Horizontal_bracket_engraver"
}
}
\relativec''{
\once\overrideHorizontalBracket.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"
\overrideHorizontalBracket.direction=#UP
}
}
{
\once\overrideHorizontalBracketText.text="a"
c''\startGroupd''\stopGroup
\once\overrideHorizontalBracketText.text="a'"
e''\startGroupd''\stopGroup|
c''-\tweakHorizontalBracketText.text
\markup\bold\huge"b"\startGroup
-\tweakHorizontalBracketText.text"a"\startGroup
d''\stopGroup
e''-\tweakHorizontalBracketText.text"a'"\startGroup
d''\stopGroup\stopGroup|
c''-\tweakHorizontalBracketText.textfoo\startGroup
d''e''f''|\break
g''a''b''c'''\stopGroup
}

[image of music]


Applying note head styles depending on the step of the scale

The shapeNoteStyles property can be used to define various note head styles for each step of the scale (as set by the key signature or the tonic property).

This property requires a set of symbols, which can be purely arbitrary (geometrical expressions such as triangle, cross, and xcircle are allowed) or based on old American engraving tradition (some latin note names are also allowed).

That said, to imitate old American song books, there are several predefined note head styles available through shortcut commands such as \aikenHeads or \sacredHarpHeads.

This example shows different ways to obtain shape note heads, and demonstrates the ability to transpose a melody without losing the correspondence between harmonic functions and note head styles.

fragment={
\keyc\major
c2d
e2f
g2a
b2c
}
\newStaff{
\transposecd
\relativec'{
\setshapeNoteStyles=##(doremifa
#flati)
\fragment
}
\break
\relativec'{
\setshapeNoteStyles=##(crosstrianglefa#f
mensuralxcirclediamond)
\fragment
}
}

[image of music]


Blanking staff lines using the \whiteout command

The \whiteout command underlays a markup with a white box. Since staff lines are in a lower layer than most other grobs, this white box will not overlap any other grob.

\layout{
ragged-right=##f
}
\relativec'{
\overrideTextScript.extra-offset=#'(2.4)
c2-\markup{\whiteout\pad-markup#0.5"middle C"}c
}

[image of music]


Changing a single note’s size in a chord

Individual note heads in a chord can be modified with the \tweak command inside a chord, by altering the font-size property.

Inside the chord (within the brackets < >), before the note to be altered, place the \tweak command, followed by font-size and define the proper size like #-2 (a tiny note head).

\relativec'{
<\tweakfont-size#+2cegc
\tweakfont-size#-2e>1
^\markup{Atinye}_\markup{Abigc}
}

[image of music]


Changing the appearance of a slur from solid to dotted or dashed

The appearance of slurs may be changed from solid to dotted or dashed.

\relativec'{
c4(dec)
\slurDotted
c4(dec)
\slurSolid
c4(dec)
\slurDashed
c4(dec)
\slurSolid
c4(dec)
}

[image of music]


Coloring notes depending on their pitch

It is possible to color note heads depending on their pitch and/or their names: the function used in this example even makes it possible to distinguish enharmonics.

%Association list of pitches to colors.
#(definecolor-mapping
(list
(cons(ly:make-pitch00NATURAL)(x11-color'red))
(cons(ly:make-pitch00SHARP)(x11-color'green))
(cons(ly:make-pitch01FLAT)(x11-color'green))
(cons(ly:make-pitch02NATURAL)(x11-color'red))
(cons(ly:make-pitch02SHARP)(x11-color'green))
(cons(ly:make-pitch03FLAT)(x11-color'red))
(cons(ly:make-pitch03NATURAL)(x11-color'green))
(cons(ly:make-pitch04SHARP)(x11-color'red))
(cons(ly:make-pitch05NATURAL)(x11-color'green))
(cons(ly:make-pitch05FLAT)(x11-color'red))
(cons(ly:make-pitch06SHARP)(x11-color'red))
(cons(ly:make-pitch01NATURAL)(x11-color'blue))
(cons(ly:make-pitch03SHARP)(x11-color'blue))
(cons(ly:make-pitch04FLAT)(x11-color'blue))
(cons(ly:make-pitch05SHARP)(x11-color'blue))
(cons(ly:make-pitch06FLAT)(x11-color'blue))))
%Compare pitch and alteration (not octave).
#(define(pitch-equals?p1p2)
(and
(=(ly:pitch-alterationp1)(ly:pitch-alterationp2))
(=(ly:pitch-notenamep1)(ly:pitch-notenamep2))))
#(define(pitch-to-colorpitch)
(let((color(assocpitchcolor-mappingpitch-equals?)))
(ifcolor
(cdrcolor))))
#(define(color-noteheadgrob)
(pitch-to-color
(ly:event-property(event-causegrob)'pitch)))
\score{
\newStaff\relativec'{
\overrideNoteHead.color=#color-notehead
c8bddiseesfgaes
}
}

[image of music]


Controlling the placement of chord fingerings

The placement of fingering numbers can be controlled precisely. For fingering orientation to apply, it must be used within a chord construct <>, even for single notes. Orientation for string numbers and right-hand fingerings may be set in a similar way.

\relativec'{
\setfingeringOrientations=#'(left)
<c-1e-3a-5>4
\setfingeringOrientations=#'(down)
<c-1e-3a-5>4
\setfingeringOrientations=#'(downrightup)
<c-1e-3a-5>4
\setfingeringOrientations=#'(up)
<c-1e-3a-5>4
\setfingeringOrientations=#'(left)
<c-1>2
\setfingeringOrientations=#'(down)
<e-3>2
\setstringNumberOrientations=#'(upleftdown)
<f3円a2円c1円>1
\setstrokeFingerOrientations=#'(downrightup)
<c\rightHandFinger#1e\rightHandFinger#2c'\rightHandFinger#4>
}

[image of music]


Creating a delayed turn

Creating a delayed turn, where the lower note of the turn uses the accidental, requires several overrides. The outside-staff-priority property must be set to #f, as otherwise this would take precedence over the avoid-slur property. Changing the fraction 2/3 adjusts the horizontal position.

\relativec''{
\after2*2/3\turnc2(d4)r|
\after4\turnc4.(d8)
\after4
{
\once\setsuggestAccidentals=##t
\once\overrideAccidentalSuggestion.outside-staff-priority=##f
\once\overrideAccidentalSuggestion.avoid-slur=#'inside
\once\overrideAccidentalSuggestion.font-size=-3
\once\overrideAccidentalSuggestion.script-priority=-1
\once\hideNotes
cis8\turn\noBeam
}
d4.(e8)
}

[image of music]


Creating blank staves

To create blank staves, generate empty measures then remove the Bar_number_engraver from the Score context, and the Time_signature_engraver, Clef_engraver and Bar_engraver from the Staff context.

#(set-global-staff-size20)
\score{
{
\repeatunfold12{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]


Creating double-digit fingerings

Creating fingerings larger than 5 is possible.

\relativec'{
c1-10
c1-50
c1-36
c1-29
}

[image of music]


Default direction of stems on the center line of the staff

The default direction of stems on the center line of the staff is set by the Stem property neutral-direction.

\relativec''{
a4bcb
\overrideStem.neutral-direction=#up
a4bcb
\overrideStem.neutral-direction=#down
a4bcb
}

[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'
#{
\overrideInstrumentName.after-line-breaking=
#(lambda(grob)
(let*((orig(ly:grob-originalgrob))
(siblings(if(ly:grob?orig)
(ly:spanner-broken-intoorig)
'())))
(if(pair?siblings)
(begin
(ly:grob-set-property!
(carsiblings)
'font-size
(carfont-size-pair))
(for-each
(lambda(g)
(ly:grob-set-property!g'font-size(cdrfont-size-pair)))
(cdrsiblings))))))
#})
\layout{
\context{
\Staff
\InstrumentNameFontSize#'(6.-3)
}
}
\newStaffGroup<<
\newStaff
\with{
instrumentName="Flute"
shortInstrumentName="Fl."
}
{c''1\breakc''\breakc''}
\newStaff
\with{
instrumentName="Violin"
shortInstrumentName="Vl."
}
{c''1\breakc''\breakc''}
>>

[image of music]


Drawing boxes around grobs

The print-function can be overridden to draw a box around an arbitrary grob.

\relativec''{
\overrideTextScript.stencil=
#(make-stencil-boxer0.10.3ly:text-interface::print)
c'4^"foo"
\overrideStem.stencil=
#(make-stencil-boxer0.050.25ly:stem::print)
\overrideScore.RehearsalMark.stencil=
#(make-stencil-boxer0.150.3ly:text-interface::print)
b8
\revertStem.stencil
\revertFlag.stencil
c4.c4
\mark\default
c1
}

[image of music]


Drawing circles around note heads

Here is how to circle a note.

circle=
\once\overrideNoteHead.stencil=#(lambda(grob)
(let*((note(ly:note-head::printgrob))
(combo-stencil(ly:stencil-add
note
(circle-stencilnote0.10.8))))
(ly:make-stencil(ly:stencil-exprcombo-stencil)
(ly:stencil-extentnoteX)
(ly:stencil-extentnoteY))))
{\circlec''}

[image of music]


Drawing circles around various objects

The \circle markup command draws circles around various objects, for example fingering indications. For other objects, specific tweaks may be required: this example demonstrates two strategies for rehearsal marks and measure numbers.

\relativec'{
c1
\setScore.rehearsalMarkFormatter=
#(lambda(markcontext)
(make-circle-markup(format-mark-numbersmarkcontext)))
\mark\default
c2d^\markup{
\override#'(thickness.3){
\circle\finger2
}
}
\overrideScore.BarNumber.break-visibility=#all-visible
\overrideScore.BarNumber.stencil=
#(make-stencil-circler0.10.25ly:text-interface::print)
}

[image of music]


Embedding native PostScript in a \markup block

PostScript code can be directly inserted inside a \markup block.

% PostScript is a registered trademark of Adobe Systems Inc.
\relativec''{
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]


Grid lines: changing their appearance

The appearance of grid lines can be changed by overriding some of their properties.

\score{
\newChoirStaff<<
\newStaff{
\relativec''{
\stemUp
c'4.d8e8fg4
}
}
\newStaff{
\relativec{
% this moves them up one staff space from the default position
\overrideScore.GridLine.extra-offset=#'(0.0.1.0)
\stemDown
\clefbass
\once\overrideScore.GridLine.thickness=#5.0
c4
\once\overrideScore.GridLine.thickness=#1.0
g'4
\once\overrideScore.GridLine.thickness=#3.0
f4
\once\overrideScore.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-moment1/4)
}
\context{
\Score
\consists"Grid_line_span_engraver"
% this moves them to the right half a staff space
\overrideNoteColumn.X-offset=#-0.5
}
}
}

[image of music]


Grid lines: emphasizing rhythms and notes synchronization

Regular vertical lines can be drawn between staves to show note synchronization; however, in case of monophonic music, you may want to make the second stave invisible, and make the lines shorter like in this snippet.

\score{
\newChoirStaff{
\relativec''<<
\newStaff{
\time12/8
\stemUp
c4.d8e8fg4f8e8.d16c8
}
\newStaff{
% hides staff and notes so that only the grid lines are visible
\hideNotes
\hideStaff.BarLine
\overrideStaff.StaffSymbol.line-count=#0
\hideStaff.TimeSignature
\hideStaff.Clef
% dummy notes to force regular note spacing
\once\overrideScore.GridLine.thickness=#4.0
c8cc
\once\overrideScore.GridLine.thickness=#3.0
c8cc
\once\overrideScore.GridLine.thickness=#4.0
c8cc
\once\overrideScore.GridLine.thickness=#3.0
c8cc
}
>>
}
\layout{
\context{
\Score
\consists"Grid_line_span_engraver"
% center grid lines horizontally below note heads
\overrideNoteColumn.X-offset=#-0.5
}
\context{
\Staff
\consists"Grid_point_engraver"
gridInterval=#(ly:make-moment1/8)
% set line length and positioning:
% two staff spaces above center line on hidden staff
% to four spaces below center line on visible staff
\overrideGridPoint.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.

\newTabStaff{
\relativec'{
d4(e2円)
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.

\newTabStaff{
\relativec'{
% chord hammer-on and pull-off
\setdoubleSlurs=##t
<g'b>8(<ac><gb>)
}
}

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

\newTabStaff{
\relativec'{
<<{\voiceOneg2(a)}
\\{\voiceTwoa,(b)}
>>\oneVoice
}
}

[image of music]


Making some staff lines thicker than the others

For educational purposes, a staff line can be thickened (e.g., the middle line, or to emphasize the line of the G clef). This can be achieved by adding extra lines very close to the line that should be emphasized, using the line-positions property of the StaffSymbol object.

{
\overrideStaff.StaffSymbol.line-positions=
#'(-4-2-0.200.224)
d'4e'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={
\overrideStem.stencil=
#(lambda(grob)
(let*((x-parent(ly:grob-parentgrobX))
(is-rest?(ly:grob?(ly:grob-objectx-parent'rest))))
(ifis-rest?
empty-stencil
(ly:stencil-combine-at-edge
(ly:stem::printgrob)
Y
(-(ly:grob-propertygrob'direction))
(grob-interpret-markupgrob
(markup#:center-align#:fontsize-4
#:musicglyph"noteheads.s2cross"))
-2.3))))
}
speakOff={
\revertStem.stencil
\revertFlag.stencil
}
\score{
\newStaff{
\relativec''{
a4bac
\speakOn
g4frg
b4rde
\speakOff
c4agf
}
}
}

[image of music]


Measure counter

This snippet provides a workaround for emitting measure counters using transparent percent repeats.

<<
\contextVoice="foo"{
\clefbass
c4rgr
c4rgr
c4rgr
c4rgr
}
\contextVoice="foo"{
\setcountPercentRepeats=##t
\hidePercentRepeat
\overridePercentRepeatCounter.staff-padding=#1
\repeatpercent4{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
\consistsMeasure_spanner_engraver
}
}
<<
\newStaff\relativec''{
\keyd\minor
R1*2
\tweaktext"Answer"
\startMeasureSpanner
\tuplet3/28{
a16[bc]d[cb]c[de]f[ed]
}
e8agisg
fisfed~dcbe
\stopMeasureSpanner
}
\newStaff\relativec'{
\keyd\minor
\tweaktext"Subject"
\tweakdirection#DOWN
\startMeasureSpanner
\tuplet3/28{
d16[ef]g[fe]f[ga]bes[ag]
}
a8dcisc
bbesag~gfea
\stopMeasureSpanner
\tweaktext"Counter-subject"
\tweakdirection#DOWN
\startMeasureSpanner
f8earr16b,cdefisge
agisabcfis,bagisea4g8
\stopMeasureSpanner
}
>>

[image of music]


Numbering groups of measures

This snippet demonstrates the use of the Measure_counter_engraver to number groups of successive measures. Any stretch of measures may be numbered, whether consisting of repetitions or not.

The engraver must be added to the appropriate context. Here, a Staff context is used; another possibility is a Dynamics context.

The counter is begun with \startMeasureCount and ended with \stopMeasureCount. Numbering will start by default with 1, but this behavior may be modified by overriding the count-from property.

When a measure extends across a line break, the number will appear twice, the second time in parentheses.

\layout{
\context{
\Staff
\consists#Measure_counter_engraver
}
}
\newStaff{
\startMeasureCount
\repeatunfold7{
c'4d'e'f'
}
\stopMeasureCount
\bar"||"
g'4f'e'd'
\overrideStaff.MeasureCounter.count-from=#2
\startMeasureCount
\repeatunfold5{
g'4f'e'd'
}
g'4f'
\bar""
\break
e'4d'
\repeatunfold7{
g'4f'e'd'
}
\stopMeasureCount
}

[image of music]


Positioning fingering indications precisely

Generally the options available for positioning the fingering of chords work well by default, but if one of the indications needs to positioned more precisely the following tweak may be used. This is particularly useful for correcting the positioning when intervals of a second are involved.

\relativec'{
\setfingeringOrientations=#'(left)
<c-1d-2a'-5>4
<c-1d-\tweakextra-offset#'(0.0.2)-2a'-5>4
\setfingeringOrientations=#'(down)
<c-1d-2a'-5>4
<c-\tweakextra-offset#'(0.-1.1)-1
d-\tweakextra-offset#'(-1.2.-1.8)-2a'-5>4
\setfingeringOrientations=#'(downrightup)
<c-1d-\tweakextra-offset#'(-0.3.0)-2a'-5>4
<c-1d-\tweakextra-offset#'(-1.1.2)-2a'-5>4
\setfingeringOrientations=#'(up)
<c-1d-\tweakextra-offset#'(0.1.1)-2
a'-\tweakextra-offset#'(0.1)-5>4
<c-1d-\tweakextra-offset#'(-1.2.1.5)-2
a'-\tweakextra-offset#'(0.1.4)-5>4
}

[image of music]


Positioning text markups inside slurs

Text markups need to have the outside-staff-priority property set to false in order to be printed inside slurs.

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

[image of music]


Printing text from right to left

It is possible to print text from right to left in a markup object, as demonstrated here.

{
b1^\markup{
\line{ingirumimusnocte}
}
f'_\markup{
\override#'(text-direction.-1)
\line{ingirumimusnocte}
}
}

[image of music]


String number extender lines

Make an extender line for string number indications, showing that a series of notes is supposed to be played all on the same string.

stringNumberSpanner=
#(define-music-function(StringNumber)(string?)
#{
\overrideTextSpanner.style=#'solid
\overrideTextSpanner.font-size=#-5
\overrideTextSpanner.bound-details.left.stencil-align-dir-y=#CENTER
\overrideTextSpanner.bound-details.left.text=
\markup{\circle\number$StringNumber}
#})
\relativec{
\clef"treble_8"
\stringNumberSpanner"5"
\textSpannerDown
a8\startTextSpan
bcdef\stopTextSpan
\stringNumberSpanner"4"
g\startTextSpana
bes4ag2\stopTextSpan
}

[image of music]


Using PostScript to generate special note head shapes

When a note head with a special shape cannot easily be generated with graphic markup, PostScript code can be used to generate the shape. This example shows how a parallelogram-shaped note head is generated.

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")
(cons01.3125)
(cons-.75.75))
myNoteHeads=\overrideNoteHead.stencil=\parallelogram
normalNoteHeads=\revertNoteHead.stencil
\relativec''{
\myNoteHeads
g4d'
\normalNoteHeads
<f,\tweakstencil\parallelogrambe>4d
}

[image of music]


Using the whiteout property

Any graphical object can be printed over a white background to mask parts of objects that lie beneath. This can be useful to improve the appearance of collisions in complex situations when repositioning objects is impractical. It is necessary to explicitly set the layer property to control which objects are masked by the white background. In this example the collision of the tie with the time signature is improved by masking out the part of the tie that crosses the time signature by setting the whiteout property of TimeSignature. To do this TimeSignature is moved to a layer above Tie, which is left in the default layer of 1, and StaffSymbol is moved to a layer above TimeSignature so it is not masked.

{
\overrideScore.StaffSymbol.layer=#4
\overrideStaff.TimeSignature.layer=#3
b'2b'~
\once\overrideStaff.TimeSignature.whiteout=##t
\time3/4
b'r4
}

[image of music]


<< Back to Documentation Index

LilyPond — Snippets v2.24.4 (stable-branch).

AltStyle によって変換されたページ (->オリジナル) /