Next: Editorial annotations, Previous: Simultaneous notes, Up: Top
These snippets illustrate the Notation Reference, section Staff notation.
Ambitus can be added per voice. In this case, the ambitus must be moved manually to prevent collisions.
\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
}
>>
When adding a new staff at a line break, some extra space is
unfortunately added at the end of the line before the break (to fit in
a key signature change, which will never be printed anyway). The
workaround is to add a setting of
Staff.explicitKeySignatureVisibility as is shown in the example.
In versions 2.10 and earlier, a similar setting for the time signatures
is also required (see the example).
\score {
\new StaffGroup \relative c'' {
\new Staff
\key f \major
c1 c^"Unwanted extra space" \break
<< { c1 c }
\new Staff {
\key f \major
\once \override Staff.TimeSignature #'stencil = ##f
c1 c
}
>>
c1 c^"Fixed here" \break
<< { c1 c }
\new Staff {
\once \set Staff.explicitKeySignatureVisibility = #end-of-line-invisible
% The next line is not needed in 2.11.x or later:
\once \override Staff.TimeSignature #'break-visibility = #end-of-line-invisible
\key f \major
\once \override Staff.TimeSignature #'stencil = ##f
c1 c
}
>>
}
}
An extra staff can be added (possibly temporarily) after the start of a piece.
\score {
<<
\new Staff \relative c'' { c1 c c c c }
\new StaffGroup \relative c'' {
\new Staff {
c1 c
<< c1 \new Staff { \once \override Staff.TimeSignature #'stencil = ##f c1 } >>
c
}
}
>>
}
The number of lines in a staff may changed by overriding the
StaffSymbol property line-count.
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
}
>>
}
Though the simplest way to resize staves is to use
#(set-global-staff-size xx), an individual staff's size can be
changed by scaling the properties staff-space and
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
}
>>
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-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"
}
}
}
\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
}
If there is only one staff in one of the staff types
ChoirStaff, InnerChoirStaff, InnerStaffGroup
or StaffGroup, the bracket and the starting bar line will not
be displayed as standard behavior. This can be changed by overriding
the relevant properties, as demonstrated in this example.
Note that in contexts such as PianoStaff and GrandStaff
where the systems begin with a brace instead of a bracket, another
property has to be set, as shown on the second system in the example.
\markup \column {
\score {
\new StaffGroup <<
% Must be lower than the actual number of staff lines
\override StaffGroup.SystemStartBracket #'collapse-height = #1
\override Score.SystemStartBar #'collapse-height = #1
\new Staff {
c'1
}
>>
\layout { }
}
\score {
\new PianoStaff <<
\override PianoStaff.SystemStartBrace #'collapse-height = #1
\override Score.SystemStartBar #'collapse-height = #1
\new Staff {
c'1
}
>>
\layout { }
}
}
Incipits can be added using the instrument name grob, but keeping separate the instrument name definition and the incipit definition.
incipit =
#(define-music-function (parser location incipit-music) (ly:music?)
#{
\once \override Staff.InstrumentName #'self-alignment-X = #RIGHT
\once \override Staff.InstrumentName #'self-alignment-Y = #UP
\once \override Staff.InstrumentName #'Y-offset = #4
\once \override Staff.InstrumentName #'padding = #0.3
\once \override Staff.InstrumentName #'stencil =
#(lambda (grob)
(let* ((instrument-name (ly:grob-property grob 'long-text))
(layout (ly:output-def-clone (ly:grob-layout grob)))
(music (make-music 'SequentialMusic
'elements (list (make-music 'ContextSpeccedMusic
'context-type 'MensuralStaff
'element (make-music 'PropertySet
'symbol 'instrumentName
'value instrument-name))
$incipit-music)))
(score (ly:make-score music))
(mm (ly:output-def-lookup layout 'mm))
(indent (ly:output-def-lookup layout 'indent))
(width (ly:output-def-lookup layout 'incipit-width))
(incipit-width (if (number? width)
(* width mm)
(* indent 0.5))))
(ly:output-def-set-variable! layout 'indent (- indent incipit-width))
(ly:output-def-set-variable! layout 'line-width indent)
(ly:output-def-set-variable! layout 'ragged-right #f)
(ly:output-def-set-variable! layout 'ragged-last #f)
(ly:output-def-set-variable! layout 'system-count 1)
(ly:score-add-output-def! score layout)
(set! (ly:grob-property grob 'long-text)
(markup #:score score))
(ly:system-start-text::print grob)))
#})
%%%%%%%%%%%%%%%%%%%%%%%%%
global = {
\set Score.skipBars = ##t
\key g \major
\time 4/4
%make the staff lines invisible on staves
\override Staff.BarLine #'transparent = ##t
% the actual music
\skip 1*8
% let finis bar go through all staves
\override Staff.BarLine #'transparent = ##f
% finis bar
\bar "|."
}
discantusIncipit = <<
\new MensuralVoice = discantusIncipit <<
\repeat unfold 9 { s1 \noBreak }
{
\clef "neomensural-c1"
\key f \major
\time 2/2
c''1.
}
>>
\new Lyrics \lyricsto discantusIncipit { IV- }
>>
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 \override NoteHead #'transparent = ##t
c'1 |
b\breve |
}
}
discantusLyrics = \lyricmode {
Ju -- bi -- |
la -- te De -- |
o, om --
nis ter -- |
ra, __ om- |
"..." |
-us. |
}
altusIncipit = <<
\new MensuralVoice = altusIncipit <<
\repeat unfold 9 { s1 \noBreak }
{
\clef "neomensural-c3"
\key f \major
\time 2/2
r1 f'1.
}
>>
\new Lyrics \lyricsto altusIncipit { IV- }
>>
altusNotes = {
\transpose c' c'' {
\clef "treble"
% two measures
r2 g2. e4 fis g |
a2 g4 e |
fis g4.( fis16 e fis4) |
g1 |
\once \override NoteHead #'transparent = ##t
g1 |
g\breve |
}
}
altusLyrics = \lyricmode {
% two measures
Ju -- bi -- la -- te |
De -- o, om -- |
nis ter -- ra, |
"..." |
-us. |
}
tenorIncipit = <<
\new MensuralVoice = tenorIncipit <<
\repeat unfold 9 { s1 \noBreak }
{
\clef "neomensural-c4"
\key f \major
\time 2/2
r\longa
r\breve
r1 c'1.
}
>>
\new Lyrics \lyricsto tenorIncipit { IV- }
>>
tenorNotes = {
\transpose c' c' {
\once \override Staff.VerticalAxisGroup #'minimum-Y-extent = #'(-6 . 3)
\clef "treble_8"
R1 |
R1 |
R1 |
% two measures
r2 d'2. d'4 b e' |
\once \override NoteHead #'transparent = ##t
e'1 |
d'\breve |
}
}
tenorLyrics = \lyricmode {
% two measures
Ju -- bi -- la -- te |
"..." |
-us.
}
bassusIncipit = <<
\new MensuralVoice = bassusIncipit <<
\repeat unfold 9 { s1 \noBreak }
{
\clef "bass"
\key f \major
\time 2/2
%% incipit
r\maxima
f1.
}
>>
\new Lyrics \lyricsto bassusIncipit { IV- }
>>
bassusNotes = {
\transpose c' c' {
\clef "bass"
R1 |
R1 |
R1 |
R1 |
g2. e4 |
\once \override NoteHead #'transparent = ##t
e1 |
g\breve |
}
}
bassusLyrics = \lyricmode {
Ju -- bi- |
"..." |
-us.
}
\score {
<<
\new StaffGroup = choirStaff <<
\new Voice = "discantusNotes" <<
\global
\set Staff.instrumentName = "Discantus"
\incipit \discantusIncipit
\discantusNotes
>>
\new Lyrics = "discantusLyrics" \lyricsto discantusNotes { \discantusLyrics }
\new Voice = "altusNotes" <<
\global
\set Staff.instrumentName = "Altus"
\incipit \altusIncipit
\altusNotes
>>
\new Lyrics = "altusLyrics" \lyricsto altusNotes { \altusLyrics }
\new Voice = "tenorNotes" <<
\global
\set Staff.instrumentName = "Tenor"
\incipit \tenorIncipit
\tenorNotes
>>
\new Lyrics = "tenorLyrics" \lyricsto tenorNotes { \tenorLyrics }
\new Voice = "bassusNotes" <<
\set Staff.instrumentName = "Bassus"
\incipit \bassusIncipit
\bassusNotes
>>
>>
\new Lyrics = "bassusLyrics" \lyricsto bassusNotes { \bassusLyrics }
%% Keep the bass lyrics outside of the staff group to avoid bar lines
%% between the lyrics.
>>
\layout {
\context {
\Score
%% no bar lines in staves
\override BarLine #'transparent = ##t
}
%% the next three instructions keep the lyrics between the bar lines
\context {
\Lyrics
\consists "Bar_engraver"
\override BarLine #'transparent = ##t
}
\context {
\StaffGroup
\consists "Separating_line_group_engraver"
}
\context {
\Voice
%% no slurs
\override Slur #'transparent = ##t
%% 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
}
}
The \markup command is quite versatile. In this snippet, it
contains a \score block instead of texts or marks.
tuning = \markup {
\score {
\new Staff \with { \remove "Time_signature_engraver" }
{
\clef bass <c, g, d g>1
}
\layout { ragged-right = ##t }
}
}
\header {
title = "Solo Cello Suites"
subtitle = "Suite IV"
subsubtitle = \markup { Originalstimmung: \general-align #Y #CENTER \tuning }
}
\layout { ragged-right = ##f }
\relative c'' {
\time 4/8
\times 2/3 { c8 d e } \times 2/3 { c d e }
\times 2/3 { c8 d e } \times 2/3 { c d e }
g8 a g a
g8 a g a
}
Tablature can be formatted using letters instead of numbers.
#(define (letter-tablature-format str context event)
(let*
((tuning (ly:context-property context 'stringTunings))
(pitch (ly:event-property event 'pitch)))
(make-whiteout-markup
(make-vcenter-markup
(string (integer->char
(+ (char->integer #\a)
(- (ly:pitch-semitones pitch)
(list-ref tuning (- str 1))))))))))
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 = #letter-tablature-format
} {
\music
}
>>
For pedagogical 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.
{
\override Staff.StaffSymbol #'line-positions = #'(-4 -2 -0.2 0 0.2 2 4)
d'4 e' f' g'
}
This snippet provides a workaround for emitting measure counters using transparent percent repeats.
<<
\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
\override PercentRepeat #'transparent = ##t
\override PercentRepeatCounter #'staff-padding = #1
\repeat percent 4 { s1 }
}
>>
The mensurstriche-layout where the bar lines do not show on the staves
but between staves can be achieved with a StaffGroup instead of
a ChoirStaff. The bar line on staves is blanked out by setting
the transparent property.
global = {
\override Staff.BarLine #'transparent = ##t
s1 s
% the final bar line is not interrupted
\revert Staff.BarLine #'transparent
\bar "|."
}
\new StaffGroup \relative c'' {
<<
\new Staff { << \global { c1 c } >> }
\new Staff { << \global { c c } >> }
>>
}
Use a markup text to replace the (TAB) clef glyph with a modern font.
TAB = \markup {
\raise #1.5
\sans
\bold
\huge
\override #'(baseline-skip . 2.5)
\center-column {
T
A
B
}
}
\new TabStaff {
\override Staff.Clef #'stencil = #(lambda (grob)
ly:clef::print (grob-interpret-markup grob TAB))
a
}
The property systemStartDelimiterHierarchy can be used to make
more complex nested staff groups. The command \set
StaffGroup.systemStartDelimiterHierarchy takes an alphabetical list of
the number of staves produced. Before each staff a system start
delimiter can be given. It has to be enclosed in brackets and takes as
much staves as the brackets enclose. Elements in the list can be
omitted, but the first bracket takes always the complete number of
staves. The possibilities are SystemStartBar,
SystemStartBracket, SystemStartBrace, and
SystemStartSquare.
\new StaffGroup
\relative c'' <<
\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 }
>>
The commonly used \key command sets the keySignature
property, in the Staff context.
To create non-standard key signatures, set this property directly. The format of this command is a list:
\set Staff.keySignature = #`(((octave . step) . alter) ((octave
. step) . alter) ...) where, for each element in the list,
octave specifies the octave (0 being the octave from middle C to
the B above), step specifies the note within the octave (0 means
C and 6 means B), and alter is ,SHARP ,FLAT ,DOUBLE-SHARP
etc. (Note the leading comma.)
Alternatively, for each item in the list, using the more concise format
(step . alter) specifies that the same alteration should hold in
all octaves.
Here is an example of a possible key signature for generating a whole-tone scale:
\relative c' {
\set Staff.keySignature = #`(((0 . 3) . ,SHARP) ((0 . 5) . ,FLAT) ((0 . 6) . ,FLAT))
c4 d e fis
aes4 bes 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
}
Quotations take into account the transposition of both
source and target. In this example, all instruments play sounding
middle C; the target is an instrument in F. The target part may be
transposed using \transpose. In this case, all the pitches
(including the quoted ones) are transposed.
\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
}
{
\set Staff.instrumentName = \markup \center-column { Horn \line { in F } }
\quoteTest
\transpose c' d' << \quoteTest s4_"up a tone" >>
}
With \quote, fragments of previously entered
music may be quoted. quotedEventTypes will determines which
items are quoted. In this example, a 16th rest is not quoted, since
rest-event is not in quotedEventTypes.
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 {
\set Staff.instrumentName = #"quoteMe"
\quoteMe
}
\new Staff {
\set Staff.instrumentName = #"orig"
\original
}
\new Staff \relative c'' <<
\set Staff.instrumentName = #"orig+quote"
\set Staff.quotedEventTypes = #'(note-event articulation-event)
\original
\new Voice {
s4
\set fontSize = #-4
\override Stem #'length-fraction = #(magstep -4)
\quoteDuring #"quoteMe" { \skip 2. }
}
>>
>>
The first empty staff can also be removed from the score by setting the
VerticalAxisGroup property remove-first. This can be done
globally inside the \layout block, or locally inside the
specific staff that should be removed. In the latter case, you have to
specify the context (Staff applies only to the current staff) in
front of the property.
The lower staff of the second staff group is not removed, because the setting applies only to the specific staff inside of which it is written.
\layout {
\context {
\RemoveEmptyStaffContext
% 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
}
>>
The time signature can be enclosed within parentheses.
\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
}
The command \clef "treble_8" is equivalent to setting
clefGlyph, clefPosition (which controls the vertical
position of the clef), middleCPosition and
clefOctavation. A clef is printed when any of the properties
except middleCPosition are changed.
Note that changing the glyph, the position of the clef, or the
octavation does not in itself change the position of subsequent notes
on the staff: the position of middle C must also be specified to do
this. The positional parameters are relative to the staff center line,
positive numbers displacing upwards, counting one for each line and
space. The clefOctavation value would normally be set to 7, -7,
15 or -15, but other values are valid.
When a clef change takes place at a line break the new clef symbol is
printed at both the end of the previous line and the beginning of the
new line by default. If the warning clef at the end of the previous
line is not required it can be suppressed by setting the Staff
property explicitClefVisibility to the value
end-of-line-invisible. The default behavior can be recovered
with \unset Staff.explicitClefVisibility.
The following examples show the possibilities when setting these properties manually. On the first line, the manual changes preserve the standard relative positioning of clefs and notes, whereas on the second line, they do not.
{
% The default treble clef
c'1
% The standard bass clef
\set Staff.clefGlyph = #"clefs.F"
\set Staff.clefPosition = #2
\set Staff.middleCPosition = #6
c'1
% The baritone clef
\set Staff.clefGlyph = #"clefs.C"
\set Staff.clefPosition = #4
\set Staff.middleCPosition = #4
c'1
% The standard choral tenor clef
\set Staff.clefGlyph = #"clefs.G"
\set Staff.clefPosition = #-2
\set Staff.clefOctavation = #-7
\set Staff.middleCPosition = #1
c'1
% A non-standard clef
\set Staff.clefPosition = #0
\set Staff.clefOctavation = #0
\set Staff.middleCPosition = #-4
c'1 \break
% The following clef changes do not preserve
% the normal relationship between notes 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.clefOctavation = #7
c'1
\set Staff.clefOctavation = #0
\set Staff.clefPosition = #0
c'1
% Here we go back to the normal clef:
\set Staff.middleCPosition = #0
c'1
}
The system start delimiter SystemStartSquare can be used by
setting it explicitly in a StaffGroup or ChoirStaffGroup
context.
\score {
\new StaffGroup { <<
\set StaffGroup.systemStartDelimiter = #'SystemStartSquare
\new Staff { c'4 d' e' f' }
\new Staff { c'4 d' e' f' }
>> }
}
By adding the Volta_engraver to the relevant
staff, volte can be put under chords.
\score {
<<
\chords {
c1
c1
}
\new Staff \with { \consists "Volta_engraver" } {
\repeat volta 2 { c'1 }
\alternative { c' }
}
>>
\layout {
\context {
\Score
\remove "Volta_engraver"
}
}
}
By adding the Volta_engraver to the relevant
staff, volte can be put over staves other than the topmost
one in a score.
voltaMusic = \relative c'' {
\repeat volta 2 {
c1
}
\alternative {
d1
e
}
}
<<
\new StaffGroup <<
\context Staff \voltaMusic
\new Staff \voltaMusic
>>
\new StaffGroup <<
\new Staff \with { \consists "Volta_engraver" }
\voltaMusic
\new Staff \voltaMusic
>>
>>
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.