1.2.4 Beams


Automatic beams

By default, beams are inserted automatically:

\time 2/4 c8 c c c
\time 6/8 c c c c8. c16 c8

[image of music]

If these automatic decisions are not satisfactory, beaming can be entered explicitly; see Manual beams. Beams must be entered manually if beams are to be extended over rests.

If automatic beaming is not required, it may be turned off with \autoBeamOff and on with \autoBeamOn:

c4 c8 c8. c16 c8. c16 c8
\autoBeamOff
c4 c8 c8. c16 c8.
\autoBeamOn
c16 c8

[image of music]

Note: If beams are used to indicate melismata in songs, then automatic beaming should be switched off with autoBeamOff and the beams indicated manually.

Beaming patterns that differ from the automatic defaults can be created; see Setting automatic beam behavior.

Predefined commands

\autoBeamOff, \autoBeamOn.

Selected Snippets

Beams across line breaks

Line breaks are normally forbidden when beams cross bar lines. This behavior can be changed as shown:

\relative c'' {
  \override Beam #'breakable = ##t
  c8 c[ c] c[ c] c[ c] c[ \break
  c8] c[ c] c[ c] c[ c] c
}


[image of music]

Changing beam knee gap

Kneed beams are inserted automatically when a large gap is detected between the note heads. This behavior can be tuned through the auto-knee-gap property. A kneed beam is drawn if the gap is larger than the value of auto-knee-gap plus the width of the beam object (which depends on the duration of the notes and the slope of the beam). By default auto-knee-gap is set to 5.5 staff spaces.

{
  f8 f''8 f8 f''8
  \override Beam #'auto-knee-gap = #6
  f8 f''8 f8 f''8
}

[image of music]

See also

Notation Reference: Manual beams, Setting automatic beam behavior.

Installed Files: ‘scm/auto-beam.scm’.

Snippets: Rhythms.

Internals Reference: Auto_beam_engraver, Beam_engraver, Beam, BeamEvent, BeamForbidEvent, beam-interface, unbreakable-spanner-interface.

Known issues and warnings

Beams can collide with note heads and accidentals in other voices.


Setting automatic beam behavior

The placement of automatic beams is determined by the time signature. Three types of rules are used for determining the end of automatic beams: default rules for the time signature, explicit rules for the beam in the time signature, and the beatLength for the time signature.

The following rules, in order of priority, apply when determining the appearance of beams:

Modifying the grouping of beats

By default beatLength is derived from the time signature set by the \time command. The beatLength is set to be one over the denominator of the time signature.

beatLength is a moment, a unit of musical duration. A quantity of type moment is created by the scheme function ly:make-moment. For more information about this function, see Time administration.

Autobeam settings are stored in the beamSettings property. Default values of beamSettings are determined in ‘scm/beam-settings.scm’. Entries in beamSettings are indexed by time signature and rule type.

Time signature should be a scheme pair , e.g. #'(4 . 4).

Rule type should be #'end for beam ending.

The ending rules consist of a scheme alist (or list of pairs) that indicates the beam type and the grouping to be applied to beams containing notes with a shortest duration of that beam type.

#'((beam-type1 . grouping-1)
   (beam-type2 . grouping-2)
   (beam-type3 . grouping-3))

Beam type is either a scheme pair indicating the duration of the beam, e.g. (1 . 16), or * to indicate a default rule, which applies to all beams if no explicit rule is defined.

Grouping is a scheme list indicating the grouping to be applied to the beam. For default rules (where beam type is *, the grouping is in units of beatLength. For explicit rules, the grouping is in units of the beam type.

For reference, the default beaming rules are found in ‘scm/beam-settings.scm’.

Beam settings are changed with \overrideBeamSettings and \revertBeamSettings.

Note: The ending settings must be complete rules. That is, every rule that should apply to the current time signature must be included in the setting. It is not possible to change the grouping of only one beam type for a given time signature. While this may seem cumbersome, it means that the current beaming settings need not be known in order to specify a new beaming pattern.

\time 5/16
c8^"beats" c16 c8 |
\overrideBeamSettings #'Score #'(5 . 16) #'end #'((* . (2 3)))
c8^"(2+3)" c16 c8
\overrideBeamSettings #'Score #'(5 . 16) #'end #'((* . (3 2)))
c8^"(3+2)" c16 c8

[image of music]

Beam setting changes can be limited to specific contexts. If no setting is included in a lower-level context, the setting of the enclosing context will apply.

\new Staff <<
  \time 7/8
  \new Voice = one {
    \relative c'' {
      \overrideBeamSettings #'Staff #'(7 . 8) #'end #'((* . (2 3 2)))
        a8 a a a a a a
    }
  }
  \new Voice  = two {
    \relative c' {
      \voiceTwo
      \overrideBeamSettings #'Voice #'(7 . 8) #'end #'((* . (1 3 3)))
      f8 f f f f f f
    }
  }
>>

[image of music]

When multiple voices are used the Staff context must be specified if the beaming is to be applied to all voices in the staff:

