Metric modulation (proportional tempi)

Revision as of 22:38, 13 June 2026 by Gabriel Ellsworth (talk | contribs) (I added links to Yoshiaki Onishi’s solution.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This snippet shows how you can typeset a metric modulation as a rehearsal mark. (See this thread on the mailing list.)

In the code below, the following commands enable you to center the = glyph above the bar line.

  1. \general-align commands set the center of the myMetricModulation markup to be the center of the equals sign (=). For more information, see A.1.2 Markup for text alignment in the Notation Reference.
  2. \put-adjacent commands add elements to the sides of the equals sign without shifting it. See A.1.2 Markup for text alignment.
  3. Switching off self-alignment-X means that the 0 coordinate of the stencil gets used for alignment with the bar line, without any shifting. (If you do not include \tweak self-alignment-X ##f, then self-alignment-X = 0 will calculate a shift in order to align the center of the markup, rather than the equals sign, to its anchor point.)

The music on this page is from Tomás Luis de Victoria, “O magnum mysterium,” Tenor part (PDF of source).

Some other approaches to metric modulations:

  1. Metric modulation with tuplet shows a way to indicate a metric modulation that refers to a duration within a tuplet.
  2. Yoshiaki Onishi’s approaches use \textEndMark and \textMark and print left and right arrows (← →) on each side of the equation, following the example of the scores of composer Elliott Carter. For an explanation, search for “Metric Modulation Equation” in Onishi’s LilyPond Contemporary Notation Cookbook; for the code, see metricModulationRegularFlag.ly and metricmodulationStraightFlag.ly. His commands support tuplet note values.

\version "2.26"

% Optional: Define markup commands
% to contain shortcuts for the notes
% to typeset in your metric modulation markup.
simpleBreve = \markup {
  \override #'(style . baroque)
  \note { \breve }
  #UP % (stem direction)
}

dottedBreve = \markup {
  \override #'(style . baroque)
  \note { \breve. }
  #UP % (stem direction)
}

thickSpace = \markup \char ##x2004
% Unicode codepoint U+2004 is a
% Three-per-Em space
% (also known as a “thick space”); see
% https://en.wikipedia.org/wiki/Whitespace_character#Unicode

% Define a custom markup command
% to typeset an equals sign (=)
% with a thick space on each side.
equals = \markup {
  \put-adjacent #X #RIGHT
  \put-adjacent #X #LEFT
  \general-align #Y #DOWN \char ##x003D
  % https://en.wikipedia.org/wiki/Mathematical_operators_and_symbols_in_Unicode
  \thickSpace
  \thickSpace
}

% Define a markup that says
% “breve = dotted breve”
% with the = glyph at the
% center of this markup.
myMetricModulation = \markup {
  \put-adjacent #X #RIGHT
  \put-adjacent #X #LEFT
  
  \general-align #X #CENTER
  \general-align #Y #CENTER
  \equals
  
  \simpleBreve
  \dottedBreve
}

words = \lyricmode {
  Ie -- sum Chris -- tum
  al -- le -- lu -- ia
  al
}

music = \relative {
  \key g \dorian
  \clef "petrucci-c4"
  \override NoteHead.style = #'baroque
  \tag #'metronome { \tempo 1 = 60 }
  \time 2/1
  f\breve | g1 a1 |
  \tweak self-alignment-X ##f
  \mark \myMetricModulation
  \tag #'metronome {
    \once \override Score.MetronomeMark.X-offset = #7
    \tempo "" 1 = 90
  }
  \time 3/1
  g\breve g1 | d'\breve d1 |
  c\breve c1 |
}

\markup { \circle 1 Metric modulation: }
\markup \vspace #0.2
\score {
  <<
    \new Voice = "tenor"
      \removeWithTag #'metronome \music
    \new Lyrics \lyricsto "tenor" \words
  >>
}

\markup { \circle 2 With metronome marks added: }
\markup \vspace #0.2
\score {
  <<
    \new Voice = "tenor"
      \keepWithTag #'metronome \music
    \new Lyrics \lyricsto "tenor" \words
  >>
}