Expressive Text

Expressive text markings like dynamics and tempo marks can be written using simple Text and MusicText objects, but we provide some built-in functionality for convenience.

Dynamics

Classical dynamics can be easily written in their idiomatic style with the Dynamic class.

staff = Staff(ORIGIN, None, Mm(30))
Dynamic((ZERO, staff.unit(7)), staff, "p")
/_static/rendered_examples/57OXXRDYYIZGMUFHJWIBYXP5L5GCDJV5.png

Dynamic strings can consist of any of the following letters: p, m, f, r, s, z, n.

staff = Staff(ORIGIN, None, Mm(30))
Dynamic((ZERO, staff.unit(7)), staff, "sfz")
/_static/rendered_examples/VKXOTWSGO5YB6O7R5LSALGRPDHAQJ7XW.png

Metronome Markings

Metronome marks are supported with the MetronomeMark class.

staff = Staff(ORIGIN, None, Mm(30))
MetronomeMark((ZERO, staff.unit(-2)), staff, "metNoteQuarterUp", "= 60")
/_static/rendered_examples/TRZJ5DC3VSHBYFYWTSG4Q5C45AT7ZN24.png

MetronomeMark works like a combined MusicText and Text object. It takes two text arguments, the first in MusicTexts format, and the second a plain text string, and it takes two fonts (optionally inheriting the MusicFont from an ancestor).

staff = Staff(ORIGIN, None, Mm(30))
MetronomeMark(
   (ZERO, staff.unit(-2)),
   staff,
   ["metNoteQuarterUp", "metAugmentationDot"],
   "≈ 96",
)
/_static/rendered_examples/T2D4LU3RGDTZOKERX62GYE4SH7FFCZXZ.png

See the metronome marks SMuFL range for commonly used glyphs in the left-side text.

Articulations and Ornaments

Articulations and ornaments are created as regular MusicText objects. SMuFL provides a large collection of articulation glyphs here and ornament glyphs here. For convenience, Chordrest provides an attachment point above or below the outermost notehead with Chordrest.extra_attachment_point; placing centered MusicText here can often work out of the box.

staff = Staff(ORIGIN, None, Mm(30))
Clef(ZERO, staff, 'treble')
c = Chordrest(Mm(2), staff, ["c'", "e'"], (1, 8))
MusicText(c.extra_attachment_point, c, "ornamentTurnInverted",
   alignment_x=AlignmentX.CENTER, alignment_y=AlignmentY.CENTER)
/_static/rendered_examples/4AC4DGKUDUHZD3JXACDV5ZGQLE423QZU.png
staff = Staff(ORIGIN, None, Mm(30))
Clef(ZERO, staff, 'treble')
c = Chordrest(Mm(2), staff, ["c#", "g"], (1, 8))
MusicText(c.extra_attachment_point, c, "articAccentBelow",
   alignment_x=AlignmentX.CENTER, alignment_y=AlignmentY.CENTER)
/_static/rendered_examples/IBRRZVH75BHZEMSH4W3ZKYHU2DNWBE5Y.png