1.2.3 Displaying rhythms


Time signature

The time signature is set as follows:

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

[image of music]

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

[image of music]

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

[image of music]

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

[image of music]

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

[image of music]

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

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

[image of music]

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

[image of music]

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

[image of music]

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
}

[image of music]

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

[image of music]

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

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

[image of music]

Tempo indications with text can be used instead:

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

[image of music]

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

[image of music]

In general, the text can be any markup object:

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

[image of music]

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

[image of music]

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
}

[image of music]

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

[image of music]

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
}

[image of music]

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 |

[image of music]

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

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

[image of music]

The \partial duration can also be written as;

\set Timing.measurePosition -duration

So \partial 8 becomes:

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

[image of music]

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

[image of music]


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

[image of music]

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

[image of music]

A new bar is never started within a cadenza, even if one or more \bar commands are inserted within it. Therefore, reminder accidentals will need to be added manually. See Accidentals.

c4 d e d
\cadenzaOn
cis4 d cis d
\bar "|"
cis4 d cis! d
\cadenzaOff
\bar "|"

[image of music]

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 }

[image of music]

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

Explicitly create a Voice context when starting a piece with \cadenzaOn, else unexpected errors may occur.

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

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 \times 2/3 { c8[ c c] } c4
    }
  }
>>

[image of music]

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

[image of music]

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
}

[image of music]

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
}

[image of music]

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 }

[image of music]

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

[image of music]

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

[image of music]

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

[image of music]

See also

Snippets: Rhythms.

Internals Reference: RhythmicStaff, Pitch_squash_engraver.


Other languages: deutsch, español, français, italiano, 日本語.
About automatic language selection.

LilyPond — Notation Reference