LilyPond Notation Reference: 1.2.3 Displaying rhythms

### 1.2.3 Displaying rhythms

#### Time signature

The time signature is set as follows:

>     \time 2/4 c2
>     \time 3/4 c2.

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.

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

>     % 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 time-signature-based default values for the properties `baseMoment`, `beatStructure`, and `beamExceptions`. The predefined default values for these properties can be found in ‘`scm/time-signature-settings.scm`’. The existing default values can be changed, or new default values can be added:

>     \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 Scheme pair describing the time signature.
2. `baseMomentFraction`, a Scheme pair 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.

The context containing `\overrideTimeSignatureSettings` must be instantiated before the `\overrideTimeSignatureSettings` call is executed. That means it must either be explicitly instantiated or there must be music in the context before the `\overrideTimeSignatureSettings` call:

>     \score {
>       \relative c' {
>         % This call will fail because the context isn't yet instantiated
>         \overrideTimeSignatureSettings
>           #'(4 . 4)  % timeSignatureFraction
>           #'(1 . 4)  % baseMomentFraction
>           #'(3 1)    % beatStructure
>           #'()       % beamExceptions
>         \time 4/4
>         c8^\markup {"Beamed (2 2)"}
>         \repeat unfold 7 { c8 } |
>         % This call will succeed
>         \overrideTimeSignatureSettings
>           #'(4 . 4)  % timeSignatureFraction
>           #'(1 . 4)  % baseMomentFraction
>           #'(3 1)    % beatStructure
>           #'()       % beamExceptions
>         \time 4/4
>         c8^\markup {"Beamed (3 1)"}
>         \repeat unfold 7 { c8 } |
>       }
>     }

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

>     \score{
>       \relative c' {
>         \repeat unfold 8 { c8 } |
>         \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 moving the `Timing_translator` and the `Default_bar_line_engraver` from the `Score` context to the `Staff` context.

>     \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 {
>         \context {
>           \Score
>           \remove "Timing_translator"
>           \remove "Default_bar_line_engraver"
>         }
>         \context {
>           \Staff
>           \consists "Timing_translator"
>           \consists "Default_bar_line_engraver"
>         }
>       }
>     }

#### Predefined commands

`\numericTimeSignature`, `\defaultTimeSignature`.

#### Selected Snippets

Changing the time signature without affecting the beaming

The `\time` command sets the properties `timeSignatureFraction`, `beatLength`, `beatGrouping` and `measureLength` in the `Timing` context, which is normally aliased to `Score`. Changing the value of `timeSignatureFraction` causes the new time signature symbol to be printed without changing any of the other properties:

>     \markup {
>       This snippet is deprecated as of 2.13.5 and will be removed in 2.14
>     }

Compound time signatures

Odd 20th century time signatures (such as "5/8") can often be played as compound time signatures (e.g. "3/8 + 2/8"), which combine two or more inequal metrics. LilyPond can make such music quite easy to read and play, by explicitly printing the compound time signatures and adapting the automatic beaming behavior. (Graphic measure grouping indications can also be added; see the appropriate snippet in this database.)

