text:
# LilyPond — Notation Reference

 This manual provides a reference for all notation that can be produced with LilyPond version 2.23.10. It assumes that the reader is familiar with the material in the Learning Manual.
 For more information about how this manual fits with the other documentation, or to read this manual in other formats, see Manuals. If you are missing any manuals, the complete documentation can be found at https://lilypond.org/.

# 1. Musical notation

This chapter explains how to create musical notation.

## 1.1 Pitches

This section discusses how to specify the pitch of notes. There are three steps to this process: input, modification, and output.

### 1.1.1 Writing pitches

This section discusses how to input pitches. There are two different ways to place notes in octaves: absolute and relative mode. In most cases, relative mode will be more convenient.

#### Absolute octave entry

A pitch name is specified using lowercase letters a through g. The note names c to b are engraved in the octave below middle C.

{
\clef bass
c4 d e f
g4 a b c
d4 e f g
}

Other octaves may be specified with a single quote (') or comma (,) character. Each ' raises the pitch by one octave; each , lowers the pitch by an octave.

{
\clef treble
c'4 e' g' c''
c'4 g b c'
\clef bass
c,4 e, g, c
c,4 g,, b,, c,
}

Common octave marks can be entered just once on a reference pitch after \fixed placed before the music. Pitches inside \fixed only need ' or , marks when they are above or below the octave of the reference pitch.

{
\fixed c' {
\clef treble
c4 e g c'
c4 g, b, c
}
\clef bass
\fixed c, {
c4 e g c'
c4 g, b, c
}
}

Pitches in the music expression following \fixed are unaffected by any enclosing \relative, discussed next.

Music Glossary: Pitch names.

Snippets: Pitches.

#### Relative octave entry

Absolute octave entry requires specifying the octave for every single note. Relative octave entry, in contrast, specifies each octave in relation to the last note: changing one note’s octave will affect all of the following notes.

Relative note mode has to be entered explicitly using the \relative command:

\relative startpitch musicexpr

In relative mode, each note is assumed to be as close to the previous note as possible. This means that the octave of each pitch inside musicexpr is calculated as follows:

• If no octave changing mark is used on a pitch, its octave is calculated so that the interval with the previous note is less than a fifth. This interval is determined without considering accidentals.
• An octave changing mark ' or , can be added to respectively raise or lower a pitch by an extra octave, relative to the pitch calculated without an octave mark.
• Multiple octave changing marks can be used. For example, '' and ,, will alter the pitch by two octaves.
• The pitch of the first note is relative to startpitch. startpitch is specified in absolute octave mode. Which choices are meaningful?
an octave of c

Identifying middle C with c' is quite basic, so finding octaves of c tends to be straightforward. If your music starts with gis above c''', you’d write something like \relative c''' { gis' … }

an octave of the first note inside

Writing \relative gis''' { gis … } makes it easy to determine the absolute pitch of the first note inside.

no explicit starting pitch

The form \relative { gis''' … } serves as a compact version of the previous option: the first note inside is written in absolute pitch itself. (This happens to be equivalent to choosing f as the reference pitch.)

The documentation will usually employ the last option.

Here is the relative mode shown in action:

\relative {
\clef bass
c d e f
g a b c
d e f g
}

Octave changing marks are used for intervals greater than a fourth:

\relative {
c'' g c f,
c' a, e'' c
}

A note sequence without a single octave mark can nevertheless span large intervals:

\relative {
c f b e
a d g c
}

When \relative blocks are nested, the innermost \relative block starts with its own reference pitch independently of the outer \relative.

\relative {
c' d e f
\relative {
c'' d e f
}
}

\relative has no effect on \chordmode blocks.

\new Staff {
\relative c''' {
\chordmode { c1 }
}
\chordmode { c1 }
}

\relative is not allowed inside of \chordmode blocks.

Music inside a \transpose block is absolute unless a \relative is included.

\relative {
d' e
\transpose f g {
d e
\relative {
d' e
}
}
}

If the preceding item is a chord, the first note of the chord is used as the reference point for the octave placement of a following note or chord. Inside chords, the next note is always relative to the preceding one. Examine the next example carefully, paying attention to the c notes.

\relative {
c'
<c e g>
<c' e g'>
<c, e, g''>
}

As explained above, the octave of pitches is calculated only with the note names, regardless of any alterations. Therefore, an E-double-sharp following a B will be placed higher, while an F-double-flat will be placed lower. In other words, a double-augmented fourth is considered a smaller interval than a double-diminished fifth, regardless of the number of semitones that each interval contains.

\relative {
c''2 fis
c2 ges
b2 eisis
b2 feses
}

In complex situations, it is sometimes useful to get back to a certain pitch regardless of what happened before. This can be done using \resetRelativeOctave:

\relative {
<<
{ c''2 d }
\\
{ e,,2 f }
>>
\resetRelativeOctave c''
c2
}

Music Glossary: fifth, interval, Pitch names.

Notation Reference: Octave checks.

Snippets: Pitches.

Internals Reference: RelativeOctaveMusic.

#### Accidentals

Note: New users are sometimes confused about accidentals and key signatures. In LilyPond, note names specify pitches; key signatures and clefs determine how these pitches are displayed. An unaltered note like c means ‘C natural’, regardless of the key signature or clef. For more information, see Pitches and key signatures.

A sharp pitch is made by adding is to the note name, and a flat pitch by adding es. As you might expect, a double sharp or double flat is made by adding isis or eses. This syntax is derived from Dutch note naming conventions. To use other names for accidentals, see Note names in other languages.

\relative c'' { ais1 aes aisis aeses }

A natural pitch is entered as a simple note name; no suffix is required. A natural sign will be printed when needed to cancel the effect of an earlier accidental or key signature.

\relative c'' { a4 aes a2 }

Quarter tones may be added; the following is a series of Cs with increasing pitches:

\relative c'' { ceseh1 ces ceh c cih cis cisih }

Normally accidentals are printed automatically, but you may also print them manually. A reminder accidental can be forced by adding an exclamation mark ! after the pitch. A cautionary accidental (i.e., an accidental within parentheses) can be obtained by adding the question mark ? after the pitch.

\relative c'' { cis cis cis! cis? c c c! c? }

Accidentals on tied notes are only printed at the beginning of a new system:

\relative c'' {
cis1~ 1~
\break
cis
}

#### Hiding accidentals on tied notes at the start of a new system

This shows how to hide accidentals on tied notes at the start of a new system.

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

#### Preventing extra naturals from being automatically added

In accordance with traditional typesetting rules, a natural sign is printed before a sharp or flat if a previous double sharp or flat on the same note is canceled. To change this behavior to contemporary practice, set the extraNatural property to f in the Staff context.

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

Music Glossary: sharp, flat, double sharp, double flat, Pitch names, quarter tone.

Learning Manual: Pitches and key signatures.

Snippets: Pitches.

Internals Reference: Accidental_engraver, Accidental, AccidentalCautionary, accidental-interface.

#### Known issues and warnings

There are no generally accepted standards for denoting quarter tone accidentals, so LilyPond’s symbols do not conform to any standard.

#### Note names in other languages

There are predefined sets of note and accidental names for various other languages. Selecting the note name language is usually done at the beginning of the file; the following example is written using Italian note names:

\language "italiano"

\relative {
do' re mi sib
}

The available languages and the note names they define are:

Language

Note Names

nederlands

c d e f g a bes b

català or
catalan

do re mi fa sol la sib si

deutsch

c d e f g a b h

english

c d e f g a bf/b-flat b

español or
espanol

do re mi fa sol la sib si

français

do ré/re mi fa sol la sib si

italiano

do re mi fa sol la sib si

norsk

c d e f g a b h

português or
portugues

do re mi fa sol la sib si

suomi

c d e f g a b h

svenska

c d e f g a b h

vlaams

do re mi fa sol la sib si

In addition to note names, accidental suffixes may also vary depending on the language:

Language

sharp

flat

double sharp

double flat

nederlands

is

es

isis

eses

català or
catalan

d/s

b

dd/ss

bb

deutsch

is

es

isis

eses

english

s/-sharp

f/-flat

ss/x/-sharpsharp

ff/-flatflat

español or
espanol

s

b

ss/x

bb

français

d

b

dd/x

bb

italiano

d

b

dd

bb

norsk

iss/is

ess/es

ississ/isis

essess/eses

português or
portugues

s

b

ss

bb

suomi

is

es

isis

eses

svenska

iss

ess

ississ

essess

vlaams

k

b

kk

bb

In Dutch, German, Norwegian, and Finnish, aes is contracted to as; in Dutch and Norwegian, however, both forms are accepted by LilyPond. Exactly the same holds for es and ees, aeses and ases, and finally eeses and eses.

In German and Finnish, LilyPond additionally provides the more frequent form asas for ases.

\relative c'' { a2 as e es a ases e eses }

Some music uses microtones whose alterations are fractions of a ‘normal’ sharp or flat. The following table lists note name suffixes for quarter tone accidentals; here the prefixes semi- and sesqui- respectively mean ‘half’ and ‘one and a half’.

Language

semi-sharp

semi-flat

sesqui-sharp

sesqui-flat

nederlands

ih

eh

isih

eseh

català or
catalan

qd/qs

qb

tqd/tqs

tqb

deutsch

ih

eh

isih

eseh

english

qs

qf

tqs

tqf

español or
espanol

cs

cb

tcs

tcb

français

sd

sb

dsd

bsb

italiano

sd

sb

dsd

bsb

norsk

ih

eh

issih/isih

esseh/eseh

português or
portugues

sqt

bqt

stqt

btqt

suomi

ih

eh

isih

eseh

svenska

ih

eh

issih

esseh

vlaams

hk

hb

khk

bhb

In German, there are similar name contractions for microtones as with normal pitches described above.

\language "deutsch"

\relative c'' { asah2 eh aih eisih }

Most languages presented here are commonly associated with Western classical music, also referred to as Common Practice Period. However, alternate pitches and tuning systems are also supported: see Common notation for non-Western music.

Music Glossary: Pitch names, Common Practice Period.

Notation Reference: Common notation for non-Western music.

Installed Files: ‘scm/define-note-names.scm’.

Snippets: Pitches.

### 1.1.2 Changing multiple pitches

This section discusses how to modify pitches.

#### Octave checks

In relative mode, it is easy to forget an octave changing mark. Octave checks make such errors easier to find by displaying a warning and correcting the octave if a note is found in an unexpected octave.

To check the octave of a note, specify the absolute octave after the = symbol. This example will generate a warning (and change the pitch) because the second note is the absolute octave d'' instead of d' as indicated by the octave correction.

\relative {
c''2 d='
e2 f
}

The octave of notes may also be checked with the \octaveCheck controlpitch command. controlpitch is specified in absolute mode. This checks that the interval between the previous note and the controlpitch is within a fourth (i.e., the normal calculation of relative mode). If this check fails, a warning is printed. While the previous note itself is not changed, future notes are relative to the corrected value.

\relative {
c''2 d
\octaveCheck c'
e2 f
}

Compare the two bars below. The first and third \octaveCheck checks fail, but the second one does not fail.

\relative {
c''4 f g f

c4
\octaveCheck c'
f
\octaveCheck c'
g
\octaveCheck c'
f
}

Snippets: Pitches.

Internals Reference: RelativeOctaveCheck.

#### Transpose

A music expression can be transposed with \transpose. The syntax is

\transpose frompitch topitch musicexpr

This means that musicexpr is transposed by the interval between the pitches frompitch and topitch: any note with pitch frompitch is changed to topitch and any other note is transposed by the same interval. Both pitches are entered in absolute mode.

Note: Music inside a transpose block is absolute unless a relative is included in the block.

Consider a piece written in the key of D-major. It can be transposed up to E-major; note that the key signature is automatically transposed as well.

\transpose d e {
\relative {
\key d \major
d'4 fis a d
}
}

If a part written in C (normal concert pitch) is to be played on the A clarinet (for which an A is notated as a C and thus sounds a minor third lower than notated), the appropriate part will be produced with:

\transpose a c' {
\relative {
\key c \major
c'4 d e g
}
}

Note that we specify \key c \major explicitly. If we do not specify a key signature, the notes will be transposed but no key signature will be printed.

\transpose distinguishes between enharmonic pitches: both \transpose c cis or \transpose c des will transpose up a semitone. The first version will print sharps and the notes will remain on the same scale step, the second version will print flats on the scale step above.

