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

#### Selected Snippets

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

#### See also

Music Glossary: time signature

Notation Reference: Mensural time signatures, Polymetric notation, Setting automatic beam behavior, Time administration.

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 particularly useful markup command is `\rhythm`, which prints a rhythmic pattern. See Music.

>     \relative {
>       \tempo \markup {
>         Swing
>         \hspace #0.4
>         \rhythm { 8[ 8] } = \rhythm { \tuplet 3/2 { 4 8 } }
>       }
>       b8 g' c, d ees d16 ees d c r8
>     }

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

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

#### See also

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.

#### See also

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
>       \cadenzaOn
>       c4 cis d8[ d d] f4 g4.
>       \cadenzaOff
>       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 = {
>       \cadenzaOff
>       \partial 1024 s1024
>       \cadenzaOn
>     }

>     \relative c'' {
>       % Show all bar numbers
>       \override Score.BarNumber.break-visibility = #all-visible
>       c4 d e d
>       \cadenzaOn
>       c4 cis \bar "!" d8[ d d] \cadenzaMeasure f4 g4.
>       \cadenzaMeasure
>       \cadenzaOff
>       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 }
>       \cadenzaOn
>       cis8 c c c c
>       \bar"|"
>       c8 c c
>       \cadenzaOff
>       \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 or other solutions in Line breaking.

>     \relative {
>       c'4 f g c, d f g c
>       \cadenzaOn
>       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`.

#### See also

Music Glossary: cadenza.

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 3 { c8[ c c] }
>           \repeat unfold 3 { c4 c8 }
>         }
>       }
>       \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
>     }

#### See also

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 Note_heads_engraver
>       \consists Completion_heads_engraver
>       \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 {
>       \remove Note_heads_engraver
>       \consists Completion_heads_engraver
>     } \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 {
>       \remove Note_heads_engraver
>       \consists Completion_heads_engraver
>     } \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
>     }

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

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

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

#### LilyPond — Notation Reference v2.24.4 (stable-branch).