>     #(define ((compound-time one two num) grob)
>        (grob-interpret-markup grob
>                               (markup #:override '(baseline-skip . 0) #:number
>                                       (#:line ((#:column (one num))
>                                                #:vcenter "+"
>                                                (#:column (two num)))))))

>     \relative c' {
>       \override Staff.TimeSignature #'stencil = #(compound-time "2" "3" "8")
>       \time 5/8
>       \set Staff.beatStructure = #'(2 3)
>       c8 d e fis gis
>       c8 fis, gis e d
>       c8 d e4 gis8
>     }

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

Sometimes, a time signature should not print the whole fraction (e.g. 7/4), but only the numerator (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
>     }

#### See also

Music Glossary: time signature

Notation Reference: Mensural time signatures, Time administration.

Snippets: Rhythms.

Internals Reference: TimeSignature, Timing_translator.

#### Metronome marks

A basic metronome mark is simple to write:

>     \tempo 4 = 120
>     c2 d
>     e4. d8 c2

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

>     \tempo 4 = 40 ~ 46
>     c4. e8 a4 g
>     b,2 d4 r

Tempo indications with text can be used instead:

>     \tempo "Allegretto"
>     c4 e d c
>     b4. a16 b c4 r4

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

>     \tempo "Allegro" 4 = 160
>     g4 c d e
>     d4 b g2

In general, the text can be any markup object:

>     \tempo \markup { \italic Faster } 4 = 132
>     a8-. 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:

>     \tempo "" 8 = 96
>     d4 g e c

#### Selected Snippets

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

#### See also

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

Notation Reference: Formatting text, MIDI output.

Snippets: Staff notation.

Internals Reference: MetronomeMark.

#### Upbeats

Partial or pick-up measures, such as an anacrusis or upbeat, are entered using the `\partial` command, with the syntax

>     \partial duration

where `duration` is the rhythmic length of the remaining interval of the current measure before the start of the next.

>     \partial 4 e4 |
>     a2. c,4 |

The partial measure can be any duration less than the full measure:

>     \partial 8*3 c8 d e |
>     a2. c,4 |

Internally, `\partial duration` is translated into:

>     \set Timing.measurePosition -duration

For example, `\partial 8*3` becomes:

>     \set Timing.measurePosition = #(ly:make-moment -3 8)

The property `measurePosition` contains a rational number indicating how much of the measure has passed at this point. Note that this is set to a negative number by the `\partial` command: i.e., `\partial 4` is internally translated to `-4`, meaning “there is a quarter note left in the measure.”

#### See also

Music Glossary: anacrusis.

Notation Reference: Grace notes.

Snippets: Rhythms.

Internal Reference: Timing_translator.

#### Known issues and warnings

The `\partial` command is intended to be used only at the beginning of a piece. If you use it after the beginning, some odd warnings or effects may occur, in this case use `\set Timing.measurePosition` instead.

#### Unmetered music

Bar lines and bar numbers are calculated automatically. For unmetered music (some cadenzas, for example), this is not desirable. To turn off automatic calculation of bar lines and bar numbers, use the command `\cadenzaOn`, and use `\cadenzaOff` to turn them on again.

>     c4 d e d
>     \cadenzaOn
>     c4 c d8[ d d] f4 g4.
>     \cadenzaOff
>     \bar "|"
>     d4 e d c

Bar numbering is resumed at the end of the cadenza as if the cadenza were not there:

>     % Show all bar numbers
>     \override Score.BarNumber #'break-visibility = #all-visible
>     c4 d e d
>     \cadenzaOn
>     c4 c d8[ d d] f4 g4.
>     \cadenzaOff
>     \bar "|"
>     d4 e d c

Automatic beaming is disabled by `\cadenzaOn` and enabled by `\cadenzaOff`. Therefore, all beaming in cadenzas must be entered manually (Manual beams).

>     \repeat unfold 8 { c8 }
>     \cadenzaOn
>     \repeat unfold 5 { c8 }
>     \bar"|"
>     \cadenzaOff
>     \repeat unfold 8 { c8 }

Note that these predefined commands affect all staves in the score, even when they are placed in just one `Voice` context. To change this, move the `Timing_translator` from the `Score` context to the `Staff` context, as shown in Polymetric notation.

#### Predefined commands

`\cadenzaOn`, `\cadenzaOff`.

#### See also

Music Glossary: cadenza.

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

Snippets: Rhythms.

#### Known issues and warnings

LilyPond will insert line breaks and page breaks only at a bar line. Unless the unmetered music ends before the end of the staff line, you will need to insert invisible bar lines with

>     \bar ""

to indicate where breaks can occur.

You should explicitly create a `Voice` context when starting a piece with `\cadenzaOn`, otherwise strange errors may occur.

>     \new Voice {
>       \relative c' {
>         \cadenzaOn
>         c16[^"Solo Free Time" d e f] g2.
>         \bar "||"
>         \cadenzaOff
>       }
>     }

#### Polymetric notation

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

Staves with different time signatures, equal measure lengths

This notation can be created by setting a common time signature for each staff but replacing the symbol manually by setting `timeSignatureFraction` to the desired fraction and scaling the printed durations in each staff to the common time signature; see Time signature. The scaling is done with `\scaleDurations`, which is used in a similar way to `\times`, but does not create a tuplet bracket; see Scaling durations.

In this 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, as 2/3 * 9/8 = 3/4, and in the third staff, shown durations are multiplied by 3/5, as 3/5 * 10/8 = 3/4. It will often be necessary to insert beams manually, as the duration scaling affects the autobeaming rules.

>     \relative c' <<
>       \new Staff {
>         \time 3/4
>         c4 c c |
>         c 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. c4. \times 2/3 { c8[ c c] } c4
>         }
>       }
>     >>

Staves with different time signatures, unequal bar lengths

Each staff can be given its own independent time signature by moving the `Timing_translator` and the `Default_bar_line_engraver` to the `Staff` context.

>     \layout {
>       \context {
>         \Score
>         \remove "Timing_translator"
>         \remove "Default_bar_line_engraver"
>       }
>       \context {
>         \Staff
>         \consists "Timing_translator"
>         \consists "Default_bar_line_engraver"
>       }
>     }

>     % Now each staff has its own time signature.

>     \relative c' <<
>       \new Staff {
>         \time 3/4
>         c4 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 |
>       }
>     >>

#### Selected Snippets

Compound time signatures

Odd 20th century time signatures (such as "5/8") can often be played as compound time signatures (e.g. "3/8 + 2/8"), which combine two or more inequal metrics. LilyPond can make such music quite easy to read and play, by explicitly printing the compound time signatures and adapting the automatic beaming behavior. (Graphic measure grouping indications can also be added; see the appropriate snippet in this database.)

>     #(define ((compound-time one two num) grob)
>        (grob-interpret-markup grob
>                               (markup #:override '(baseline-skip . 0) #:number
>                                       (#:line ((#:column (one num))
>                                                #:vcenter "+"
>                                                (#:column (two num)))))))

>     \relative c' {
>       \override Staff.TimeSignature #'stencil = #(compound-time "2" "3" "8")
>       \time 5/8
>       \set Staff.beatStructure = #'(2 3)
>       c8 d e fis gis
>       c8 fis, gis e d
>       c8 d e4 gis8
>     }

#### See also

Music Glossary: polymetric, polymetric time signature, meter.

Notation Reference: Time signature, Scaling durations.

Snippets: Rhythms.

Internals Reference: TimeSignature, Timing_translator, Default_bar_line_engraver, Staff.

#### Known issues and warnings

When using different time signatures in parallel, notes at the same moment will be placed at the same horizontal location. However, the bar lines in the different staves will cause the note spacing to be less regular in each of the individual staves than would be normal without 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 "Note_heads_engraver"
>       \consists "Completion_heads_engraver"
>       \remove "Rest_engraver"
>       \consists "Completion_rest_engraver"
>     }

>     { c2. 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.

#### See also

Music Glossary: tie

Learning Manual: Engravers explained, Adding and removing engravers.

Snippets: Rhythms.

Internals Reference: Note_heads_engraver, Completion_heads_engraver, Rest_engraver, Completion_rest_engraver, Forbid_line_break_engraver.

#### Known issues and warnings

Not all durations (especially those containing tuplets) can be represented exactly with normal notes and dots, but the `Completion_heads_engraver` will not insert tuplets.

The `Completion_heads_engraver` only affects notes; it does not split rests.

#### 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" {
>           \time 4/4
>           c4 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
>       }
>     >>

#### Predefined commands

`\improvisationOn`, `\improvisationOff`.

#### Selected Snippets

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

#### See also

Snippets: Rhythms.

Internals Reference: RhythmicStaff, Pitch_squash_engraver.

Jiné jazyky: deutsch, español, français, 日本語.

#### LilyPond — Notation Reference