music = \relative { c' d e f }
\new Staff {
\transpose c cis { \music }
\transpose c des { \music }
}

\transpose may also be used in a different way, to input written notes for a transposing instrument. The previous examples show how to enter pitches in C (or concert pitch) and typeset them for a transposing instrument, but the opposite is also possible if you for example have a set of instrumental parts and want to print a conductor’s score. For example, when entering music for a B-flat trumpet that begins on a notated E (concert D), one would write:

musicInBflat = { e4 … }
\transpose c bes, \musicInBflat

To print this music in F (e.g., rearranging to a French horn) you could wrap the existing music with another \transpose:

musicInBflat = { e4 … }
\transpose f c' { \transpose c bes, \musicInBflat }

#### Transposing pitches with minimum accidentals ("Smart" transpose)

This example uses some Scheme code to enforce enharmonic modifications for notes in order to have the minimum number of accidentals. In this case, the following rules apply:

Double accidentals should be removed

B sharp -> C

E sharp -> F

C flat -> B

F flat -> E

In this manner, the most natural enharmonic notes are chosen.

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

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

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

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

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

Notation Reference: Instrument transpositions, Inversion, Modal transformations, Relative octave entry, Retrograde.

Snippets: Pitches.

Internals Reference: TransposedMusic.

#### Known issues and warnings

The relative conversion will not affect \transpose, \chordmode or \relative sections in its argument. To use relative mode within transposed music, an additional \relative must be placed inside \transpose.

Triple accidentals will not be printed if using \transpose. An ‘enharmonically equivalent’ pitch will be used instead (e.g., d-flat rather than e-triple-flat).

#### Inversion

A music expression can be inverted and transposed in a single operation with:

\inversion around-pitch to-pitch musicexpr

The musicexpr is inverted interval by interval around around-pitch, and then transposed so that around-pitch is mapped to to-pitch.

music = \relative { c' d e f }
\new Staff {
\music
\inversion d' d' \music
\inversion d' ees' \music
}

Note: Motifs to be inverted should be expressed in absolute form or be first converted to absolute form by enclosing them in a relative block.

Notation Reference: Modal transformations, Retrograde, Transpose.

A music expression can be reversed to produce its retrograde:

music = \relative { c'8. ees16( fis8. a16 b8.) gis16 f8. d16 }

\new Staff {
\music
}

#### Known issues and warnings

\retrograde is a rather simple tool. Since many events are ‘mirrored’ rather than exchanged, tweaks and directional modifiers for opening spanners need to be added at the matching closing spanners: ^( needs to be ended by ^), every \< or \cresc needs to be ended by \! or \endcr, every \> or \decr needs to be ended by \enddecr. Property-changing commands/overrides with a lasting effect will likely cause surprises.

Notation Reference: Inversion, Modal transformations, Transpose.

#### Modal transformations

In a musical composition that is based on a scale, a motif is frequently transformed in various ways. It may be transposed to start at different places in the scale or it may be inverted around a pivot point in the scale. It may also be reversed to produce its retrograde, see Retrograde.

Note: Any note that does not lie within the given scale will be left untransformed.

#### Modal transposition

A motif can be transposed within a given scale with:

\modalTranspose from-pitch to-pitch scale motif

The notes of motif are shifted within the scale by the number of scale degrees given by the interval between to-pitch and from-pitch:

diatonicScale = \relative { c' d e f g a b }
motif = \relative { c'8 d e f g a b c }

\new Staff {
\motif
\modalTranspose c f \diatonicScale \motif
\modalTranspose c b, \diatonicScale \motif
}

An ascending scale of any length and with any intervals may be specified:

pentatonicScale = \relative { ges aes bes des ees }
motif = \relative { ees'8 des ges,4 <ges' bes,> <ges bes,> }

\new Staff {
\motif
\modalTranspose ges ees' \pentatonicScale \motif
}

When used with a chromatic scale \modalTranspose has a similar effect to \transpose, but with the ability to specify the names of the notes to be used:

chromaticScale = \relative { c' cis d dis e f fis g gis a ais b }
motif = \relative { c'8 d e f g a b c }

\new Staff {
\motif
\transpose c f \motif
\modalTranspose c f \chromaticScale \motif
}

#### Modal inversion

A motif can be inverted within a given scale around a given pivot note and transposed in a single operation with:

\modalInversion around-pitch to-pitch scale motif

The notes of motif are placed the same number of scale degrees from the around-pitch note within the scale, but in the opposite direction, and the result is then shifted within the scale by the number of scale degrees given by the interval between to-pitch and around-pitch.

So to simply invert around a note in the scale use the same value for around-pitch and to-pitch:

octatonicScale = \relative { ees' f fis gis a b c d }
motif = \relative { c'8. ees16 fis8. a16 b8. gis16 f8. d16 }

\new Staff {
\motif
\modalInversion fis' fis' \octatonicScale \motif
}

To invert around a pivot between two notes in the scale, invert around one of the notes and then transpose by one scale degree. The two notes specified can be interpreted as bracketing the pivot point:

scale = \relative { c' g' }
motive = \relative { c' c g' c, }

\new Staff {
\motive
\modalInversion c' g' \scale \motive
}

octatonicScale = \relative { ees' f fis gis a b c d }
motif = \relative { c'8. ees16 fis8. a16 b8. gis16 f8. d16 }

\new Staff {
\motif
\retrograde \modalInversion c' c' \octatonicScale \motif
}

### 1.1.3 Displaying pitches

This section discusses how to alter the output of pitches.

#### Clef

Without any explicit command, the default clef for LilyPond is the treble (or G) clef.

c'2 c'

However, the clef can be changed by using the \clef command and an appropriate clef name. Middle C is shown in each of the following examples.

\clef treble
c'2 c'
\clef alto
c'2 c'
\clef tenor
c'2 c'
\clef bass
c'2 c'

For the full range of possible clef names see Clef styles.

Specialized clefs, such as those used in Ancient music, are described in Mensural clefs and Gregorian clefs. Music that requires tablature clefs is discussed in Default tablatures and Custom tablatures.

For mixing clefs when using cue notes, see the \cueClef and \cueDuringWithClef commands in Formatting cue notes.

By adding _8 or ^8 to the clef name, the clef is transposed one octave down or up respectively, and _15 and ^15 transpose by two octaves. Other integers can be used if required. Clef names containing non-alphabetic characters must be enclosed in quotes

\clef treble
c'2 c'
\clef "treble_8"
c'2 c'
\clef "bass^15"
c'2 c'
\clef "alto_2"
c'2 c'
\clef "G_8"
c'2 c'
\clef "F^5"
c'2 c'

Optional octavation can be obtained by enclosing the numeric argument in parentheses or brackets:

\clef "treble_(8)"
c'2 c'
\clef "bass^[15]"
c'2 c'

The pitches are displayed as if the numeric argument were given without parentheses/brackets.

By default, a clef change taking place at a line break will cause the new clef symbol to be printed at the end of the previous line, as a warning clef, as well as the beginning of the next. This warning clef can be suppressed.

\clef treble { c'2 c' } \break
\clef bass { c'2 c' } \break
\clef alto
\set Staff.explicitClefVisibility = #end-of-line-invisible
{ c'2 c' } \break
\unset Staff.explicitClefVisibility
\clef bass { c'2 c' } \break

By default, a clef that has previously been printed will not be reprinted if the same \clef command is issued again and will be ignored. The command \set Staff.forceClef = ##t changes this behaviour.

  \clef treble
c'1
\clef treble
c'1
\set Staff.forceClef = ##t
c'1
\clef treble
c'1

To be more precise, it is not the \clef command itself that prints a clef. Instead, it sets or changes a property of the Clef_engraver, which then decides by its own whether to display a clef or not in the current staff. The forceClef property overrides this decision locally to reprint a clef once.

When there is a manual clef change, the glyph of the changed clef will be smaller than normal. This behaviour can be overridden.

  \clef "treble"
c'1
\clef "bass"
c'1
\clef "treble"
c'1
\override Staff.Clef.full-size-change = ##t
\clef "bass"
c'1
\clef "treble"
c'1
\revert Staff.Clef.full-size-change
\clef "bass"
c'1
\clef "treble"
c'1

#### Tweaking clef properties

Changing the Clef glyph, its position, or the ottavation does not change the position of subsequent notes on the staff. To get key signatures on their correct staff lines middleCClefPosition must also be specified, with positive or negative values moving middle C up or down respectively, relative to the staff’s center line.

For example, \clef "treble_8" is equivalent to setting the clefGlyph, clefPosition (the vertical position of the clef itself on the staff), middleCPosition and clefTransposition. Note that when any of these properties (except middleCPosition) are changed a new clef symbol is printed.

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
\key f \major
c'1
% The standard bass clef
\set Staff.clefGlyph = #"clefs.F"
\set Staff.clefPosition = #2
\set Staff.middleCPosition = #6
\set Staff.middleCClefPosition = #6
\key g \major
c'1
% The baritone clef
\set Staff.clefGlyph = #"clefs.C"
\set Staff.clefPosition = #4
\set Staff.middleCPosition = #4
\set Staff.middleCClefPosition = #4
\key f \major
c'1
% The standard choral tenor clef
\set Staff.clefGlyph = #"clefs.G"
\set Staff.clefPosition = #-2
\set Staff.clefTransposition = #-7
\set Staff.middleCPosition = #1
\set Staff.middleCClefPosition = #1
\key f \major
c'1
% A non-standard clef
\set Staff.clefPosition = #0
\set Staff.clefTransposition = #0
\set Staff.middleCPosition = #-4
\set Staff.middleCClefPosition = #-4
\key g \major
c'1 \break

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

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

\set Staff.middleCPosition = #0
c'1
}

Notation Reference: Mensural clefs, Gregorian clefs, Default tablatures, Custom tablatures, Formatting cue notes.

Installed Files: ‘scm/parser-clef.scm’.

Snippets: Pitches.

Internals Reference: Clef_engraver, Clef, ClefModifier, clef-interface.

#### Known issues and warnings

Ottavation numbers attached to clefs are treated as separate grobs. So any \override done to the Clef will also need to be applied, as a separate \override, to the ClefModifier grob.

\new Staff \with {
\override Clef.color = #blue
\override ClefModifier.color = #red
}

\clef "treble_8" c'4

#### Key signature

Note: New users are sometimes confused about accidentals and key signatures. In LilyPond, note names are the raw input; key signatures and clefs determine how this raw input is displayed. An unaltered note like c means ‘C natural’, regardless of the key signature or clef. For more information, see Pitches and key signatures.

The key signature indicates the tonality in which a piece is played. It is denoted by a set of alterations (flats or sharps) at the start of the staff. The key signature may be altered:

\key pitch mode

Here, mode should be \major or \minor to get a key signature of pitch-major or pitch-minor, respectively. You may also use the standard mode names, also called church modes: \ionian, \dorian, \phrygian, \lydian, \mixolydian, \aeolian, and \locrian.

\relative {
\key g \major
fis''1
f
fis
}

Additional modes can be defined, by listing the alterations for each scale step when the mode starts on C.

freygish = #((0 . ,NATURAL) (1 . ,FLAT) (2 . ,NATURAL)
(3 . ,NATURAL) (4 . ,NATURAL) (5 . ,FLAT) (6 . ,FLAT))

\relative {
\key c \freygish c'4 des e f
\bar "||" \key d \freygish d es fis g
}

Accidentals in the key signature may be printed in octaves other than their traditional positions, or in multiple octaves, by using the flat-positions and sharp-positions properties of KeySignature. Entries in these properties specify the range of staff positions where accidentals will be printed. If a single position is specified in an entry, the accidentals are placed within the octave ending at that staff position.

\override Staff.KeySignature.flat-positions = #'((-5 . 5))
\override Staff.KeyCancellation.flat-positions = #'((-5 . 5))
\clef bass \key es \major es g bes d'
\clef treble \bar "||" \key es \major es' g' bes' d''

\override Staff.KeySignature.sharp-positions = #'(2)
\bar "||" \key b \major b' fis' b'2

#### Preventing natural signs from being printed when the key signature changes

When the key signature changes, natural signs are automatically printed to cancel any accidentals from previous key signatures. This may be prevented by setting to f the printKeyCancellation property in the Staff context.

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

The commonly used \key command sets the keyAlterations 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.keyAlterations =
#(((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.

Alternatively, using the more concise format for each item in the list (step . alter) specifies the same alteration holds in all octaves.

For microtonal scales where a “sharp” is not 100 cents, alter refers to the alteration as a proportion of a 200-cent whole tone.

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

Music Glossary: church mode, scordatura.

Learning Manual: Pitches and key signatures.

Snippets: Pitches.

Internals Reference: KeyChangeEvent, Key_engraver, Key_performer, KeyCancellation, KeySignature, key-signature-interface.

#### Ottava brackets

Ottava brackets introduce an extra transposition of an octave for the staff:

\relative c'' {
a2 b
\ottava #-2
a2 b
\ottava #-1
a2 b
\ottava #0
a2 b
\ottava #1
a2 b
\ottava #2
a2 b
}

By default, only a number is printed at the start of the bracket. That setting may be changed to include an abbreviated ordinal, either in superscript or in normal letters (the latter was formerly used by default); the default bold font weight of these characters may also be altered, as explained in Selecting font and font size.

The following example demonstrates various options, as well as how to go back to the current default behavior:

\relative c'' {
\ottava #1
a'2 b
\ottava #2
a'2 b
\bar "||"
\set Staff.ottavationMarkups = #ottavation-ordinals
\ottava #1
a,2 b
\ottava #2
a'2 b
\bar "||"
\override Staff.OttavaBracket.font-series = #'medium
\set Staff.ottavationMarkups = #ottavation-simple-ordinals
\ottava #1
a,2 b
\ottava #2
a'2 b
\bar "||"
\revert Staff.OttavaBracket.font-series
\set Staff.ottavationMarkups = #ottavation-numbers
\ottava #1
a,2 b
\ottava #2
a'2 b
}

#### Changing ottava text

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

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

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

#### Adding an ottava marking to a single voice

If you have more than one voice on the staff, setting octavation in one voice transposes the position of notes in all voices for the duration of the ottava bracket. If the octavation is only intended to apply to one voice, the Ottava_spanner_engraver should be moved to Voice context.

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

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

#### Modifying the Ottava spanner slope

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

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

Music Glossary: octavation.

Notation Reference: Selecting font and font size.

Snippets: Pitches.

Internals Reference: Ottava_spanner_engraver, OttavaBracket, ottava-bracket-interface.

#### Instrument transpositions

When typesetting scores that involve transposing instruments, some parts can be typeset in a different pitch than the concert pitch. In these cases, the key of the transposing instrument should be specified; otherwise the MIDI output and cues in other parts will produce incorrect pitches. For more information about quotations, see Quoting other voices.

\transposition pitch

The pitch to use for \transposition should correspond to the real sound heard when a c' written on the staff is played by the transposing instrument. This pitch is entered in absolute mode, so an instrument that produces a real sound which is one tone higher than the printed music should use \transposition d'. \transposition should only be used if the pitches are not being entered in concert pitch.

Here are a few notes for violin and B-flat clarinet where the parts have been entered using the notes and key as they appear in each part of the conductor’s score. The two instruments are playing in unison.

\new GrandStaff <<
\new Staff = "violin" \with {
instrumentName = "Vln"
midiInstrument = "violin"
}
\relative c'' {
% not strictly necessary, but a good reminder
\transposition c'
\key c \major
g4( c8) r c r c4
}
\new Staff = "clarinet" \with {
instrumentName = \markup { Cl (B\flat) }
midiInstrument = "clarinet"
}
\relative c'' {
\transposition bes
\key d \major
a4( d8) r d r d4
}
>>

The \transposition may be changed during a piece. For example, a clarinetist may be required to switch from an A clarinet to a B-flat clarinet.

flute = \relative c'' {
\key f \major
\cueDuring "clarinet" #DOWN {
R1 _\markup\tiny "clarinet"
c4 f e d
R1 _\markup\tiny "clarinet"
}
}
clarinet = \relative c'' {
\key aes \major
\transposition a
aes4 bes c des
R1^\markup { muta in B\flat }
\key g \major
\transposition bes
d2 g,
}
<<
\new Staff \with { instrumentName = "Flute" }
\flute
\new Staff \with { instrumentName = "Cl (A)" }
\clarinet
>>

Music Glossary: concert pitch, transposing instrument.

Notation Reference: Quoting other voices, Transpose.

Snippets: Pitches.

#### Automatic accidentals

There are many different conventions on how to typeset accidentals. LilyPond provides a function to specify which accidental style to use. This function is called as follows:

\new Staff <<
\accidentalStyle voice
{ … }
>>

The accidental style normally applies to the current Staff (with the exception of the styles choral, piano and piano-cautionary, which are explained below). Optionally, the function can take a second argument that determines in which scope the style should be changed. For example, to use the same style in all staves of the current StaffGroup, use:

\accidentalStyle StaffGroup.voice

The following accidental styles are supported. To demonstrate each style, we use the following example:

musicA = {
<<
\relative {
cis''8 fis, bes4 <a cis>8 f bis4 |
cis2. <c, g'>4 |
}
\\
\relative {
ais'2 cis, |
fis8 b a4 cis2 |
}
>>
}

musicB = {
\clef bass
\new Voice {
\voiceTwo \relative {
<fis a cis>8[ <fis a cis>
\change Staff = up
cis' cis
\change Staff = down
<fis, a> <fis a>]
\showStaffSwitch
\change Staff = up
dis'4 |
\change Staff = down
<fis, a cis>4 gis <f a d>2 |
}
}
}

\new PianoStaff {
<<
\new Staff = "up" {
\accidentalStyle default
\musicA
}
\new Staff = "down" {
\accidentalStyle default
\musicB
}
>>
}

Note that the last lines of this example can be replaced by the following, as long as the same accidental style should be used in both staves.

\new PianoStaff {
<<
\new Staff = "up" {
%%% change the next line as desired:
\accidentalStyle Score.default
\musicA
}
\new Staff = "down" {
\musicB
}
>>
}

default

This is the default typesetting behavior. It corresponds to eighteenth-century common practice: accidentals are remembered to the end of the measure in which they occur and only in their own octave. Thus, in the example below, no natural signs are printed before the b in the second measure or the last c:

voice

The normal behavior is to remember the accidentals at Staff-level. In this style, however, accidentals are typeset individually for each voice. Apart from that, the rule is similar to default.

As a result, accidentals from one voice do not get canceled in other voices, which is often an unwanted result: in the following example, it is hard to determine whether the second a should be played natural or sharp. The voice option should therefore be used only if the voices are to be read solely by individual musicians. If the staff is to be used by one musician (e.g., a conductor or in a piano score) then modern or modern-cautionary should be used instead.

modern

This rule corresponds to the common practice in the twentieth century. It omits some extra natural signs, which were traditionally prefixed to a sharp following a double sharp, or a flat following a double flat. The modern rule prints the same accidentals as default, with two additions that serve to avoid ambiguity: after temporary accidentals, cancellation marks are printed also in the following measure (for notes in the same octave) and, in the same measure, for notes in other octaves. Hence the naturals before the b and the c in the second measure of the upper staff:

modern-cautionary

This rule is similar to modern, but the ‘extra’ accidentals are printed as cautionary accidentals (with parentheses). They can also be printed at a different size by overriding AccidentalCautionary’s font-size property.

modern-voice

This rule is used for multivoice accidentals to be read both by musicians playing one voice and musicians playing all voices. Accidentals are typeset for each voice, but they are canceled across voices in the same Staff. Hence, the a in the last measure is canceled because the previous cancellation was in a different voice, and the d in the lower staff is canceled because of the accidental in a different voice in the previous measure:

modern-voice-cautionary

This rule is the same as modern-voice, but with the extra accidentals (the ones not typeset by voice) typeset as cautionaries. Even though all accidentals typeset by default are typeset with this rule, some of them are typeset as cautionaries.

piano

This rule reflects twentieth-century practice for piano notation. Its behavior is very similar to modern style, but here accidentals also get canceled across the staves in the same GrandStaff or PianoStaff, hence all the cancellations of the final notes.

This accidental style applies to the current GrandStaff or PianoStaff unless qualified with a second argument.

piano-cautionary

This is the same as piano but with the extra accidentals typeset as cautionaries.

choral

This rule is a combination of the modern-voice and the piano style. It shows all accidentals required for singers that only follow their own voice, as well as additional accidentals for readers that follow all voices of an entire ChoirStaff simultaneously.

This accidental style applies to the current ChoirStaff unless qualified with a second argument.

choral-cautionary

This is the same as choral but with the extra accidentals typeset as cautionaries.

neo-modern

This rule reproduces a common practice in contemporary music: accidentals are printed like with modern, but they are printed again if the same note appears later in the same measure – except if the note is immediately repeated.

neo-modern-cautionary

This rule is similar to neo-modern, but the ‘extra’ accidentals are printed as cautionary accidentals (with parentheses). They can also be printed at a different size by overriding AccidentalCautionary’s font-size property.

neo-modern-voice

This rule is used for multivoice accidentals to be read both by musicians playing one voice and musicians playing all voices. Accidentals are typeset for each voice as with neo-modern, but they are canceled across voices in the same Staff.

neo-modern-voice-cautionary

This rule is similar to neo-modern-voice, but the extra accidentals are printed as cautionary accidentals.

dodecaphonic

This rule reflects a practice introduced by composers at the beginning of the 20th century, in an attempt to abolish the hierarchy between natural and non-natural notes. With this style, every note gets an accidental sign, including natural signs.

dodecaphonic-no-repeat

Like with the dodecaphonic accidental style every note gets an accidental sign by default, but accidentals are suppressed for pitches immediately repeated within the same staff.

dodecaphonic-first

Similar to the dodecaphonic accidental style every pitch gets an accidental sign, but only the first time it is encountered in a measure. Accidentals are only remembered for the actual octave but throughout voices.

teaching

This rule is intended for students, and makes it easy to create scale sheets with automatically created cautionary accidentals. Accidentals are printed like with modern, but cautionary accidentals are added for all sharp or flat tones specified by the key signature, except if the note is immediately repeated.

no-reset

This is the same as default but with accidentals lasting ‘forever’ and not only within the same measure:

forget

This is the opposite of no-reset: Accidentals are not remembered at all – and hence all accidentals are typeset relative to the key signature, regardless of what came before in the music.

Snippets: Pitches.

#### Known issues and warnings

Simultaneous notes are not considered in the automatic determination of accidentals; only previous notes and the key signature are considered. Forcing accidentals with ! or ? may be required when the same note name occurs simultaneously with different alterations, as in ‘<f! fis!>’.

In alternative endings, cautionary cancellation should be based on the previous played measure, but it is based on the previous printed measure. In the following example, the natural c in the second alternative does not need a natural sign:

The following workaround can be used: define a function that locally changes the accidental style to forget:

forget = #(define-music-function (music) (ly:music?) #{
\accidentalStyle forget
#music
\accidentalStyle modern
#})
{
\accidentalStyle modern
\time 2/4
\repeat volta 2 {
c'2
}
\alternative {
\volta 1 { cis' }
\volta 2 { \forget c' }
}
}

#### Alternate accidental glyphs

Non-Western and ancient notation systems have their own accidentals. The glyphs are controlled through the alterationGlyphs property of the Staff context and similar context types. The predefined values for this property are listed in Accidental glyph sets.

\layout {
\context {
\Staff
alterationGlyphs = #alteration-vaticana-glyph-name-alist
}
}

{ ces' c' cis' }

The property may also be set to a custom associative list mapping alterations to glyph names. Alterations are given as fractions in tones. Glyphs are listed at Accidental glyphs.

\layout {
\context {
\Staff
alterationGlyphs =
#'((-1/2 . "accidentals.flat.arrowdown")
(0 . "accidentals.natural.arrowup")
(1/2 . "accidentals.sharp.arrowup"))
}
}

{ ces' c' cis' }

The padding-pairs property of KeySignature and KeyCancellation objects is an associative list mapping pairs of glyphs to the padding that should be added between these glyphs in key signatures.

\layout {
\context {
\Staff
alterationGlyphs =
#'((-1/2 . "accidentals.flat.arrowdown")
(0 . "accidentals.natural.arrowup")
(1/2 . "accidentals.sharp.arrowup"))
#'((("accidentals.sharp.arrowup" . "accidentals.sharp.arrowup")
. 0.25)
(("accidentals.flat.arrowdown" . "accidentals.flat.arrowdown")
. 0.3))
#'((("accidentals.natural.arrowup" . "accidentals.natural.arrowup")
. 0.7))
}
}

{
\key cis \major
ces' c'
\key ces \major
cis'
}

Notation Reference: Accidental glyph sets, Accidental glyphs.

Internals Reference: accidental-switch-interface, Alteration_glyph_engraver, key-signature-interface.

#### Ambitus

The term ambitus (pl. ambitus) denotes a range of pitches for a given voice in a part of music. It may also denote the pitch range that a musical instrument is capable of playing. Ambitus are printed on vocal parts so that performers can easily determine if it matches their capabilities.

Ambitus are denoted at the beginning of a piece near the initial clef. The range is graphically specified by two note heads that represent the lowest and highest pitches. Accidentals are only printed if they are not part of the key signature.

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

\relative {
aes' c e2
cis,1
}

#### Selected Snippets

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

#### Ambitus with multiple voices

Adding the Ambitus_engraver to the Staff context creates a single ambitus per staff, even in the case of staves with multiple voices.

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

#### Changing the ambitus gap

It is possible to change the default gap between the ambitus noteheads and the line joining them.

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

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

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

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

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

#### Ambitus after key signature

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

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

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

Music Glossary: ambitus.

Snippets: Pitches.

Internals Reference: Ambitus_engraver, Voice, Staff, Ambitus, AmbitusAccidental, AmbitusLine, AmbitusNoteHead, ambitus-interface.

#### Known issues and warnings

There is no collision handling in the case of multiple per-voice ambitus.

This section suggests ways of altering note heads.

The appearance of note heads may be altered:

\relative c'' {
c4 b
c4 b
a b
a b
c4 d e f
}

The cross style is used to represent a variety of musical intentions. The following generic predefined commands modify the note head in both staff and tablature contexts and can be used to represent any musical meaning:

\relative {
c''4 b
\xNotesOn
a b c4 b
\xNotesOff
c4 d
}

The music function form of this predefined command may be used inside and outside chords to generate crossed note heads in both staff and tablature contexts:

\relative {
c''4 b
\xNote { e f }
c b < g \xNote c f > b
}

As synonyms for \xNote, \xNotesOn and \xNotesOff, \deadNote, \deadNotesOn and \deadNotesOff can be used. The term dead note is commonly used by guitarists.

There is also a similar shorthand for diamond shapes:

\relative c'' {
<c f\harmonic>2 <d a'\harmonic>4 <c g'\harmonic> f\harmonic
}

#### Predefined commands

\harmonic, \xNotesOn, \xNotesOff, \xNote.

Snippets: Pitches.

Notation Reference: Note head styles, Chorded notes, Indicating harmonics and dampened notes.

The ‘easy play’ note head includes a note name inside the head. It is used in music for beginners. To make the letters readable, it should be printed in a large font size. To print with a larger font, see Setting the staff size.

#(set-global-staff-size 26)
\relative c' {
c2 e4 f
g1
c,1
}

#### Predefined commands

\easyHeadsOn, \easyHeadsOff.

#### Numbers as easy note heads

Easy notation note heads use the note-names property of the NoteHead object to determine what appears inside the note head. By overriding this property, it is possible to print numbers representing the scale-degree.

A simple engraver can be created to do this for every note head object it sees.

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

#(set-global-staff-size 26)

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

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

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

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

Notation Reference: Setting the staff size.

Snippets: Pitches.

In shape note head notation, the shape of the note head corresponds to the harmonic function of a note in the scale. This notation was popular in nineteenth-century American song books. Shape note heads can be produced in Sacred Harp, Southern Harmony, Funk (Harmonia Sacra), Walker, and Aiken (Christian Harmony) styles:

\relative c'' {
c, d e f g2 a b1 c \break
c,4 d e f g2 a b1 c \break
c,4 d e f g2 a b1 c \break
c,4 d e f g2 a b1 c \break
c,4 d e f g2 a b1 c \break
c,4 d e f g2 a b1 c \break
}

Shapes are typeset according to the step in the scale, where the base of the scale is determined by the \key command. When writing in a minor key, the scale step can be determined from the relative major:

\relative c'' {
\key a \minor
a b c d e2 f g1 a \break
a,4 b c d e2 f g1 a \break
a,4 b c d e2 f g1 a \break
a,2 b c d \break
a2 b c d \break
a2 b c d \break
a2 b c d \break
}

#### Predefined commands

\aikenHeads, \aikenHeadsMinor, \aikenThinHeads, \aikenThinHeadsMinor, \funkHeads, \funkHeadsMinor, \sacredHarpHeads, \sacredHarpHeadsMinor, \southernHarmonyHeads, \southernHarmonyHeadsMinor, \walkerHeads, \walkerHeadsMinor.

#### Selected Snippets

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

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

\set shapeNoteStyles = ##(doThin reThin miThin
faThin sol laThin tiThin)
c'' a' c' a
}
}

#### 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 = {
\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
}
}