\time 7/8
% rhythm 3-1-1-2
% Context Voice specified --  does not work correctly
% Because of autogenerated voices, all beating will
% be at beatLength (1 . 8)
\overrideBeamSettings #'Voice #'(7 . 8) #'end #'((* . (3 1 1 2)))
<< {a8 a a a16 a a a a8 a} \\ {f4. f8 f f f} >>

% Works correctly with context Staff specified
\overrideBeamSettings #'Staff #'(7 . 8) #'end #'((* . (3 1 1 2)))
<< {a8 a a a16 a a a a8 a} \\ {f4. f8 f f f} >>

[image of music]

Beam settings can be reverted to get back to default behavior. This is accomplished by using \revertBeamSettings. The arguments are the same as for \overrideBeamSettings, except no value for grouping is given:

\revertBeamSettings context time-signature rule-type
\time 4/4
\repeat unfold 8 {a8}
% set default rule for (1 1 1 1) grouping
\overrideBeamSettings #'Score #'(4 . 4) #'end #'((* . (1 1 1 1)))
\repeat unfold 8 {a8}
% revert the new rule
\revertBeamSettings #'Score #'(4 . 4) #'end
\repeat unfold 8 {a8}

[image of music]

Predefined commands

\overrideBeamSettings, \revertBeamSettings.

Selected Snippets

Sub-dividing beams

The beams of consecutive 16th (or shorter) notes are, by default, not sub-divided. That is, the three (or more) beams stretch unbroken over entire groups of notes. This behavior can be modified to sub-divide the beams into sub-groups by setting the property subdivideBeams. When set, multiple beams will be sub-divided at intervals defined by the current value of beatLength by reducing the multiple beams to just one beam between the sub-groups. Note that beatLength defaults to one over the denominator of the current time signature if not set explicitly. It must be set to a fraction giving the duration of the beam sub-group using the ly:make-moment function, as shown here:

\relative c'' {
  c32[ c c c c c c c]
  \set subdivideBeams = ##t
  c32[ c c c c c c c]

  % Set beam sub-group length to an eighth note
  \set beatLength = #(ly:make-moment 1 8)
  c32[ c c c c c c c]

  % Set beam sub-group length to a sixteenth note
  \set beatLength = #(ly:make-moment 1 16)
  c32[ c c c c c c c]
}

[image of music]

Conducting signs measure grouping signs

Beat grouping within a bar is controlled by the default grouping established in beamSettings. This grouping can be established by the use of \overrideBeamSettings. Alternatively, the Scheme function set-time-signature can be used to both set the time signature and establish the default grouping rule. set-time-signature, takes three arguments: the number of beats, the beat length, and the internal grouping of beats in the measure. If the Measure_grouping_engraver is included in one of the display contexts, measure grouping signs will be created. Such signs ease reading rhythmically complex modern music. In the example, the 9/8 measure is grouped in two different patterns using the two different methods, while the 5/8 measure is grouped according to the default setting in ‘scm/beam-settings.scm’:

\score {
  \relative c'' {
    \time 9/8
    \overrideBeamSettings #'Score #'(9 . 8) #'end #'((* . (2 2 2 3)))
    g8 g d d g g a( bes g) |
    #(set-time-signature 9 8 '(4 5))
    g8 g d d g g a( bes g) |
    \time 5/8
    a4. g4 |
  }
  \layout {
    \context {
      \Staff
      \consists "Measure_grouping_engraver"
    }
  }
}

[image of music]

Beam endings in Score context

Beam-ending rules specified in the Score context apply to all staves, but can be modified at both Staff and Voice levels:

\relative c'' {
  \time 5/4
  % Set default beaming for all staves
  \overrideBeamSettings #'Score #'(5 . 4) #'end
     #'(((1 . 8) . (3 4 3))
        ((1 . 16) . (6 8 6))
        ((1 . 32) . (12 16 12)))
  <<
    \new Staff {
      c8 c c c c c c c c c
    }
    \new Staff {
      % Modify beaming for just this staff
      \overrideBeamSettings #'Staff #'(5 . 4) #'end
        #'((* . (3 2)))
      c8 c c c c c c c c c
    }
    \new Staff {
      % Inherit beaming from Score context
      <<
        {
          \voiceOne
          c8 c c c c c c c c c
        }
        % Modify beaming for this voice only
        \new Voice {
          \voiceTwo
          \overrideBeamSettings #'Voice #'(5 . 4) #'end
              #'((* . (3 2)))
          a8 a a a a a a a a a
        }
      >>
    }
  >>
}

[image of music]

See also

Installed files: ‘scm/beam-settings.scm’.

Snippets: Rhythms.

Internals Reference: Auto_beam_engraver, Beam, BeamForbidEvent, beam-interface.

Known issues and warnings

If a score ends while an automatic beam has not been ended and is still accepting notes, this last beam will not be typeset at all. The same holds for polyphonic voices, entered with << … \\ … >>. If a polyphonic voice ends while an automatic beam is still accepting notes, it is not typeset. The workaround for these problems is to manually beam the last beam in the voice or score.


