### 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 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 c' {
>           \time #'(2 2 3) 7/8
>           \repeat unfold 7 { c8 } |
>           \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 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"
>         }
>       }
>     }

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 (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, Setting automatic beam behavior, Time administration.

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

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

In a part for an instrument with long periods of 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.

>     \compressFullBarRests
>     \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 { 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 an upbeat, are entered using the `\partial` command,

>     \partial duration

where `duration` is the remaining length of the partial measure before the start of the next full measure.

>     \time 3/4
>     \partial 8
>     e8 | a4 c8 b c4 |

The duration can be any value less than a full measure:

>     \time 3/4
>     \partial 4.
>     r4 e8 | a4 c8 b c4 |

`\partial duration` can also be written as:

>     \set Timing.measurePosition -duration

So the first example above could be written:

>     \time 3/4
>     \set Timing.measurePosition = #(ly:make-moment -1/8)
>     e8 | a4 c8 b c4 |

The property `measurePosition` contains a rational number, which is usually positive and indicates how much of the measure has passed at this point. The `\partial duration` command sets it to a negative number, when it has a different meaning: it then says that the current (first) bar will be preceded by a bar 0 (the partial bar) with a duration given by duration.

#### See also

Music Glossary: anacrusis.

Notation Reference: Grace notes.

Snippets: Rhythms.

Internal Reference: Timing_translator.

#### Known issues and warnings

The `\partial` command should be used only at the beginning of a piece. If you use it after the beginning, warnings or problems may occur, so use `\set Timing.measurePosition` instead.

>     \time 6/8
>     \partial 8
>     e8 | a4 c8 b[ c b] |
>     \set Timing.measurePosition = #(ly:make-moment -1/4)
>     r8 e,8 | a4 c8 b[ c b] |

#### Unmetered music

In metered music bar lines are inserted and bar numbers are calculated automatically. In unmetered music (i.e. cadenzas), this is not desirable and can be ‘switched off’ using the command `\cadenzaOn`, then ‘switched back on’ at the appropriate place using `\cadenzaOff`.

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

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

Inserting a `\bar` command within a cadenza does not start a new measure, even if a bar line is printed. So any accidentals – which are usually assumed to remain in force until the end of the measure – will still be valid after the bar line printed by `\bar`. If subsequent accidentals should be printed, forced accidentals or reminder accidentals need to be inserted manually, see Accidentals.

>     c4 d e d
>     \cadenzaOn
>     cis4 d cis d
>     \bar "|"
>     % First cis is printed without alteration even if it's after a \bar
>     cis4 d cis! d
>     \cadenzaOff
>     \bar "|"

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

>     \repeat unfold 8 { c8 }
>     \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.

#### Predefined commands

`\cadenzaOn`, `\cadenzaOff`.

#### See also

Music Glossary: cadenza.

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

Snippets: Rhythms.

#### Known issues and warnings

Automatic line and page breaks are inserted only at bar lines, so ‘invisible’ bar lines will need to be inserted manually in long stretches of unmetered music to permit breaking:

>     \bar ""

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

#### 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 c' {
>       \compoundMeter #'((2 2 2 8))
>       \repeat unfold 6 c8 \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 c' {
>       \compoundMeter #'((1 4) (3 8))
>       \repeat unfold 5 c8 \repeat unfold 10 c16
>     }

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

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

其他语言：deutsch, español, français, italiano, 日本語。
About automatic language selection.

#### LilyPond — Notation Reference v2.18.2 (稳定分支).