Snippets: Pitches.

#### Improvisation

Improvisation is sometimes denoted with slashed note heads, where the performer may choose any pitch but should play the specified rhythm. Such note heads can be created:

\new Voice \with {
\consists Pitch_squash_engraver
} \relative {
e''8 e g a a16( bes) a8 g
\improvisationOn
e8 ~
2 ~ 8 f4 f8 ~
2
\improvisationOff
a16( bes) a8 g e
}

#### Predefined commands

\improvisationOn, \improvisationOff.

Snippets: Pitches.

Internals Reference: Pitch_squash_engraver, Voice, RhythmicStaff.

## 1.2 Rhythms

This section discusses rhythms, rests, durations, beaming and bars.

### 1.2.1 Writing rhythms

#### Durations

The durations of notes are entered using numbers and dots. The number entered is based on the reciprocal value of the length of the note. For example, a quarter note is designated using the numerical value of 4 as it is a 1/4 note, a half note using 2, an eighth using 8 and so on. Durations as short as 1024 notes can be entered but shorter values, while possible, can only be entered as beamed notes. Also see Beams.

For notes longer than a whole use the \longa – double breve – and \breve commands. A note with the duration of a quadruple breve is possible using the \maxima command but is only supported within ancient music notation. See Ancient notation.

\relative {
\time 8/1
c''\longa c\breve c1 c2
c4 c8 c16 c32 c64 c128 c128
}

Here are the same durations with automatic beaming turned off.

\relative {
\time 8/1
\autoBeamOff
c''\longa c\breve c1 c2
c4 c8 c16 c32 c64 c128 c128
}

Isolated durations – durations without a pitch – that occur within a music sequence will take their pitch from the preceding note or chord.

\relative {
\time 8/1
c'' \longa \breve 1 2
4 8 16 32 64 128 128
}

Isolated pitches – pitches without a duration – that occur within a music sequence will take their duration from the preceding note or chord. If there is no preceding duration, then default for the note is always 4, a quarter note.