Manual beams

In some cases it may be necessary to override the automatic beaming algorithm. For example, the autobeamer will not put beams over rests or bar lines, and in choral scores the beaming is often set to follow the meter of the lyrics rather than the notes. Such beams can be specified manually by marking the begin and end point with [ and ].

r4 r8[ g' a r8] r8 g[ | a] r8

[image of music]

Beaming direction can be set manually using direction indicators:

c8^[ d e] c,_[ d e f g]

[image of music]

Individual notes may be marked with \noBeam to prevent them from being beamed:

\time 2/4
c8 c\noBeam c c

[image of music]

Grace note beams and normal note beams can occur simultaneously. Unbeamed grace notes are not put into normal note beams.

c4 d8[
\grace { e32[ d c d] }
e8] e8[ e
\grace { f16 }
e8 e]

[image of music]

Even more strict manual control with the beams can be achieved by setting the properties stemLeftBeamCount and stemRightBeamCount. They specify the number of beams to draw on the left and right side, respectively, of the next note. If either property is set, its value will be used only once, and then it is erased. In this example, the last f is printed with only one beam on the left side, i.e., the eighth-note beam of the group as a whole.

a8[ r16 f g a]
a8[ r16
\set stemLeftBeamCount = #2
\set stemRightBeamCount = #1
f16
\set stemLeftBeamCount = #1
g16 a]

[image of music]

Predefined commands

\noBeam.

Selected Snippets

Flat flags and beam nibs

Flat flags on lone notes and beam nibs at the ends of beamed figures are both possible with a combination of stemLeftBeamCount, stemRightBeamCount and paired [] beam indicators.

For right-pointing flat flags on lone notes, use paired [] beam indicators and set stemLeftBeamCount to zero (see Example 1).

For left-pointing flat flags, set stemRightBeamCount instead (Example 2).

For right-pointing nibs at the end of a run of beamed notes, set stemRightBeamCount to a positive value. And for left-pointing nibs at the start of a run of beamed notes, set stemLeftBeamCount instead (Example 3).

Sometimes it may make sense for a lone note surrounded by rests to carry both a left- and right-pointing flat flag. Do this with paired [] beam indicators alone (Example 4).

(Note that \set stemLeftBeamCount is always equivalent to \once \set. In other words, the beam count settings are not “sticky”, so the pair of flat flags attached to the lone c'16[] in the last example have nothing to do with the \set two notes prior.)

\score {
  <<
    % Example 1
    \new RhythmicStaff {
      \set stemLeftBeamCount = #0
      c16[]
      r8.
    }
    % Example 2
    \new RhythmicStaff {
      r8.
      \set stemRightBeamCount = #0
      c16[]
    }
    % Example 3
    \new RhythmicStaff {
      c16 c
      \set stemRightBeamCount = #2
      c16 r r
      \set stemLeftBeamCount = #2
      c16 c c
    }
    % Example 4
    \new RhythmicStaff {
      c16 c
      \set stemRightBeamCount = #2
      c16 r
      c16[]
      r16
      \set stemLeftBeamCount = #2
      c16 c
    }
  >>
}

[image of music]

See also

Notation Reference: Direction and placement, Grace notes.

Snippets: Rhythms.

Internals Reference: Beam, BeamEvent, Beam_engraver, beam-interface, Stem_engraver.


Feathered beams

Feathered beams are used to indicate that a small group of notes should be played at an increasing (or decreasing) tempo, without changing the overall tempo of the piece. The extent of the feathered beam must be indicated manually using [ and ], and the beam feathering is turned on by specifying a direction to the Beam property grow-direction.

If the placement of the notes and the sound in the MIDI output is to reflect the ritardando or accelerando indicated by the feathered beam the notes must be grouped as a music expression delimited by braces and preceded by a featherDurations command which specifies the ratio between the durations of the first and last notes in the group.

The square brackets show the extent of the beam and the braces show which notes are to have their durations modified. Normally these would delimit the same group of notes, but this is not required: the two commands are independent.

In the following example the eight 16th notes occupy exactly the same time as a half note, but the first note is one half as long as the last one, with the intermediate notes gradually lengthening. The first four 32nd notes gradually speed up, while the last four 32nd notes are at a constant tempo.

\override Beam #'grow-direction = #LEFT
\featherDurations #(ly:make-moment 2 1)
{ c16[ c c c c c c c] }
\override Beam #'grow-direction = #RIGHT
\featherDurations #(ly:make-moment 2 3)
{ c32[ d e f] }
% revert to non-feathered beams
\override Beam #'grow-direction = #'()
{ g32[ a b c] }

[image of music]

The spacing in the printed output represents the note durations only approximately, but the MIDI output is exact.

Predefined commands

\featherDurations.

See also

Snippets: Rhythms.

Known issues and warnings

The \featherDurations command only works with very short music snippets, and when numbers in the fraction are small.


Other languages: deutsch, español, français.

LilyPond — Notation Reference