Manual beams

In some cases it may be necessary to override the automatic beaming algorithm. For example, the auto-beamer 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 ].

\relative { r4 r8[ g' a r] r g[ | a] r }

[image of music]

Beaming direction can be set manually using direction indicators:

\relative { c''8^[ d e] c,_[ d e f g] }

[image of music]

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

\relative {
  \time 2/4
  c''8 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.

\relative {
  c''4 d8[
  \grace { e32 d c d }
  e8] e[ 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.

\relative a' {
  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

Beam nibs

Beam nibs at the start and end of beams together with beams attached to solitary notes that look like flat flags are possible with a combination of stemLeftBeamCount, stemRightBeamCount, and paired [] beam indicators.

For imitating right-pointing flat flags on lone notes, use paired [] beam indicators and set stemLeftBeamCount to zero. For imitating left-pointing flat flags on lone notes, set stemRightBeamCount to zero instead (line one).

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

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

Note that \set stemLeftBeamCount is always equivalent to \once \set. In other words, the beam count settings are not “sticky”, so the pair of nibs attached to the lone 16th note in the last example has nothing to do with the \set command for the beam before.

\score {
  <<
    \new RhythmicStaff {
      \set stemLeftBeamCount = 0
      c16[] r8.
      r8.
      \set stemRightBeamCount = 0
      16[]
    }
    \new RhythmicStaff {
      16 16
      \set stemRightBeamCount = 2
      16 r r
      \set stemLeftBeamCount = 2
      16 16 16
    }
    \new RhythmicStaff {
      16 16
      \set stemRightBeamCount = 2
      16 r16
      16[] r16
      \set stemLeftBeamCount = 2
      16 16
    }
  >>
}

[image of music]

Using alternative flag styles

Alternative shapes for flags on eighth and shorter notes can be displayed by overriding the stencil property of Flag. LilyPond provides the following functions: modern-straight-flag, old-straight-flag, and flat-flag. Use \revert to restore the default shape.

To get stacked (i.e., vertically more compact) flags, call the command \flagStyleStacked, which can be reset with \flagStyleDefault.

Overriding the Flag stencil does not change how flag elements are positioned vertically. This is especially noticeable for flat flags: LilyPond doesn’t dynamically adjust the vertical gaps between flag elements in the same way as it does for beams. A possible solution to harmonize the appearance is to replace flat flags with half beams, as shown in the second staff; however, this can’t be done automatically. In the code of this snippet, such half beams are entered with @ as a prefix, for example @c8.

Be aware that half beams are not Flag grobs. This means in particular that modifying Flag properties won’t have any effect on them (you have to use Beam properties instead), and properties for their associated Stem grob will also behave beam-like.

"@" =
#(define-music-function (music) (ly:music?)
  #{ \set stemLeftBeamCount = 0 $music [] #})

testnotes = {
  \autoBeamOff
  c8 d16 e''32 f64 \acciaccatura { g,,,8 } a128 b
}

\relative c' {
  \override TextScript.staff-padding = 6
  \time 1/4
    <>^"default" \testnotes
  \override Flag.stencil = #modern-straight-flag
    <>_"modern straight" \testnotes
  \override Flag.stencil = #old-straight-flag
    <>^"old straight" \testnotes
  \override Flag.stencil = #flat-flag
    <>_"flat" \testnotes
  \revert Flag.stencil

  \flagStyleStacked
    <>^"stacked" \testnotes
  \flagStyleDefault
    <>_"default" \testnotes
}

\relative c' {
  \time 3/4
  \override Flag.stencil = #flat-flag

  <>^"flat" c8 c[ c] d16 d[ d] e''32 e[ e] f64 f[ f]
    \acciaccatura { g,,,8 } a128 a[ a a a a]
  <>^"beam-like" @c8 c[ c] @d16 d[ d] @e''32 e[ e] @f64 f[ f]
    \acciaccatura { g,,,8 } @a128 a[ a a a a]
}

\layout {
  indent = 0
  \context {
    \Score
    \override NonMusicalPaperColumn.line-break-permission = ##f
  }
}

[image of music]

See also

Notation Reference: Direction and placement, Grace notes.

Snippets: Rhythms.

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


LilyPond Notation Reference v2.25.22 (development-branch).