\relative { a' a a2 a a4 a a1 a }

Place a dot (.) after the duration to obtain ‘dotted’ note lengths. Double-dotted notes are specified by appending two dots, and so on.

\relative { a'4 b c4. b8 a4. b4.. c8. }

To avoid clashing with staff lines, dots on notes are normally moved up. In polyphonic situations however, they can be placed, manually, above or below the staff as required. See Direction and placement.

Some note durations cannot be represented using just numbers and dots but only by tying two or more notes together. See Ties.

To specify durations that align the syllables of lyrics and notes together see Vocal music.

Notes can also be spaced proportionately to their duration, see Proportional notation.

#### Predefined commands

\autoBeamOn, \autoBeamOff, \dotsUp, \dotsDown, \dotsNeutral.

#### Alternative breve notes

Breve notes are also available with two vertical lines on each side of the notehead instead of one line and in baroque style.

\relative c'' {
\time 4/2
c\breve |
b\breve
b\breve
a\breve
}

#### Changing the number of augmentation dots per note

The number of augmentation dots on a single note can be changed independently of the dots placed after the note.

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

Music Glossary: breve, longa, maxima, note value, Duration names notes and rests.

Notation Reference: Beams, Ties, Stems, Writing rhythms, Writing rests, Vocal music, Ancient notation, Proportional notation.

Snippets: Rhythms.

Internals Reference: Dots, DotColumn.

#### Known issues and warnings

While there is no fundamental limit to rest durations (longest or shortest), there is a limit to the number of glyphs possible so only rests between 1024 and \maxima may be printed.

#### Tuplets

Tuplets are made from a music expression with the \tuplet command, multiplying the speed of the music expression by a fraction:

\tuplet fraction { music }

The fraction’s numerator will be printed over or under the notes, optionally with a bracket. The most common tuplets are triplets (3 notes played within the duration normally allowed for 2).

\relative {
a'2 \tuplet 3/2 { b4 4 4 }
c4 c \tuplet 3/2 { b4 a g }
}

When entering long passages of tuplets, having to write a separate \tuplet command for each group is inconvenient. It is possible to specify the duration of one tuplet group directly before the music in order to have the tuplets grouped automatically:

\relative {
g'2 r8 \tuplet 3/2 8 { cis16 d e e f g g f e }
}

Tuplet brackets may be manually placed above or below the staff:

\relative {
\tupletUp \tuplet 3/2 { c''8 d e }
\tupletNeutral \tuplet 3/2 { c8 d e }
\tupletDown \tuplet 3/2 { f,8 g a }
\tupletNeutral \tuplet 3/2 { f8 g a }
}

Tuplets may be nested:

\relative {
\autoBeamOff
c''4 \tuplet 5/4 { f8 e f \tuplet 3/2 { e[ f g] } } f4
}

Modifying nested tuplets which begin at the same musical moment must be done with \tweak; see The \tweak command.

Tuplet brackets may be replaced with slurs, as is preferred in many older editions:

\relative {
\tuplet 3/2 4 {
\override TupletBracket.tuplet-slur = ##t
c'4 e8 d4 f8
\override TupletBracket.bracket-visibility = ##t
e f g f e d
} c1
}

By default, a bracket is only printed if all of the notes it spans are not beamed together; in some cases (for example with slurs, as in the example above) it may be preferrable to change that behavior, through the bracket-visibility property as detailed in one of the following snippets.

More generally, either or both the TupletBracket and TupletNumber objects may be hidden or shown as explained in Visibility of objects; however, a more flexible way of modifying the duration of notes without printing a tuplet bracket is also introduced in Scaling durations.

#### Predefined commands

\tupletUp, \tupletDown, \tupletNeutral.

#### Entering several tuplets using only one tuplet command

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

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

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

#### Changing the tuplet number

By default, only the numerator of the tuplet number is printed over the tuplet bracket, i.e., the numerator of the argument to the \tuplet command.

Alternatively, num:den of the tuplet number may be printed, or the tuplet number may be suppressed altogether.

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

#### Non-default tuplet numbers

LilyPond also provides formatting functions to print tuplet numbers different than the actual fraction, as well as to append a note value to the tuplet number or tuplet fraction.

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

#### Controlling tuplet bracket visibility

The default behavior of tuplet-bracket visibility is to print a bracket unless there is a beam of the same length as the tuplet.

To control the visibility of tuplet brackets, set the property 'bracket-visibility to either #t (always print a bracket), 'if-no-beam (only print a bracket if there is no beam, which is the default behavior), or #f (never print a bracket). The latter is in fact equivalent to omitting the @code{TupletBracket} object altogether from the printed output.

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

\new Voice {
\relative c' {
<< \music s4^"default" >>
\override TupletBracket.bracket-visibility = #'if-no-beam
<< \music s4^"'if-no-beam" >>
\override TupletBracket.bracket-visibility = ##t
<< \music s4^"#t" >>
\override TupletBracket.bracket-visibility = ##f
<< \music s4^"#f" >>
\omit TupletBracket
<< \music s4^"omit" >>
}
}

#### Permitting line breaks within beamed tuplets

This artificial example shows how both manual and automatic line breaks may be permitted to within a beamed tuplet. Note that such off-beat tuplets have to be beamed manually.

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

Music Glossary: triplet, tuplet, polymetric.

Learning Manual: Tweaking methods.

Snippets: Rhythms.

Internals Reference: TupletBracket, TupletNumber, TimeScaledMusic.

#### Scaling durations

The duration of single notes, rests or chords may be multiplied by a fraction N/M by appending *N/M (or *N if M is 1) to the duration. Factors may also be added by using Scheme expressions evaluating to a number or musical length like *#(ly:music-length music). This is convenient for scaling a duration of ‘1’ to let a note or multi-measure rest stretch to a length derived from a music variable.

Adding a factor will not affect the appearance of the notes or rests produced, but the altered duration will be used in calculating the position within the measure and setting the duration in the MIDI output. Multiplying factors may be combined like *L*M/N. Factors are part of the duration: if a duration is not specified for subsequent notes, the default duration taken from the preceding note will include any scaling factor.

In the following example, the first three notes take up exactly two beats, but no triplet bracket is printed.

\relative {
\time 2/4
% Alter durations to triplets
a'4*2/3 gis a
% Normal durations
a4 a
% Double the duration of chord
<a d>4*2
% Duration of quarter, appears like sixteenth
b16*4 c4
}

The duration of spacer rests may also be modified by a multiplier. This is useful for skipping many measures, e.g., s1*23.

Longer stretches of music may be compressed by a fraction in the same way, as if every note, chord or rest had the fraction as a multiplier. This leaves the appearance of the music unchanged but the internal duration of the notes will be multiplied by the given scale factor, usually num/den. Here is an example showing how music can be compressed and expanded:

\relative {
\time 2/4
% Normal durations
<c'' a>4 c8 a
% Scale music by *2/3
\scaleDurations 2/3 {
<c a f>4. c8 a f
}
% Scale music by *2
\scaleDurations 2 {
<c' a>4 c8 b
}
}

One application of this command is in polymetric notation, see Polymetric notation.

Notation Reference: Tuplets, Invisible rests, Polymetric notation.

Snippets: Rhythms.

#### Known issues and warnings

The calculation of the position within a measure must take into account all the scaling factors applied to the notes within that measure and any fractional carry-out from earlier measures. This calculation is carried out using rational numbers. If an intermediate numerator or denominator in that calculation exceeds 2^30 the execution and typesetting will stop at that point without indicating an error.

#### Ties

A tie connects two adjacent note heads of the same pitch. The tie in effect extends the duration of a note.

Ties that connect notes to nothing are called laissez vibrer articulation; see Laissez vibrer, for the \laissezVibrer command. Ties that connect nothing to notes (as needed in seconda volta sections, for example), can be entered with the \repeatTie command; see Repeat tie.

Note: Ties should not be confused with slurs, which indicate articulation, or phrasing slurs, which indicate musical phrasing. A tie is just a way of extending a note duration, similar to the augmentation dot.

A tie is entered by appending a tilde symbol (~) to the first of each pair of notes being tied. This indicates that the note should be tied to the following note, which must be at the same pitch.

{ a'2~ 4~ 16 r r8 }

Ties can make use of the ‘last explicit pitch’ interpretation of isolated durations:

{ a'2~ 4~ 16 r r8 }

Ties are used either when the note crosses a bar line, or when dots cannot be used to denote the rhythm. Ties should also be used when note values cross larger subdivisions of the measure:

\relative {
r8 c'4.~ 4 r4 |
r8^"not" c2~ 8 r4
}

If you need to tie many notes across bar lines, it may be easier to use automatic note splitting, see Automatic note splitting. This mechanism automatically splits long notes, and ties them across bar lines.

When a tie is applied to a chord, all note heads whose pitches match are connected. When no note heads match, no ties will be created. Chords may be partially tied by placing the ties inside the chord.

\relative c' {
<c e g>2~ 2 |
<c e g>4~ <c e g c>
<c~ e g~ b> <c e g b> |
}

When a tie continues into alternative endings, you have to specify the repeated tie as follows:

\relative {
\repeat volta 2 { c'' g <c e>2~ }
\alternative {
% the following note is tied normally
\volta 1 { <c e>2. r4 }
% the following note has a repeated tie
\volta 2 { <c e>2\repeatTie d4 c }
}
}

L.v. ties (laissez vibrer) indicate that notes must not be damped at the end. It is used in notation for piano, harp and other string and percussion instruments. They can be entered as follows:

<c' f' g'>1\laissezVibrer

Ties may be made to curve up or down manually; see Direction and placement.

Ties may be made dashed, dotted, or a combination of solid and dashed.

\relative c' {
\tieDotted
c2~ 2
\tieDashed
c2~ 2
\tieHalfDashed
c2~ 2
\tieHalfSolid
c2~ 2
\tieSolid
c2~ 2
}

Custom dash patterns can be specified:

\relative c' {
\tieDashPattern #0.3 #0.75
c2~ 2
\tieDashPattern #0.7 #1.5
c2~ 2
\tieSolid
c2~ 2
}

Dash pattern definitions for ties have the same structure as dash pattern definitions for slurs. For more information about complex dash patterns, see Slurs.

Override whiteout and layer layout properties of objects that should cause a gap in ties.

\relative {
\override Tie.layer = #-2
\override Staff.TimeSignature.layer = #-1
\override Staff.KeySignature.layer = #-1
\override Staff.TimeSignature.whiteout = ##t
\override Staff.KeySignature.whiteout = ##t
b'2 b~
\time 3/4
\key a \major
b r4
}

#### Predefined commands

\tieUp, \tieDown, \tieNeutral, \tieDotted, \tieDashed, \tieDashPattern, \tieHalfDashed, \tieHalfSolid, \tieSolid.

#### Using ties with arpeggios

Ties are sometimes used to write out arpeggios. In this case, two tied notes need not be consecutive. This can be achieved by setting the tieWaitForNote property to #t. The same feature is also useful, for example, to tie a tremolo to a chord, but in principle, it can also be used for ordinary consecutive notes.

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

#### Engraving ties manually

Ties may be engraved manually by changing the tie-configuration property of the TieColumn object. The first number indicates the distance from the center of the staff in half staff-spaces, and the second number indicates the direction (1 = up, -1 = down).

Note that LilyPond makes a distinction between exact and inexact values for the first number. If using an exact value (i.e., either an integer or a fraction like (/ 4 5)), the value serves as a rough vertical position that gets further tuned by LilyPond to make the tie avoid staff lines. If using an inexact value like a floating point number, it is taken as the vertical position without further adjustments.

\relative c' {
<c e g>2~ <c e g>
\override TieColumn.tie-configuration =
#'((0.0 . 1) (-2.0 . 1) (-4.0 . 1))
<c e g>2~ <c e g>
\override TieColumn.tie-configuration =
#'((0 . 1) (-2 . 1) (-4 . 1))
<c e g>2~ <c e g>
}

Music Glossary: tie, laissez vibrer.

Notation Reference: Slurs, Automatic note splitting.

Snippets: Expressive marks, Rhythms.

Internals Reference: LaissezVibrerTie, LaissezVibrerTieColumn, TieColumn, Tie.

#### Known issues and warnings

Switching staves when a tie is active will not produce a slanted tie.

Changing clefs or ottavations during a tie is not really well-defined. In these cases, a slur may be preferable.

### 1.2.2 Writing rests

Rests are entered as part of the music in music expressions.

#### Rests

Rests are entered like notes with the note name r. Durations longer than a whole rest use the following predefined commands:

\new Staff {
% These two lines are just to prettify this example
\time 16/1
\omit Staff.TimeSignature
% Print a maxima rest, equal to four breves
r\maxima
% Print a longa rest, equal to two breves
r\longa
% Print a breve rest
r\breve
r1 r2 r4 r8 r16 r32 r64 r128
}

Whole measure rests, centered in the middle of the measure, must be entered as multi-measure rests. They can be used for a single measure as well as many measures and are discussed in Full measure rests.

To explicitly specify a rest’s vertical position, write a note followed by \rest. A rest of the duration of the note will be placed at the staff position where the note would appear. This allows for precise manual formatting of polyphonic music, since the automatic rest collision formatter will not move these rests.

\relative { a'4\rest d4\rest }

#### Rest styles

Rests may be used in various styles.

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

\override Staff.Rest.style = #'mensural
r\maxima^\markup \typewriter { mensural }
r\longa r\breve r1 r2 r4 r8 r16 s32 s64 s128 s128
\bar ""
\break

\override Staff.Rest.style = #'neomensural
r\maxima^\markup \typewriter { neomensural }
r\longa r\breve r1 r2 r4 r8 r16 s32 s64 s128 s128
\bar ""
\break

\override Staff.Rest.style = #'classical
r\maxima^\markup \typewriter { classical }
r\longa r\breve r1 r2 r4 r8 r16 r32 r64 r128 s128
\bar ""
\break

\override Staff.Rest.style = #'z
r\maxima^\markup \typewriter { z-style }
r\longa r\breve r1 r2 r4 r8 r16 r32 r64 r128 s128
\bar ""
\break

\override Staff.Rest.style = #'default
r\maxima^\markup \typewriter { default }
r\longa r\breve r1 r2 r4 r8 r16 r32 r64 r128 s128
}

Music Glossary: breve, longa, maxima.

Notation Reference: Full measure rests.

Snippets: Rhythms.

Internals Reference: Rest.

#### Known issues and warnings

There is no fundamental limit to rest durations (both in terms of longest and shortest), but the number of glyphs is limited: there are rests from 1024th to maxima (8× whole).

#### Invisible rests

There are two forms of invisible rests: the spacer rest named ‘s’, and the \skip command. The spacer rest is a note that does not produce output. Like any other note or rest, its duration sets the default duration of following notes.

\relative c'' {
c4 c s c |
s2 c |
}

Also like other notes and rests, it implicitly causes Staff and Voice contexts to be created if none exist.

{ s1 s s }

Spacer rests are available only in note mode and chord mode. In other situations, for example, when entering lyrics, the command \skip is used to skip a musical moment. The \skip command accepts either an explicit duration or a piece of music as an argument and skips the duration of the argument. The duration of the \skip is ignored if lyrics derive their durations from the notes in an associated melody through \addlyrics or \lyricsto.

<<
{
a'2 \skip2 a'2 a'2
}
\new Lyrics {
\lyricmode {
foo2 \skip 1 bla2
}
}
>>

When the argument to \skip is music, the default duration of the following note is implicitly set by the last note of the argument. However, to preserve backward compatibility with the legacy implementation of \skip, a numeric duration argument does not affect the duration of the subsequent note.

<<
{
\repeat unfold 12 { a'4 }
}
{
a'4 \skip 2 a' |
a'4 \skip { a'8 a' a' a' } a' a' |
s2 a'
}
>>

The \skip command preserves the effect of an enclosing unfoldRepeats command, unlike the skip-of-length Scheme function.

MyCadenza = \fixed c' {
\repeat volta 2 {
d8 e f g g4 f4
}
}

music = <<
\new Staff {
c'1
}
\new Staff {
c'1
}
\new Staff {
c'1
}
>>

\unfoldRepeats \music

The \skip command simply skips musical time; it creates no output of any kind.

% This is valid input, but does nothing
{ \skip 1 \skip1 \skip 1 }

Learning Manual: Visibility and color of objects.

Notation Reference: Hidden notes, Visibility of objects.

Snippets: Rhythms.

Internals Reference: SkipMusic.

#### Known issues and warnings

Because duration and music arguments to the \skip command affect the duration of subsequent music differently, it is good practice to provide an explicit duration for the music immediately following the command.

#### Full measure rests

Rests for one or more full measures are entered like notes with the note name uppercase ‘R’. Their duration is entered identically to the duration notation used for notes, including the ability to use duration multipliers, as explained in Scaling durations:

% Rest measures contracted to single measure
\compressMMRests {
R1*4
R1*24
R1*4
b'2^"Tutti" b'4 a'4
}

The example above also demonstrates how to compress multiple empty measures, as explained in Compressing empty measures.

The duration of a multi-measure rest must always be equal to the length of one or several measures. Therefore, some time signatures require the use of augmentation dots or fractions:

\compressMMRests {
\time 2/4
R1 | R2 |
\time 3/4
R2. | R2.*2 |
\time 13/8
R1*13/8 | R1*13/8*12 |
\time 10/8
R4*5*4 |
}

A full-measure rest is printed as either a whole or breve rest, centered in the measure, depending on the time signature.

\time 4/4
R1 |
\time 6/4
R1*3/2 |
\time 8/4
R1*2 |

Markups can be added to multi-measure rests.

\compressMMRests {
\time 3/4
R2.*10^\markup { \italic "ad lib." }
}

Note: Markups and articulations attached to multi-measure rests are MultiMeasureRestText and MultiMeasureRestScript types, not TextScript and Script. Overrides must be directed to the correct object, or they will be ignored. See the following example:

% This fails, as the wrong object name is specified
\override Script.color = #blue
R1^"wrong"
R1\fermata
% This is the correct object name to be specified
\override MultiMeasureRestScript.color = #blue
R1^"right"
R1\fermata

When a multi-measure rest immediately follows a \partial setting, resulting bar-check warnings may not be displayed.

#### Predefined commands

\textLengthOn, \textLengthOff, \compressMMRests.

#### Multi-measure rest length control

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

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

#### Positioning multi-measure rests

Unlike ordinary rests, there is no predefined command to change the staff position of a multi-measure rest symbol of either form by attaching it to a note. However, in polyphonic music multi-measure rests in odd-numbered and even-numbered voices are vertically separated.

The positioning of multi-measure rests can be controlled as follows:

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

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

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

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

#### Multi-measure rest markup

Markups attached to a multi-measure rest will be centered above or below it. Long markups attached to multi-measure rests do not cause the measure to expand. To expand a multi-measure rest to fit the markup, use an empty chord with an attached markup before the multi-measure rest. Text attached to a spacer rest in this way is left-aligned to the position where the note would be placed in the measure, but if the measure length is determined by the length of the text, the text will appear to be centered.

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

Music Glossary: multi-measure rest.

Notation Reference: Durations, Scaling durations, Compressing empty measures, Text, Formatting text, Text scripts.

Snippets: Rhythms.

Internals Reference: MultiMeasureRest, MultiMeasureRestNumber, MultiMeasureRestScript, MultiMeasureRestText.

#### Known issues and warnings

Fingerings over multi-measure rests (e.g., R1*10-4) may result in the fingering numeral colliding with the bar counter numeral.

There is no way to automatically condense multiple ordinary rests into a single multi-measure rest.

Multi-measure rests do not take part in rest collisions.

### 1.2.3 Displaying rhythms

#### Time signature

The time signature is set as follows:

\time 2/4 c''2
\time 3/4 c''2.

Mid-measure time signature changes are covered in Upbeats.

Time signatures are printed at the beginning of a piece and whenever the time signature changes. If a change takes place at the end of a line a warning time signature sign is printed there. This default behavior may be changed, see Visibility of objects.

\relative c'' {
\time 2/4
c2 c
\break
c c
\break
\time 4/4
c c c c
}

The time signature symbol that is used in 2/2 and 4/4 time can be changed to a numeric style:

\relative c'' {
% Default style
\time 4/4 c1
\time 2/2 c1
% Change to numeric style
\numericTimeSignature
\time 4/4 c1
\time 2/2 c1
% Revert to default style
\defaultTimeSignature
\time 4/4 c1
\time 2/2 c1
}

Mensural time signatures are covered in Mensural time signatures.

In addition to setting the printed time signature, the \time command also sets the values of the time-signature-based properties baseMoment, beatStructure, and beamExceptions. The predefined default values for these properties can be found in ‘scm/time-signature-settings.scm’.

The default value of beatStructure can be overridden in the \time command itself by supplying it as the optional first argument:

\score {
\new Staff {
\relative {
\time 2,2,3 7/8
\repeat unfold 7 { c'8 } |
\time 3,2,2 7/8
\repeat unfold 7 { c8 } |
}
}
}

Alternatively, the default values of all these time-signature-based variables, including baseMoment and beamExceptions, can be set together. The values can be set independently for several different time signatures. The new values take effect when a subsequent \time command with the same value of the time signature is executed:

\score {
\new Staff {
\relative c' {
\overrideTimeSignatureSettings
4/4        % timeSignatureFraction
1/4        % baseMomentFraction
3,1        % beatStructure
#'()       % beamExceptions
\time 4/4
\repeat unfold 8 { c8 } |
}
}
}

\overrideTimeSignatureSettings takes four arguments:

1. timeSignatureFraction, a fraction describing the time signature to which these values apply.
2. baseMomentFraction, a fraction containing the numerator and denominator of the basic timing unit for the time signature.
3. beatStructure, a Scheme list indicating the structure of the beats in the measure, in units of the base moment.
4. beamExceptions, an alist containing any beaming rules for the time signature that go beyond ending at every beat, as described in Setting automatic beam behavior.

Changed values of default time signature properties can be restored to the original values:

\score {
\relative {
\repeat unfold 8 { c'8 } |
\overrideTimeSignatureSettings
4/4        % timeSignatureFraction
1/4        % baseMomentFraction
3,1        % beatStructure
#'()       % beamExceptions
\time 4/4
\repeat unfold 8 { c8 } |
\revertTimeSignatureSettings 4/4
\time 4/4
\repeat unfold 8 { c8 } |
}
}

Different values of default time signature properties can be established for different staves by enabling polymetric notation (see Polymetric notation).

\score {
\new StaffGroup <<
\new Staff {
\overrideTimeSignatureSettings
4/4        % timeSignatureFraction
1/4        % baseMomentFraction
3,1        % beatStructure
#'()       % beamExceptions
\time 4/4
\repeat unfold 8 {c''8}
}
\new Staff {
\overrideTimeSignatureSettings
4/4        % timeSignatureFraction
1/4        % baseMomentFraction
1,3        % beatStructure
#'()       % beamExceptions
\time 4/4
\repeat unfold 8 {c''8}
}
>>
\layout {
\enablePolymeter
}
}

A further method of changing these time-signature-related variables, which avoids reprinting the time signature at the time of the change, is shown in Setting automatic beam behavior.

#### Predefined commands

\numericTimeSignature, \defaultTimeSignature.

#### Time signature printing only the numerator as a number (instead of the fraction)

Sometimes, a time signature should not print the whole fraction (for example, 7/4), but only the numerator (digit 7 in this case). This can be easily done by using \override Staff.TimeSignature.style = #'single-digit to change the style permanently. By using \revert Staff.TimeSignature.style, this setting can be reversed. To apply the single-digit style to only one time signature, use the \override command and prefix it with a \once.

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

Music Glossary: time signature

Installed Files: ‘scm/time-signature-settings.scm’.

Snippets: Rhythms.

Internals Reference: TimeSignature, Timing_translator.

#### Known issues and warnings

\numericTimeSignature and \defaultTimeSignature have no effect when used in a MensuralStaff. To use these modern time signatures in a MensuralStaff, either select them already when creating the context:

\new MensuralStaff \with { \numericTimeSignature } {
c'1
}

or use an explicit \override:

\new MensuralStaff {
\time 2/2
c'1
\override MensuralStaff.TimeSignature.style = #'numbered
\time 2/2
c'
\override MensuralStaff.TimeSignature.style = #'default
\time 2/2
c'
}

#### Metronome marks

A basic metronome mark is simple to write:

\relative {
\tempo 4 = 120
c'2 d
e4. d8 c2
}

Metronome marks may also be printed as a range of two numbers:

\relative {
\tempo 4 = 40 - 46
c'4. e8 a4 g
b,2 d4 r
}

Tempo indications with text can be used instead:

\relative {
\tempo "Allegretto"
c''4 e d c
b4. a16 b c4 r4
}

Combining a metronome mark and text will automatically place the metronome mark within parentheses:

\relative {
\tempo "Allegro" 4 = 160
g'4 c d e
d4 b g2
}

In general, the text can be any markup object:

\relative {
\tempo \markup { \italic Faster } 4 = 132
a'8-. r8 b-. r gis-. r a-. r
}

A parenthesized metronome mark with no textual indication may be written by including an empty string in the input:

\relative {
\tempo "" 8 = 96
d''4 g e c
}

In a part for an instrument with long periods of rests (see Full measure rests), tempo indications sometimes follow each other closely. The command \markLengthOn provides extra horizontal space to prevent tempo indications from overlapping, and \markLengthOff restores the default behavior of ignoring tempo marks for horizontal spacing.

\compressMMRests {
\markLengthOn
\tempo "Molto vivace"
R1*12
\tempo "Meno mosso"
R1*16
\markLengthOff
\tempo "Tranquillo"
R1*20
}

#### Printing metronome and rehearsal marks below the staff

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 {
indent = 0
ragged-right = ##f
}

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

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

#### Changing the tempo without a metronome mark

To change the tempo in MIDI output without printing anything, make the metronome mark invisible.

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

#### Creating metronome marks in markup mode

New metronome marks can be created in markup mode, but they will not change the tempo in MIDI output.

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

For more details, see Formatting text.

Music Glossary: metronome, metronomic indication, tempo indication, metronome mark.

Notation Reference: Formatting text, Creating MIDI output, Full measure rests.

Snippets: Staff notation.

Internals Reference: MetronomeMark.

#### Upbeats

Partial or pickup measures, such as an anacrusis or an upbeat, are entered using the \partial command:

\partial duration

When \partial is used at the beginning of a score, duration is the length of the music preceding the first bar.

\relative {
\time 3/4
\partial 4.
r4 e'8 | a4 c8 b c4 |
}

When \partial is used after the beginning of a score, duration is the remaining length of the current measure. It does not create a new numbered bar.

\relative {
\set Score.barNumberVisibility = #all-bar-numbers-visible
\override Score.BarNumber.break-visibility =
#end-of-line-invisible
\time 9/8
d''4.~ 4 d8 d( c) b | c4.~ 4. \bar "||"
\time 12/8
\partial 4.
c8( d) e | f2.~ 4 f8 a,( c) f |
}

The \partial command is required when the time signature changes in mid measure, but it may also be used alone.

\relative {
\set Score.barNumberVisibility = #all-bar-numbers-visible
\override Score.BarNumber.break-visibility =
#end-of-line-invisible
\time 6/8
\partial 8
e'8 | a4 c8 b[ c b] |
\partial 4
r8 e,8 | a4 \bar "||"
\partial 4
r8 e8 | a4
c8 b[ c b] |
}

The \partial command sets the Timing.measurePosition property, which is a rational number that indicates how much of the measure has passed.

Music Glossary: anacrusis.

Notation Reference: Grace notes.

Snippets: Rhythms.

Internal Reference: Timing_translator.

#### Unmetered music

In music such as cadenzas, it may be desirable to disable automatic measure demarcation and all that it entails: numbering bars, resetting accidentals, etc. Music between \cadenzaOn and \cadenzaOff does not count toward the length of a measure.

\relative c'' {
% Show all bar numbers
\override Score.BarNumber.break-visibility = #all-visible
c4 d e d
c4 cis d8[ d d] f4 g4.
d4 e d c
}

To divide an unmetered passage into irregular measures, temporarily re-enable timing and use \partial to create a tiny measure. The \bar command alone does not start a new measure.

cadenzaMeasure = {
\partial 1024 s1024
}

\relative c'' {
% Show all bar numbers
\override Score.BarNumber.break-visibility = #all-visible
c4 d e d
c4 cis \bar "!" d8[ d d] \cadenzaMeasure f4 g4.
d4 e d c
}

Automatic beaming is disabled by \cadenzaOn. Therefore, all beaming in cadenzas must be entered manually. See Manual beams.

\relative {
\repeat unfold 8 { c''8 }
cis8 c c c c
\bar"|"
c8 c c
\repeat unfold 8 { c8 }
}

These predefined commands affect all staves in the score, even when placed in just one Voice context. To change this, move the Timing_translator from the Score context to the Staff context. See Polymetric notation.

Within a cadenza section, automatic breaks are disabled: since there is no metric, it is not possible to determine automatically where they would be appropriate. Therefore, in a long cadenza passage, you must insert possible break points at appropriate places using the \allowBreak command.

\relative {
c'4 f g c, d f g c
c4 cis8
\allowBreak
d[ cis c cis]
\allowBreak
d[ f g a]
\allowBreak
ais[ g f g]
\allowBreak
d4 f8
\allowBreak
d[ cis] c4
\allowBreak
a8[ c] g4
}

#### Predefined commands

\cadenzaOn, \cadenzaOff.

Notation Reference: Visibility of objects, Polymetric notation, Manual beams, Accidentals.

Snippets: Rhythms.

#### Polymetric notation

Polymetric notation is supported explicitly or by manually modifying the visible time signature symbol and/or scaling note durations.

#### Different time signatures with equal-length measures

Set a common time signature for each staff, and set the timeSignatureFraction to the desired fraction. Then use the \scaleDurations function to scale the durations of the notes in each staff to the common time signature.

In the following example, music with the time signatures of 3/4, 9/8 and 10/8 are used in parallel. In the second staff, shown durations are multiplied by 2/3 (because 2/3 * 9/8 = 3/4) and in the third staff, the shown durations are multiplied by 3/5 (because 3/5 * 10/8 = 3/4). It may be necessary to insert beams manually, as the duration scaling will affect the autobeaming rules.

\relative <<
\new Staff {
\time 3/4
c'4 c c |
c4 c c |
}
\new Staff {
\time 3/4
\set Staff.timeSignatureFraction = 9/8
\scaleDurations 2/3
\repeat unfold 6 { c8[ c c] }
}
\new Staff {
\time 3/4
\set Staff.timeSignatureFraction = 10/8
\scaleDurations 3/5 {
\repeat unfold 2 { c8[ c c] }
\repeat unfold 2 { c8[ c] } |
c4. c \tuplet 3/2 { c8[ c c] } c4
}
}
>>

#### Different time signatures with unequal-length measures

Each staff can be given its own independent time signature as soon as \enablePolymeter is placed in the \layout block.

\layout {
\enablePolymeter
}

% Now each staff has its own time signature.

\relative <<
\new Staff {
\time 3/4
c'4 c c |
c4 c c |
}
\new Staff {
\time 2/4
c4 c |
c4 c |
c4 c |
}
\new Staff {
\time 3/8
c4. |
c8 c c |
c4. |
c8 c c |
}
>>

To have just one polymetric score, include \enablePolymeter in a \layout block inside the \score block.

\score {
<<
\new Staff { c''1 1 }
\new Staff { c'2 d' g'2~ 2 }
>>
}

\score {
\layout {
\enablePolymeter
}
<<
\new Staff { \time 4/4 c''1 1 }
\new Staff { \time 2/4 c'2 d' g'2~ 2 }
>>
}

When using polymeter, all staves should include a \time command if their meter is not the default 4/4. This is true even for special staves without actual staff lines, such as Dynamics contexts, since the placement of certain spanners like hairpins is synchronized with bar lines.

In order to use this feature with MIDI output, also include \enablePolymeter in a \midi block.

\layout {
\enablePolymeter
}

\midi {
\enablePolymeter
}

#### Compound time signatures

These are created using the \compoundMeter function. The syntax for this is:

\compoundMeter #'(list of lists)

The simplest construction is a single list, where the last number indicates the bottom number of the time signature and those that come before it, the top numbers.

\relative {
\compoundMeter #'((2 2 2 8))
\repeat unfold 6 c'8 \repeat unfold 12 c16
}

More complex meters can be constructed using additional lists. Also, automatic beaming settings will be adjusted depending on the values.

\relative {
\compoundMeter #'((1 4) (3 8))
\repeat unfold 5 c'8 \repeat unfold 10 c16
}

\relative {
\compoundMeter #'((1 2 3 8) (3 4))
\repeat unfold 12 c'8
}

Music Glossary: polymetric, polymetric time signature, meter.

Notation Reference: Automatic beams, Manual beams, Time signature, Scaling durations.

Snippets: Rhythms.

Internals Reference: TimeSignature, Timing_translator, Staff.

#### Known issues and warnings

Although notes that occur at the same moment in each of the different staves will be placed at the same horizontal location, bar lines (in each staff) may cause inconsistent spacing within each of the different time signatures.

#### Automatic note splitting

Long notes which overrun bar lines can be converted automatically to tied notes. This is done by replacing the Note_heads_engraver with the Completion_heads_engraver. Similarly, long rests which overrun bar lines are split automatically by replacing the Rest_engraver with the Completion_rest_engraver. In the following example, notes and rests crossing the bar lines are split, notes are also tied.

\new Voice \with {
\remove Rest_engraver
\consists Completion_rest_engraver
}
\relative {
c'2. c8 d4 e f g a b c8 c2 b4 a g16 f4 e d c8. c2 r1*2
}

These engravers split all running notes and rests at the bar line, and inserts ties for notes. One of its uses is to debug complex scores: if the measures are not entirely filled, then the ties show exactly how much each measure is off.

The property completionUnit sets a preferred duration for the split notes.

\new Voice \with {
} \relative {
\time 9/8 g\breve. d''4. \bar "||"
\set completionUnit = #(ly:make-moment 3 8)
g\breve. d4.
}

These engravers split notes with scaled duration, such as those in tuplets, into notes with the same scale factor as in the input note.

\new Voice \with {
} \relative {
\time 2/4 r4
\tuplet 3/2 {g'4 a b}
\scaleDurations 2/3 {g a b}
g4*2/3 a b
\tuplet 3/2 {g4 a b}
r4
}

Music Glossary: tie

Learning Manual: Engravers explained, Adding and removing engravers.

Snippets: Rhythms.

#### Known issues and warnings

For consistency with previous behavior, notes and rests with duration longer than a measure, such as c1*2, are split into notes without any scale factor, { c1 c1 }. The property completionFactor controls this behavior, and setting it to #f cause split notes and rests to have the scale factor of the input durations.

#### Showing melody rhythms

Sometimes you might want to show only the rhythm of a melody. This can be done with the rhythmic staff. All pitches of notes on such a staff are squashed, and the staff itself has a single line

<<
\new RhythmicStaff {
\new Voice = "myRhythm" \relative {
\time 4/4
c'4 e8 f g2
r4 g g f
g1
}
}
\new Lyrics {
\lyricsto "myRhythm" {
This is my song
I like to sing
}
}
>>

Guitar chord charts often show the strumming rhythms. This can be done with the Pitch_squash_engraver and \improvisationOn.

<<
\new ChordNames {
\chordmode {
c1 f g c
}
}
\new Voice \with {
\consists Pitch_squash_engraver
} \relative c'' {
\improvisationOn
c4 c8 c c4 c8 c
f4 f8 f f4 f8 f
g4 g8 g g4 g8 g
c4 c8 c c4 c8 c
}
>>

Music containing chords can also be used as input to RhythmicStaff and for use with the Pitch_squash_engraver if the chords are first reduced to single notes with the \reduceChords music function:

\new RhythmicStaff {
\time 4/4
\reduceChords {
<c>2
<e>2
<c e g>2
<c e g>4
<c e g>4
}
}

#### Predefined commands

\improvisationOn, \improvisationOff, \reduceChords.

#### Guitar strum rhythms

For guitar music, it is possible to show strum rhythms, along with melody notes, chord names and fret diagrams.

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

Snippets: Rhythms.

Internals Reference: RhythmicStaff, Pitch_squash_engraver.

### 1.2.4 Beams

#### Automatic beams

By default, beams are inserted automatically:

\relative c'' {
\time 2/4 c8 c c c
\time 6/8 c8 c c c8. c16 c8
}

If these automatic decisions are not satisfactory, beaming can be entered explicitly; see Manual beams. Beams must be entered manually if beams are to be extended over rests.

If automatic beaming is not required, it may be turned off with \autoBeamOff and on with \autoBeamOn:

\relative c' {
c4 c8 c8. c16 c8. c16 c8
\autoBeamOff
c4 c8 c8. c16 c8.
\autoBeamOn
c16 c8
}

Note: If beams are used to indicate melismata in songs, then automatic beaming should be switched off with autoBeamOff and the beams indicated manually. Using partCombine with autoBeamOff can produce unintended results. See the snippets for more information.

Beaming patterns that differ from the automatic defaults can be created; see Setting automatic beam behavior.

#### Predefined commands

\autoBeamOff, \autoBeamOn.

#### Beams across line breaks

Line breaks are normally forbidden when beams cross bar lines. This behavior can be changed as shown:

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

#### Changing beam knee gap

Kneed beams are inserted automatically when a large gap is detected between the note heads. This behavior can be tuned through the auto-knee-gap property. A kneed beam is drawn if the gap is larger than the value of auto-knee-gap plus the width of the beam object (which depends on the duration of the notes and the slope of the beam). By default auto-knee-gap is set to 5.5 staff spaces.

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

#### Partcombine and autoBeamOff

The function of \autoBeamOff when used with \partCombine can be difficult to understand.

It may be preferable to use

\set Staff.autoBeaming = ##f

instead, to ensure that autobeaming will be turned off for the entire staff.

\partCombine apparently works with 3 voices – stem up single, stem down single, stem up combined.

An \autoBeamOff call in the first argument to \partCombine will apply to the voice that is active at the time the call is processed, either stem up single or stem up combined. An \autoBeamOff call in the second argument will apply to the voice that is stem down single.

In order to use \autoBeamOff to stop all autobeaming when used with \partCombine, it will be necessary to use three calls to \autoBeamOff.

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

Notation Reference: Manual beams, Setting automatic beam behavior.

Installed Files: ‘scm/auto-beam.scm’.

Snippets: Rhythms.

Internals Reference: Auto_beam_engraver, Beam_engraver, Beam, BeamEvent, BeamForbidEvent, beam-interface, unbreakable-spanner-interface.

#### Known issues and warnings

The properties of a beam are determined at the start of its construction and any additional beam property changes that occur before the beam has been completed will not take effect until the next, new beam starts.

#### Setting automatic beam behavior

When automatic beaming is enabled, the placement of automatic beams is determined by three context properties: baseMoment, beatStructure, and beamExceptions. The default values of these variables may be overridden as described below, or alternatively the default values themselves may be changed as explained in Time signature.

If a beamExceptions rule is defined for the time signature in force, that rule alone is used to determine the beam placement; the values of baseMoment and beatStructure are ignored.

If no beamExceptions rule is defined for the time signature in force, the beam placement is determined by the values of baseMoment and beatStructure.

#### Beaming based on baseMoment and beatStructure

By default, beamExceptions rules are defined for most common time signatures, so the beamExceptions rules must be disabled if automatic beaming is to be based on baseMoment and beatStructure. The beamExceptions rules are disabled by

\set Timing.beamExceptions = #'()

When beamExceptions is set to #'(), either due to an explicit setting or because no beamExceptions rules are defined internally for the time signature in force, the ending points for beams are on beats as specified by the context properties baseMoment and beatStructure. beatStructure is a scheme list that defines the length of each beat in the measure in units of baseMoment. By default, baseMoment is one over the denominator of the time signature. By default, each unit of length baseMoment is a single beat.

Note that there are separate beatStructure and baseMoment values for each time signature. Changes to these variables apply only to the time signature that is currently in force, hence those changes must be placed after the \time command which starts a new time signature section, not before it. New values given to a particular time signature are retained and reinstated whenever that time signature is reestablished.

\relative c'' {
\time 5/16
c16^"default" c c c c |
% beamExceptions are unlikely to be defined for 5/16 time,
% but let's disable them anyway to be sure
\set Timing.beamExceptions = #'()
\set Timing.beatStructure = 2,3
c16^"(2+3)" c c c c |
\set Timing.beatStructure = 3,2
c16^"(3+2)" c c c c |
}

\relative {
\time 4/4
a'8^"default" a a a a a a a
% Disable beamExceptions because they are definitely
% defined for 4/4 time
\set Timing.beamExceptions = #'()
\set Timing.baseMoment = #(ly:make-moment 1/4)
\set Timing.beatStructure = 1,1,1,1
a8^"changed" a a a a a a a
}

Beam setting changes can be limited to specific contexts. If no setting is included in a lower-level context, the setting of the enclosing context will apply.

\new Staff {
\time 7/8
% No need to disable beamExceptions
% as they are not defined for 7/8 time
\set Staff.beatStructure = 2,3,2
<<
\new Voice = one {
\relative {
a'8 a a a a a a
}
}
\new Voice = two {
\relative {
\voiceTwo
\set Voice.beatStructure = 1,3,3
f'8 f f f f f f
}
}
>>
}

When multiple voices are used the Staff context must be specified if the beaming is to be applied to all voices in the staff:

\time 7/8
% rhythm 3-1-1-2
% Change applied to Voice by default --  does not work correctly
% Because of autogenerated voices, all beating will
% be at baseMoment (1 . 8)
\set beatStructure = 3,1,1,2
<< \relative {a'8 a a a16 a a a a8 a} \\ \relative {f'4. f8 f f f} >>

% Works correctly with context Staff specified
\set Staff.beatStructure = 3,1,1,2
<< \relative {a'8 a a a16 a a a a8 a} \\ \relative {f'4. f8 f f f} >>

The value of baseMoment can be adjusted to change the beaming behavior, if desired. When this is done, the value of beatStructure must be set to be compatible with the new value of baseMoment.

\time 5/8
% No need to disable beamExceptions
% as they are not defined for 5/8 time
\set Timing.baseMoment = #(ly:make-moment 1/16)
\set Timing.beatStructure = 7,3
\repeat unfold 10 { a'16 }

baseMoment is a moment; a unit of musical duration. A quantity of type ‘moment’ is created by the Scheme function ly:make-moment. For more information about this function, see Time administration.

By default baseMoment is set to one over the denominator of the time signature. Any exceptions to this default can be found in ‘scm/time-signature-settings.scm’.

#### Beaming based on beamExceptions

Special autobeaming rules (other than ending a beam on a beat) are defined in the beamExceptions property.

The value for beamExceptions, a somewhat complex Scheme data structure, is easiest generated with the \beamExceptions function. This function is given one or more manually beamed measure-long rhythmic patterns (measures have to be separated by a bar check | since the function has no other way to discern the measure length). Here is a simple example:

\relative c'' {
\time 3/16
\set Timing.beatStructure = 2,1
\set Timing.beamExceptions =
\beamExceptions { 32[ 32] 32[ 32] 32[ 32] }
c16 c c |
\repeat unfold 6 { c32 } |
}

Note: A beamExceptions value must be complete exceptions list. That is, every exception that should be applied must be included in the setting. It is not possible to add, remove, or change only one of the exceptions. While this may seem cumbersome, it means that the current beaming settings need not be known in order to specify a new beaming pattern.

When the time signature is changed, default values of Timing.baseMoment, Timing.beatStructure, and Timing.beamExceptions are set. Setting the time signature will reset the automatic beaming settings for the Timing context to the default behavior.

\relative a' {
\time 6/8
\repeat unfold 6 { a8 }
% group (4 + 2)
\set Timing.beatStructure = 4,2
\repeat unfold 6 { a8 }
% go back to default behavior
\time 6/8
\repeat unfold 6 { a8 }
}

The default automatic beaming settings for a time signature are determined in ‘scm/time-signature-settings.scm’. Changing the default automatic beaming settings for a time signature is described in Time signature.

Many automatic beaming settings for a time signature contain an entry for beamExceptions. For example, 4/4 time tries to beam the measure in two if there are only eighth notes. The beamExceptions rule can override the beatStructure setting if beamExceptions is not reset.

\time 4/4
\set Timing.baseMoment = #(ly:make-moment 1/8)
\set Timing.beatStructure = 3,3,2
% This won't beam (3 3 2) because of beamExceptions
\repeat unfold 8 {c''8} |
% This will beam (3 3 2) because we clear beamExceptions
\set Timing.beamExceptions = #'()
\repeat unfold 8 {c''8}

In a similar fashion, eighth notes in 3/4 time are beamed as a full measure by default. To beam eighth notes in 3/4 time on the beat, reset beamExceptions.

\time 3/4
% by default we beam in (6) due to beamExceptions
\repeat unfold 6 {a'8} |
% This will beam (1 1 1) due to default baseMoment and beatStructure
\set Timing.beamExceptions = #'()
\repeat unfold 6 {a'8}

In engraving from the Romantic and Classical periods, beams often begin midway through the measure in 3/4 time, but modern practice is to avoid the false impression of 6/8 time (see Gould, p. 153). Similar situations arise in 3/8 time. This behavior is controlled by the context property beamHalfMeasure, which has effect only in time signatures with 3 in the numerator:

\relative a' {
\time 3/4
r4. a8 a a |
\set Timing.beamHalfMeasure = ##f
r4. a8 a a |
}

#### How automatic beaming works

When automatic beaming is enabled, the placement of automatic beams is determined by the context properties baseMoment, beatStructure, and beamExceptions.

The following rules, in order of priority, apply when determining the appearance of beams:

• If a manual beam is specified with […] set the beam as specified, otherwise
• if a beam ending rule is defined in beamExceptions for the beam type, use it to determine the valid places where beams may end, otherwise
• if a beam ending rule is defined in beamExceptions for a longer beam type, use it to determine the valid places where beams may end, otherwise
• use the values of baseMoment and beatStructure to determine the ends of the beats in the measure, and end beams at the end of beats.

In the rules above, the beam type is the duration of the shortest note in the beamed group.

The default beaming rules can be found in ‘scm/time-signature-settings.scm’.

#### Subdividing beams

The beams of consecutive 16th (or shorter) notes are, by default, not subdivided. That is, the three (or more) beams stretch unbroken over entire groups of notes. This behavior can be modified to subdivide the beams into sub-groups by setting the property subdivideBeams. When set, multiple beams will be subdivided at intervals defined by the current value of baseMoment by reducing the multiple beams to the number of beams that indicates the metric value of the subdivision. If the group following the division is shorter than the current metric value (usually because the beam is incomplete) the number of beams reflects the longest possible subdivision group. However, if there is only one note left after the division this restriction isn’t applied. Note that baseMoment defaults to one over the denominator of the current time signature if not set explicitly. It must be set to a fraction giving the duration of the beam sub-group using the ly:make-moment function, as shown in this snippet. Also, when baseMoment is changed, beatStructure should also be changed to match the new baseMoment:

\relative c'' {
c32[ c c c c c c c]
\set subdivideBeams = ##t
c32[ c c c c c c c]

% Set beam sub-group length to an eighth note
\set baseMoment = #(ly:make-moment 1/8)
\set beatStructure = 2,2,2,2
c32[ c c c c c c c]

% Set beam sub-group length to a sixteenth note
\set baseMoment = #(ly:make-moment 1/16)
\set beatStructure = 4,4,4,4
c32[ c c c c c c c]

% Shorten beam by 1/32
\set baseMoment = #(ly:make-moment 1/8)
\set beatStructure = 2,2,2,2
c32[ c c c c c c] r32

% Shorten beam by 3/32
\set baseMoment = #(ly:make-moment 1/8)
\set beatStructure = 2,2,2,2
c32[ c c c c] r16.
r2
}

#### Strict beat beaming

Beamlets can be set to point in the direction of the beat to which they belong. The first beam avoids sticking out flags (the default); the second beam strictly follows the beat.

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

#### Conducting signs, measure grouping signs

Beat grouping within a measure is controlled by the beatStructure context property. Values of beatStructure are established for many time signatures in file scm/time-signature-settings.scm. Values of beatStructure can be changed or set with \set. Alternatively, \time can be used to both set the time signature and establish the beat structure. For this, you specify the internal grouping of beats in a measure as a list of numbers (in Scheme syntax) before the time signature.

\time applies to the Timing context, so it will not reset values of beatStructure or baseMoment that are set in other lower-level contexts, such as Voice.

If the Measure_grouping_engraver is included in one of the display contexts, measure grouping signs will be created. Such signs ease reading rhythmically complex modern music. In the example, the 9/8 measure is grouped in two different patterns using the two different methods, while the 5/8 measure is grouped according to the default setting in scm/time-signature-settings.scm:

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

#### Beam endings in Score context

Beam-ending rules specified in the Score context apply to all staves, but can be modified at both Staff and Voice levels:

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

Notation Reference: Time signature.

Installed Files: ‘scm/time-signature-settings.scm’.

Snippets: Rhythms.

Internals Reference: Auto_beam_engraver, Beam, BeamForbidEvent, beam-interface.

#### Known issues and warnings

If a score ends while an automatic beam has not been ended and is still accepting notes, this last beam will not be typeset at all. The same holds for polyphonic voices, entered with << … \\ … >>. If a polyphonic voice ends while an automatic beam is still accepting notes, it is not typeset. The workaround for these problems is to manually beam the last beam in the voice or score.

By default, the Timing translator is aliased to the Score context. This means that setting the time signature in one staff will affect the beaming of the other staves as well. Thus, a time signature setting in a later staff will reset custom beaming that was set in an earlier staff. One way to avoid this problem is to set the time signature in only one staff.

<<
\new Staff {
\time 3/4
\set Timing.baseMoment = #(ly:make-moment 1/8)
\set Timing.beatStructure = 1,5
\set Timing.beamExceptions = #'()
\repeat unfold 6 { a'8 }
}
\new Staff {
\repeat unfold 6 { a'8 }
}
>>

The default beam settings for the time signature can also be changed, so that the desired beaming will always be used. Changes in automatic beaming settings for a time signature are described in Time signature.

<<
\new Staff {
\overrideTimeSignatureSettings
3/4               % timeSignatureFraction
1/8               % baseMomentFraction
1,5               % beatStructure
#'()		% beamExceptions
\time 3/4
\repeat unfold 6 { a'8 }
}
\new Staff {
\time 3/4
\repeat unfold 6 { a'8 }
}
>>

#### Manual beams

In some cases it may be necessary to override the automatic beaming algorithm. For example, the autobeamer will not put beams over rests or bar lines, and in choral scores the beaming is often set to follow the meter of the lyrics rather than the notes. Such beams can be specified manually by marking the begin and end point with [ and ].

\relative { r4 r8[ g' a r] r g[ | a] r }

Beaming direction can be set manually using direction indicators:

\relative { c''8^[ d e] c,_[ d e f g] }

Individual notes may be marked with \noBeam to prevent them from being beamed:

\relative {
\time 2/4
c''8 c\noBeam c c
}

Grace note beams and normal note beams can occur simultaneously. Unbeamed grace notes are not put into normal note beams.

\relative {
c''4 d8[
\grace { e32 d c d }
e8] e[ e
\grace { f16 }
e8 e]
}

Even more strict manual control with the beams can be achieved by setting the properties stemLeftBeamCount and stemRightBeamCount. They specify the number of beams to draw on the left and right side, respectively, of the next note. If either property is set, its value will be used only once, and then it is erased. In this example, the last f is printed with only one beam on the left side, i.e., the eighth-note beam of the group as a whole.

\relative a' {
a8[ r16 f g a]
a8[ r16
\set stemLeftBeamCount = #2
\set stemRightBeamCount = #1
f16
\set stemLeftBeamCount = #1
g16 a]
}

#### Predefined commands

\noBeam.

#### Flat flags and beam nibs

Flat flags on lone notes and beam nibs at the ends of beamed figures are both possible with a combination of stemLeftBeamCount, stemRightBeamCount and paired [] beam indicators.

For right-pointing flat flags on lone notes, use paired [] beam indicators and set stemLeftBeamCount to zero (see Example 1).

For left-pointing flat flags, set stemRightBeamCount instead (Example 2).

For right-pointing nibs at the end of a run of beamed notes, set stemRightBeamCount to a positive value. And for left-pointing nibs at the start of a run of beamed notes, set stemLeftBeamCount instead (Example 3).

Sometimes it may make sense for a lone note surrounded by rests to carry both a left- and right-pointing flat flag. Do this with paired [] beam indicators alone (Example 4).

(Note that \set stemLeftBeamCount is always equivalent to \once \set. In other words, the beam count settings are not “sticky”, so the pair of flat flags attached to the lone c'16[] in the last example have nothing to do with the \set two notes prior.)

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

Notation Reference: Direction and placement, Grace notes.

Snippets: Rhythms.

Internals Reference: Beam, BeamEvent, Beam_engraver, beam-interface, Stem_engraver.

#### Feathered beams

Feathered beams are used to indicate that a small group of notes should be played at an increasing (or decreasing) tempo, without changing the overall tempo of the piece. The extent of the feathered beam must be indicated manually using [ and ], and the beam feathering is turned on by specifying a direction to the Beam property grow-direction.

If the placement of the notes and the sound in the MIDI output is to reflect the ritardando or accelerando indicated by the feathered beam the notes must be grouped as a music expression delimited by braces and preceded by a featherDurations command which specifies the ratio between the durations of the first and last notes in the group.

The square brackets show the extent of the beam and the braces show which notes are to have their durations modified. Normally these would delimit the same group of notes, but this is not required: the two commands are independent.

In the following example the eight 16th notes occupy exactly the same time as a half note, but the first note is one half as long as the last one, with the intermediate notes gradually lengthening. The first four 32nd notes gradually speed up, while the last four 32nd notes are at a constant tempo.

\relative c' {
\override Beam.grow-direction = #LEFT
\featherDurations 2/1
{ c16[ c c c c c c c] }
\override Beam.grow-direction = #RIGHT
\featherDurations 2/3
{ c32[ d e f] }
% revert to non-feathered beams
\override Beam.grow-direction = #'()
{ g32[ a b c] }
}

The spacing in the printed output represents the note durations only approximately, but the MIDI output is exact.

#### Predefined commands

\featherDurations.

Snippets: Rhythms.

#### Known issues and warnings

The \featherDurations command only works with very short music snippets, and when numbers in the fraction are small.

### 1.2.5 Bars

#### Bar lines

Bar lines are used to delimit measures and sections, and to indicate repetition. Normally, simple bar lines are automatically inserted into the printed output at places according to the current time signature. Various commands insert other kinds of bar lines automatically as part of their effect (see Automatic bar lines).

A bar line inserted automatically can be changed to another type with the \bar command:

\relative { e'4 d c2 \bar "!" }

The final note of a measure is not required to end on the automatically inserted bar line: the note is assumed to carry over into the next measure. But if a long sequence of such carry-over measures appears, the music can appear compressed or even flowing off the page. This is because automatic line breaks happen only at the end of complete measures, i.e., where all notes end before the end of a measure.

Note: An incorrect duration can inhibit line breaks, leading to a line of highly compressed music or music that flows off the page.

Line breaks are also permitted at manually inserted bar lines even within incomplete measures. To allow a line break without printing a bar line, use \allowBreak; see Line breaking.

This and other special bar lines may be inserted manually at any point. When they coincide with the end of a measure they replace the simple bar line which would have been inserted there automatically. When they do not coincide with the end of a measure the specified bar line is inserted at that point in the printed output.

Manual bar lines are purely visual. They do not affect any of the properties that a normal bar line would affect, such as measure numbers and accidentals. They do not affect the calculation and placement of subsequent automatic bar lines. When a manual bar line is placed where a normal bar line already exists, the effects of the original bar line are not altered.

Two types of simple bar lines and five types of double bar lines are available for manual insertion:

\relative {
f'1 \bar "|"
f1 \bar "."
g1 \bar "||"     % see \section
a1 \bar ".|"
b1 \bar ".."
c1 \bar "|.|"
d1 \bar "|."     % see \fine
e1
}

together with dotted and dashed bar lines:

\relative {
f'1 \bar ";"
g1 \bar "!"
a1
}

and nine types of repeat bar lines:

\relative {
f'1 \bar ".|:"
g1 \bar ":..:"
a1 \bar ":|.|:"
b1 \bar ":|.:"
c1 \bar ":.|.:"
d1 \bar "[|:"
e1 \bar ":|][|:"
f1 \bar ":|]"
g1 \bar ":|."
a1
}

Ticks and short bar lines are also available; however, in the context of Gregorian chant, using \divisioMinima and \divisioMaior is preferable (see Divisiones).

f'1 \bar "'"
g1 \bar ","
a1

LilyPond supports kievan notation and provides a special kievan bar line:

f'1 \bar "k"

Further details of this notation are explained in Typesetting Kievan square notation.

For in-staff segno signs, there are three types of bar lines which differ in their behavior at line breaks:

\relative c'' {
c4 c c c
\bar "S-||"
c4 c c c \break
\bar "S-||"
c4 c c c
\bar "S"
c4 c c c \break
\bar "S"
c4 c c c
\bar "S-S"
c4 c c c \break
\bar "S-S"
c1
}

Although the bar line types signifying repeats may be inserted manually they do not in themselves cause LilyPond to recognize a repeated section. Such repeated sections are better entered using the various repeat commands (see Repeats), which automatically print the appropriate bar lines, which can be customized (see Automatic bar lines).

In addition, you can specify ".|:-||", which is equivalent to ".|:" except at line breaks, where it gives a double bar line at the end of the line and a start repeat at the beginning of the next line.

\relative c'' {
c4 c c c
\bar ".|:-||"
c4 c c c \break
\bar ".|:-||"
c4 c c c
}

For combinations of repeats with the segno sign, there are six different variations:

\relative c'' {
c4 c c c
\bar ":|.S"
c4 c c c \break
\bar ":|.S"
c4 c c c
\bar ":|.S-S"
c4 c c c \break
\bar ":|.S-S"
c4 c c c
\bar "S.|:-S"
c4 c c c \break
\bar "S.|:-S"
c4 c c c
\bar "S.|:"
c4 c c c \break
\bar "S.|:"
c4 c c c
\bar ":|.S.|:"
c4 c c c \break
\bar ":|.S.|:"
c4 c c c
\bar ":|.S.|:-S"
c4 c c c \break
\bar ":|.S.|:-S"
c1
}

Many of the repeat and segno bar lines above can be inserted automatically by \repeat commands (see Repeats).

New bar line types can be defined with \defineBarLine:

\defineBarLine bartype #'(end begin span)

In addition to bartype (the character string that will then be used to refer to that new bar line), it takes three values: the first two determine the bar line’s appearance when it occurs at a line break, in which case the first and second given glyphs are printed respectively at the end of the system and at the beginning of the next one. The third given glyph is only relevant in multi-staff systems (see Grouping staves), where it is used as span bar, printed between staves.

The \defineBarLine arguments specifying replacement glyphs can be set to #t to copy the mid-line glyph or #f to create no bar line. The empty string, "", yields a zero-width bar line.

After the definiton, the new bar line can be used by \bar bartype.

There are several bar line elements, and there are predefined bar types that use most of them individually. Some elements are primarily intended to be combined with others; those do not have predefined individual bar types.

\defineBarLine ":" #'(#f #t #f)
\defineBarLine "=" #'(#t #f #t)
\defineBarLine "[" #'(#f #t #f)
\defineBarLine "]" #'(#t #f #f)

\new Staff {
s1 \bar "'"
s1 \bar ","
s1 \bar "|"
s1 \bar "."
s1 \bar "!"
s1 \bar ";"
s1 \bar ":"
s1 \bar "k"
s1 \bar "S"
s1 \bar "="
s1 \bar "["
s1 \bar "]"
s1 \bar ""
}

The "=" bar line provides a double span bar line for use in combination with the segno sign. Using it as a stand-alone double thin bar line is not recommended; \bar "||" is preferred.

The "-" sign starts annotations to bar lines which are useful to distinguish those with identical appearance but different behavior at line breaks and/or different span bars. The part following the "-" sign is not used for building up the bar line.

\defineBarLine "||-dashedSpan" #'(#t #f "!!")

\new StaffGroup <<
\new Staff \relative c'' {
c1 \bar "||"
c1 \bar "||-dashedSpan"
c1
}
\new Staff \relative c'' {
c1
c1
c1
}
>>

Furthermore, the space character " " serves as a placeholder for defining span bars correctly aligned to the main bar lines:

\defineBarLine ":|.-wrong" #'(#t #f "|.")
\defineBarLine ":|.-right" #'(#t #f " |.")

\new StaffGroup <<
\new Staff \relative c'' {
c1 \bar ":|.-wrong"
c1 \bar ":|.-right"
c1
}
\new Staff \relative c'' {
c1
c1
c1
}
>>

New bar line types defined using \defineBarLine may even, in turn, be used in a second bar line definition. Such ‘nested’ definitions make it possible to use customized glyphs in places where it would not be otherwise possible, such as system ends:

\defineBarLine "||-dashEverywhere" #'("!!" "!!" "!!")

\new StaffGroup <<
\new Staff \relative c'' {
c1 \bar "||"
}
\new Staff \relative c'' {
c1
c1
c1
}
>>

If additional elements are needed, LilyPond provides a simple way to define them. For more information on modifying or adding bar lines, see file ‘scm/bar-line.scm’.

In scores with many staves, a \bar command in one staff is automatically applied to all staves. The resulting bar lines are connected between different staves of a StaffGroup, PianoStaff, or GrandStaff.

<<
\new StaffGroup <<
\new Staff \relative {
e'4 d
\bar "||"
f4 e
}
\new Staff \relative { \clef bass c'4 g e g }
>>
\new Staff \relative { \clef bass c'2 c2 }
>>

The bar type used for automatically inserted measure bar lines is "|". This may be changed at any time with ‘\set Timing.measureBarType = bartype’.

Notation Reference: Line breaking, Repeats, Grouping staves.

Installed Files: ‘scm/bar-line.scm’.

Snippets: Rhythms.

Internals Reference: BarLine (created at Staff level), SpanBar (across staves), Timing_translator (for Timing properties).

#### Automatic bar lines

Various commands other than \bar can also create bar lines as part of their effect. The bar lines created in these cases can be changed by setting context properties. If a property is set to '() or is unset, it is ignored; otherwise, the value must be a predefined bar type or one previously defined with the \defineBarLine command (see Bar lines).

Multiple reasons for creating different automatic bar lines may apply at the same time. Conflicts are resolved in part by providing properties for predetermined combinations, in part by annotating bar types on the fly, and in part by a priority scheme. The table below presents the available properties in order of increasing priority.

The highest-priority automatic bar type does not completely hide the others: the next-highest-priority bar type is appended as an annotation, provided that the resulting bar type is defined. This allows the secondary bar line to become visible at line breaks if suitable bar types are defined (see Bar lines).

underlyingRepeatBarType

Used at points of repetition or departure where no bar line would otherwise appear. This is expected when repeated sections are not aligned to measures. Several commands employ this bar type: \codaMark, \inStaffSegno, \repeat segno, \repeat volta, and \segnoMark.

measureBarType

Used at a measure boundary.

sectionBarType

Used at a section break created by \section.

fineBarType

Used at \fine.

doubleRepeatBarType
doubleRepeatSegnoBarType
endRepeatBarType
endRepeatSegnoBarType
fineSegnoBarType
fineStartRepeatSegnoBarType
segnoBarType
startRepeatBarType
startRepeatSegnoBarType

Only one of these bar types is used at a time; which one is used depends on the structure of the piece.

Properties with startRepeat or endRepeat in the name are used at the start or end of a repeated section created by \repeat volta, and properties with doubleRepeat in the name are used where the end of one repeated section and the start of another coincide.

Properties with segno in the name are used at an in-staff segno, which can be created by \repeat segno or \segnoMark when the segnoStyle property is set to bar-line, or created by \inStaffSegno.

Properties with fine in the name are used at \fine.

#### Setting the double repeat default for volte

There are three different styles of double repeats for volte, that can be set using doubleRepeatBarType.

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

Notation Reference: Bar lines, Repeats.

Snippets: Rhythms.

Internals Reference: Repeat_acknowledge_engraver.

#### Bar numbers

Bar numbers are typeset by default at the start of every line except the first line. The number itself is stored in the currentBarNumber property, which is normally updated automatically for every measure. It may also be set manually:

\relative c' {
c1 c c c
\break
\set Score.currentBarNumber = #50
c1 c c c
}

The default behavior of only printing bar numbers at the start of every line can be changed through the break-visibility property of BarNumber. This takes three values which may be set to #t or #f to specify whether the corresponding bar number is visible or not. The order of the three values is end of line visible, middle of line visible, beginning of line visible. In the following example bar numbers are printed at all possible places:

\relative c' {
\override Score.BarNumber.break-visibility = ##(#t #t #t)
\set Score.currentBarNumber = #11
c1 | c | c | c |
\break
c1 | c | c | c |
}

#### Printing the bar number for the first measure

By default, the first bar number in a score is suppressed if it is less than or equal to 1. By setting barNumberVisibility to all-bar-numbers-visible, any bar number can be printed for the first measure and all subsequent measures.

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

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

#### Printing bar numbers at regular intervals

By setting the barNumberVisibility property, bar numbers can be printed at regular intervals. Here the bar numbers are printed every two measures except at the end of the line.

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

#### Printing bar numbers with changing regular intervals

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

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

#### Printing bar numbers for broken measures

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

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

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

#### Printing bar numbers using modulo-bar-number-visible

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

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

• (modulo-bar-number-visible 3 2) -> prints 2,5,8
• (modulo-bar-number-visible 4 2) -> prints 2,6,10
• (modulo-bar-number-visible 3 1) -> prints 3,5,7
• (modulo-bar-number-visible 5 2) -> prints 2,7,12
\layout {
\context {
\Score
\override BarNumber.break-visibility = ##(#f #t #t)
barNumberVisibility = #(modulo-bar-number-visible 3 2)
}
}

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

#### Printing bar numbers inside boxes or circles

Bar numbers can also be printed inside boxes or circles.

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

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

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

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

#### Alternative bar numbering

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

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

#### Aligning bar numbers

Bar numbers by default are right-aligned to their parent object. This is usually the left edge of a line or, if numbers are printed within a line, the left hand side of a bar line. The numbers may also be positioned directly over the bar line or left-aligned to the bar line.

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

#### Removing bar numbers from a score

Bar numbers can be removed entirely by removing the Bar_number_engraver from the Score context.

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

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

#### Measure-centered bar numbers

For film scores, a common convention is to center bar numbers within their measure. This is achieved through setting the centerBarNumbers context property to true. When this is used, the type of the bar number grobs is CenteredBarNumber rather than BarNumber.

This example demonstrates a number of settings: the centered bar numbers are boxed and placed below the staves.

\layout {
\context {
\Score
centerBarNumbers = ##t
barNumberVisibility = #all-bar-numbers-visible
\override CenteredBarNumber.stencil
= #(make-stencil-boxer 0.1 0.25 ly:text-interface::print)
\override CenteredBarNumberLineSpanner.direction = #DOWN
}
}

\new StaffGroup <<
\new Staff \relative c' {
d4-. f8( e d4) bes'-> |
d,-. f8( e d4) cis'-> |
g-. f8( d e4) g-> |
a,1-> |
}
\new Staff \relative c {
\clef bass
d4 f8 e d2~ |
4 f8 e d2~ |
4 4 2 |
a1 |
}
>>

Snippets: Rhythms.

#### Known issues and warnings

Bar numbers may collide with the top of the StaffGroup bracket, if there is one. To solve this, the padding property of BarNumber can be used to position the number correctly. See StaffGroup and BarNumber for more.

#### Bar and bar number checks

Bar checks help detect errors in the entered durations. A bar check may be entered using the bar symbol, |, at any place where a bar line is expected to fall. If bar check lines are encountered at other places, a list of warnings is printed in the log file, showing the line numbers and lines in which the bar checks failed. In the next example, the second bar check will signal an error.

\time 3/4 c2 e4 | g2 |

An incorrect duration can result in a completely garbled score, especially if the score is polyphonic, so a good place to start correcting input is by scanning for failed bar checks and incorrect durations.

If successive bar checks are off by the same musical interval, only the first warning message is displayed. This allows the warning to focus on the source of the timing error.

Bar checks can also be inserted in lyrics:

\lyricmode {
\time 2/4
Twin -- kle | Twin -- kle |
}

Note that bar check marks in lyrics are evaluated at the musical moment when the syllable following the check mark is processed. If the lyrics are associated with the notes of a voice which has a rest at the beginning of a bar, then no syllable can be located at the start of that bar and a warning will be issued if a bar check mark is placed in the lyrics at that position.

It is also possible to redefine the action taken when a bar check or pipe symbol, |, is encountered in the input, so that it does something other than a bar check. This is done by assigning a music expression to "|". In the following example | is set to insert a double bar line wherever it appears in the input, rather than checking for end of bar.

"|" = \bar "||"
{
c'2 c' |
c'2 c'
c'2 | c'
c'2 c'
}

When copying large pieces of music, it can be helpful to check that the LilyPond bar number corresponds to the original that you are entering from. This can be checked with \barNumberCheck, for example,

\barNumberCheck #123

will print a warning if the currentBarNumber is not 123 when it is processed.

Snippets: Rhythms.

#### Rehearsal marks

To print a rehearsal mark, use the \mark command.

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

The mark is incremented automatically if you use \mark \default, but you can also use an integer argument to set the mark manually. The value to use is stored in the property rehearsalMark.

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

The letter ‘I’ is skipped in accordance with engraving traditions. If you wish to include the letter ‘I’, then use one of the following commands, depending on which style of rehearsal mark you want (letters only, letters in a hollow box, or letters in a hollow circle).

\set Score.rehearsalMarkFormatter = #format-mark-alphabet
\set Score.rehearsalMarkFormatter = #format-mark-box-alphabet
\set Score.rehearsalMarkFormatter = #format-mark-circle-alphabet

\relative c'' {
\set Score.rehearsalMarkFormatter = #format-mark-box-alphabet
c1 \mark \default
c1 \mark \default
c1 \mark #8
c1 \mark \default
c1 \mark \default
}

The style is defined by the property rehearsalMarkFormatter. It is a function taking the current mark (an integer) and the current context as argument. It should return a markup object. In the following example, rehearsalMarkFormatter is set to a predefined procedure. After a few measures, it is set to a procedure that produces a boxed number.

\relative c'' {
\set Score.rehearsalMarkFormatter = #format-mark-numbers
c1 \mark \default
c1 \mark \default
\set Score.rehearsalMarkFormatter = #format-mark-box-numbers
c1 \mark \default
\set Score.rehearsalMarkFormatter = #format-mark-circle-numbers
c1 \mark \default
\set Score.rehearsalMarkFormatter = #format-mark-circle-letters
c1
}

The file ‘scm/translation-functions.scm’ contains the definitions of format-mark-letters (the default format), format-mark-box-letters, format-mark-numbers, and format-mark-box-numbers. These can be used as inspiration for other formatting functions.

You may use format-mark-barnumbers, format-mark-box-barnumbers, and format-mark-circle-barnumbers to get bar numbers instead of incremented numbers or letters.

Arbitrary text can be provided to create a rehearsal mark that is independent of the rehearsalMark sequence.

\mark "A1"

When text is supplied, Score.rehearsalMarkFormatter has no effect; however, it is possible to apply a \markup to the string.

\mark \markup { \box A1 }

Before using \mark to add text that is effectively something other than a rehearsal mark, seeking a more fitting command is recommended. Some possibilities are referenced at the end of this section.

Music glyphs may be centered over bar lines by specifying the appropriate symbol name (see Music notation inside markup).

\fixed c'' {
c1
\mark \markup { \musicglyph "scripts.ufermata" }
c1
}

For a list of symbols which may be printed with \musicglyph, see The Emmentaler font,

For common tweaks to the positioning of rehearsal marks, see Formatting text. For more precise control, consider break-alignable-interface (see Aligning objects).

The file ‘scm/translation-functions.scm’ contains the definitions of format-mark-numbers and format-mark-letters. They can be used as inspiration for other formatting functions.

Installed Files: ‘scm/translation-functions.scm’.

Snippets: Rhythms.

#### Measure counts

Measure counts are a way to number consecutive measures, for example as an aid for musicians to count measures in written-out repeats. Using this feature requires adding the Measure_counter_engraver to a context type, usually Staff or Score.

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

\relative c' {
\time 6/8
\key e \minor
r4 a8 b c dis
\startMeasureCount
\repeat unfold 3 {
e8 b e g8. fis32 e dis8
}
\stopMeasureCount
b'4. r
}

Broken measures are numbered in parentheses.

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

\relative c' {
\time 6/8
\key e \minor
r4 a8 b c dis
\startMeasureCount
e8 b e g8. fis32 e dis8
e8 b e \break g8. fis32 e dis8
e8 b e g8. fis32 e dis8
\stopMeasureCount
b'4. r
}

Compressed multi-measure rests receive special treatment: the full measure range is shown.

\layout {
\context {
\Staff
\consists Measure_counter_engraver
}
\context {
\Voice
\override MultiMeasureRestNumber.direction = #DOWN
}
}

\compressMMRests {
\key e \minor
\startMeasureCount
\new CueVoice {
b4.( e'8) b8 r e' r
}
R1*2
\stopMeasureCount
g'2\> fis'2\!
}

Measure counters honor alternative numbering styles. If the style is numbers-with-letters, they render best with a textual font.

\layout {
\context {
\Score
alternativeNumberingStyle = #'numbers-with-letters
}
\context {
\Staff
\consists Measure_counter_engraver
\override MeasureCounter.Y-offset = 6
\override MeasureCounter.font-encoding = #'latin1
\override MeasureCounter.font-size = 1
}
}

\relative c' {
\startMeasureCount
\repeat volta 2 {
c8 d e f c d e f
}
\alternative {
{ e4 d c b }
{ g'4 g c2 }
}
\bar "|."
\stopMeasureCount
}

#### Predefined commands

\startMeasureCount, \stopMeasureCount.

Notation Reference: Modifying context plug-ins, Compressing empty measures, Breaks, Bar numbers.

Internals Reference: Measure_counter_engraver, MeasureCounter, measure-counter-interface.

#### Section divisions

The \section command marks a point where one section of music ends and another begins. It does not have to be followed by more music: it may also be used to emphasize that the written end of the music is not the end of the piece, such as at a D.C. instruction or where one movement continues into the next without a break. \section normally creates a double bar line, but its effect can depend on other notation, e.g., repeat bar lines.

The \fine command ends the piece, normally with a final bar line. It is not limited to use at the written end of the music: it may also appear inside \repeat (see Al-fine repeats).

A section can optionally be named with \sectionLabel (see Section labels).

\fixed c' {
f1
\section
\sectionLabel "Refrain"
g1
a1
\fine
}

For details on interactions of \fine and \section bar lines with other types of bar lines, and options for changing their appearance, see Automatic bar lines.

Music Glossary: fine.

Notation Reference: Automatic bar lines, Divisiones, Al-fine repeats, Section labels.

Internals Reference: FineEvent, SectionEvent.

### 1.2.6 Special rhythmic concerns

#### Grace notes

Grace notes are musical ornaments, printed in a smaller font, that take up no additional logical time in a measure.

\relative {
c''4 \grace b16 a4(
\grace { b16 c16 } a2)
}

There are three other types of grace notes possible; the acciaccatura – an unmeasured grace note indicated by a slurred note with a slashed stem – and the appoggiatura, which takes a fixed fraction of the main note it is attached to and prints without the slash. It is also possible to write a grace note with a slashed stem, like the acciaccatura but without the slur, so as to place it between notes that are slurred themselves, using the \slashedGrace function.

\relative {
\acciaccatura d''8 c4
\appoggiatura e8 d4
\acciaccatura { g16 f } e2
\slashedGrace a,8 g4
\slashedGrace b16 a4(
\slashedGrace b8 a2)
}

The placement of grace notes is synchronized between different staves. In the following example, there are two sixteenth grace notes for every eighth grace note

<<
\new Staff \relative { e''2 \grace { c16 d e f } e2 }
\new Staff \relative { c''2 \grace { g8 b } c2 }
>>

If you want to end a note with a grace, use the \afterGrace command. It takes two arguments: the main note, and the grace notes following the main note.

\relative { c''1 \afterGrace d1 { c16[ d] } c1 }

This will place the grace notes after the start of the main note. The point of time where the grace notes are placed is a given fraction of the main note’s duration. The default setting of

afterGraceFraction = 3/4

may be redefined at top level. Individual \afterGrace commands may have the fraction specified right after the command itself instead.

The following example shows the results from setting with the default space, setting it at 15/16, and finally at 1/2 of the main note.

<<
\new Staff \relative {
c''1 \afterGrace d1 { c16[ d] } c1
}
\new Staff \relative {
c''1 \afterGrace 15/16 d1 { c16[ d] } c1
}
\new Staff \relative {
c''1 \afterGrace 1/2 d1 { c16[ d] } c1
}
>>

The effect of \afterGrace can also be achieved using spacers. The following example places the grace note after a space lasting 7/8 of the main note.

\new Voice \relative {
<<
{ d''1^\trill_( }
{ s2 s4. \grace { c16 d } }
>>
c1)
}

A \grace music expression will introduce special typesetting settings, for example, to produce smaller type, and set directions. Hence, when introducing layout tweaks to override the special settings, they should be placed inside the grace expression. The overrides should also be reverted inside the grace expression. Here, the grace note’s default stem direction is overridden and then reverted.

\new Voice \relative {
\acciaccatura {
\stemDown
f''16->
\stemNeutral
}
g4 e c2
}

#### Using grace note slashes with normal heads

The slash through the stem found in acciaccaturas can be applied in other situations.

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

#### Tweaking grace layout within music

The layout of grace expressions can be changed throughout the music using the functions add-grace-property and remove-grace-property.

The following example undefines the Stem direction for this grace, so that stems do not always point up, and changes the default note heads to crosses.

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

#### Redefining grace note global defaults

The global defaults for grace notes are stored in the following identifiers.

startGraceMusic
stopGraceMusic
startAcciaccaturaMusic
stopAcciaccaturaMusic
startAppoggiaturaMusic
stopAppoggiaturaMusic

They are defined in file ly/grace-init.ly. By redefining them other effects may be obtained.

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

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

\relative c'' {
\acciaccatura d8 c1
}

#### Positioning grace notes with floating space

Setting the property 'strict-grace-spacing makes the musical columns for grace notes ’floating’, i.e., decoupled from the non-grace notes: first the normal notes are spaced, then the (musical columns of the) graces are put left of the musical columns for the main notes.

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

Music Glossary: grace notes, acciaccatura, appoggiatura.

Notation Reference: Scaling durations, Manual beams.

Installed Files: ‘ly/grace-init.ly’.

Snippets: Rhythms.

Internals Reference: GraceMusic, Grace_beam_engraver, Grace_auto_beam_engraver, Grace_engraver, Grace_spacing_engraver.

#### Known issues and warnings

A multi-note beamed acciaccatura is printed without a slash, and looks exactly the same as a multi-note beamed appoggiatura.

Grace note synchronization can also lead to surprises. Staff notation, such as key signatures, bar lines, etc., are also synchronized. Take care when you mix staves with grace notes and staves without, for example,

<<
\new Staff \relative { e''4 \bar ".|:" \grace c16 d2. }
\new Staff \relative { c''4 \bar ".|:" d2. }
>>

This can be remedied by inserting grace skips of the corresponding durations in the other staves. For the above example

<<
\new Staff \relative { e''4 \bar ".|:" \grace c16 d2. }
\new Staff \relative { c''4 \bar ".|:" \grace s16 d2. }
>>

Please make sure that you use the \grace command for the spacer part, even if the visual part uses \acciaccatura or \appoggiatura because otherwise an ugly slur fragment will be printed, connecting the invisible grace note with the following note.

Grace sections should only be used within sequential music expressions. Nesting or juxtaposing grace sections is not supported, and might produce crashes or other errors.

Each grace note in MIDI output has a length of 1/4 of its actual duration. If the combined length of the grace notes is greater than the length of the preceding note a “Going back in MIDI time” error will be generated. Either make the grace notes shorter in duration, for example:

c'8 \acciaccatura { c'8[ d' e' f' g'] }

becomes:

c'8 \acciaccatura { c'16[ d' e' f' g'] }

Or explicitly change the musical duration:

c'8 \acciaccatura { \scaleDurations 1/2 { c'8[ d' e' f' g'] } }

In an orchestral context, cadenzas present a special problem: when constructing a score that includes a measured cadenza or other solo passage, all other instruments should skip just as many notes as the length of the cadenza, otherwise they will start too soon or too late.

One solution to this problem is to use the functions mmrest-of-length and skip-of-length. These Scheme functions take a defined piece of music as an argument and generate a multi-measure rest or \skip exactly as long as the piece.

MyCadenza = \relative {
c'4 d8 e f g g4
f2 g4 g
}

\new GrandStaff <<
\new Staff {
}
\new Staff {
c'1
c'1
}
>>

Another solution is to use the \skip command.

MyCadenza = \fixed c' {
\repeat volta 2 {
d8 e f g g4 f4
}
}

music = <<
\new Staff {
c'1
}
\new Staff {
c'1
}
>>

\unfoldRepeats \music

Snippets: Rhythms.

Time is administered by the Timing_translator, which by default is to be found in the Score context. An alias, Timing, is added to the context in which the Timing_translator is placed. To ensure that the Timing alias is available, you may need to explicitly instantiate the containing context (such as Voice or Staff).

The following properties of Timing are used to keep track of timing within the score.

currentBarNumber

The current measure number. For an example showing the use of this property see Bar numbers.

measureLength

The length of the measures in the current time signature. For a 4/4 time this is 1, and for 6/8 it is 3/4. Its value determines when bar lines are inserted and how automatic beams should be generated.

measurePosition

The point within the measure where we currently are. This quantity is reset by subtracting measureLength whenever measureLength is reached or exceeded. When that happens, currentBarNumber is incremented.

timing

If set to true, the above variables are updated for every time step. When set to false, the engraver stays in the current measure indefinitely.

Timing can be changed by setting any of these variables explicitly. In the next example, the default 4/4 time signature is printed, but measureLength is set to 5/4. At 4/8 through the third measure, the measurePosition is advanced by 1/8 to 5/8, shortening that bar by 1/8. The next bar line then falls at 9/8 rather than 5/4.

\new Voice \relative {
\set Timing.measureLength = #(ly:make-moment 5/4)
c'1 c4 |
c1 c4 |
c4 c
\set Timing.measurePosition = #(ly:make-moment 5/8)
b4 b b8 |
c4 c1 |
}

As the example illustrates, ly:make-moment n/m constructs a duration of n/m of a whole note. For example, ly:make-moment 1/8 is an eighth note duration and ly:make-moment 7/16 is the duration of seven sixteenths notes.

Notation Reference: Bar numbers, Unmetered music.

Snippets: Rhythms.

Internals Reference: Timing_translator, Score.

## 1.3 Expressive marks

This section lists various expressive marks that can be created in a score.

### 1.3.1 Expressive marks attached to notes

This section explains how to create expressive marks that are attached to notes: articulations, ornamentations, and dynamics. Methods to create new dynamic markings are also discussed.