22. User-defined Symbols

This chapter describes the elements, model classes, and attribute classes that are part of the MEI.usersymbols module.

22.1. Overview of the User Symbols Module

The module described in this chapter makes available the following components:

22.1.1. Elements

Container for text that is fixed to a particular page location, regardless of changes made to the layout of the measures around it.
A curved line that cannot be represented by a more specific element, such as a slur.
A visual line that cannot be represented by a more specific; i.e., semantic, element.
A reference to a previously defined symbol.
(symbol definition) – Declaration of an individual symbol in a symbolTable.
Contains a set of user-defined symbols.

22.1.2. Attribute Classes

No attribute classes are defined in this module.

22.1.3. Model Classes

The usersymbols module defines the following model classes:

Groups elements that function as drawing primitives.
Groups elements that group symbol definitions.

22.2. Uses of the Usersymbols Module

The elements provided by the usersymbols module may be used in two ways:

  1. For defining lines, curves and text elements that cannot be represented by a more specific element.
  2. For defining reusable symbols and special graphical renditions.For this purpose, it provides three elements as graphic primitives, line, curve and anchoredText. Anywhere these elements are allowed, the symbol element can be used as well. The symbol element facilitates the re-use of symbols that were defined by symbolDef elements.

22.2.1. Defining Reusable Symbols

The symbolDef element uses SVG markup or the aforementioned graphic primitives to describe a symbol. A symbol definition may also use symbols defined by other symbolDef elements by employing the symbol element.

musical example
Definition of a triangle percussion symbol using graphic primitives
musical example
Rendition of the triangle defined above
musical example
Symbol composed of the symbol defined above and additional graphics primitives
musical example
Rendition of the composite triangle symbol

22.2.2. Elements Without Semantic Implications

The graphics primitives and symbols can be used directly in the music to describe text and lines on a purely graphical level, without implying a specific logical meaning. If possible, however, more meaningful elements should be used. This means for example, “a tempo” or “da capo” should in general not be put inside anchoredText. Instead, tempo and dir should be used. Likewise, slurs and ties should be encoded using their respective elements, not using curve, and for glissandi, gliss should be used instead of line.

An example usage for line is the visualization of voice leading, which is not covered by a specific MEI element.

musical example
Voice leading visualization as found in an Edition Peters print of "Album für die Jugend" by Schumann, No. 35 (Mignon), measure 6. (Unknown date, plate number is 10478.)
musical example
Encoding of the Schumann example

22.2.3. Defining a Specific Graphical Rendition for a Semantic Element

Usersymbols can define the rendition of different elements in two ways. Some elements, for example dir and tempo, can have user symbol elements as content. In the following example, the content of dir is used to provide pictograms of percussion instruments.

musical example
Indicating percussion instruments using pictograms
musical example
Encoding of above example

A number of elements can point to an internally-defined symbol for rendering using the @altsym attribute.

musical example
Different treble clef renditions as written by Charpentier
musical example
Defining two staffs, each using its own treble clef shape

Externally-defined symbols may be referenced using a @glyphname or @glyphnum attribute. Both attributes refer to Standard Music Font Layout (SMuFL) characters. Other character sets must be treated as internally-defined character sets.

musical example
Use of glyphname and glyphnum attributes

22.3. Positioning and Coordinates

22.3.1. Axis Orientation

MEI uses the classic axis directions where the x-axis points from left to right and the y-axis points from bottom up. (This is compatible with PostScript’s axis orientation, while SVG’s y-axis points in the opposite direction.)

22.3.2. Units

There are two types of units used by MEI: Staff units (data.MEASUREMENT) and units of the output coordinate system. Units of the output coordinate system can be translated to physical real world distances by means of the @vu.height and @page.scale of a scoreDef element. Real world units are multiplied by the value of @page.scale to get the corresponding value in output coordinate units.

If an element is scaled using the @scale attribute, the actual size of the units changes accordingly.

22.3.3. Positioning

An element may be positioned using either absolute or relative coordinates. If absolute start point coordinates are specified using @x/@y coordinates (or their relatives @x2/@y2 for endpoints) they take precedence over relative positions specified by @ho/@vo/@to (or @startho/@startvo/@startto). Analogously, @x2/@y2 override @endho@endvo/@endto.

If @to/@startto/@endto attributes are used, the start or end point is x-aligned with the indicated timestamp.

If relative start coordinates (@ho/@vo or @startho/@startvo) are used, the origin of the coordinate system to be used for the start point is the first one found by the following search schema:

  1. If @startid is present, the origin of the referenced element;
  2. If the element is inside running text (e.g. inside tempo), the end of the preceding text or element;
  3. Otherwise, the origin of the containing element.

The start point is offset from this origin by the value of the start coordinates (@ho/@vo or @startho/@startvo), using staff units.

Analogously, the endpoint is determined using end coordinates (@endho/@endvo). If @endid is specified, it takes precedence over @startid.

Examples of origins are:

  • staff and layer: The horizontal origin is the starting point of the measure, the vertical one is the bottom staff line;
  • note: The horizontal origin is the left end of the notehead, the vertical one the center of the notehead;
  • clef: The horizontal origin is the left end of the clef, the vertical one the line specified by clef/@line (or @clef.line);
  • For elements containing text: The left end of the baseline;
  • symbolDef: As symbol definitions aren’t rendered directly, their coordinate system and origin are considered virtual. When they are referenced by symbol or @altsym, the origin of the context, i.e. the referencing symbol, is used.

If neither absolute nor relative coordinates are specified, determining visually suitable start and end points for @line and @curve attributes is left to the rendering application. A value of 0 is not always assumed for absent relative coordinates. A typical example where a rendering application may not choose the origins of absent relative start and end coordinates to be the start point as well is the line connecting two notes in the above Schumann example.

22.3.4. Curve Shape

If neither a @bezier nor @bulge attribute is present, the renderer determines a suitable shape. However, if @curvedir is present, the curve must respect the curvature direction specified there.

The attributes @bezier and @bulge define the shape of a curve in two different ways. If both are present, a rendering application may choose either one. They override @curvedir.

@bezier defines the inner control points of a cubic Bézier curve, i.e., a Bézier curve with two inner control points. The coordinates are given by a space separated list, first x and y offsets for the first control point, then x and y offsets for the second one. The x and y offsets are given in staff units (or inside the context of symbolDef in abstract units). The offsets for the first inner control point are relative to the start point, the ones for the second inner control point are relative to the end point.

The @bulge attribute allows specification of the curve shape by a number of interpolation points. The interpolation points are given by their distance from the line connecting the start and end point. The distance values are stored as a space separated list.

The interpolation points are calculated as follows: If @bulge provides n distance values, the connection line is divided into n+1 subsegments of equal length. The interpolation points are found by drawing a perpendicular line of the respective length at each subsegment joint. Positive distance values are drawn to the left of the connection line (left when traveling from start to end), negative ones to the right.

musical example
Rendering a bulge attribute with value "-2 1"

The interpolation algorithm used by the rendering application is implementation dependent.

22.4. Line Rendition

The @form attribute of lines may take the following values:

  • dashed
  • dotted
  • solid
  • wavy

These attribute values are only qualitative. Actual dash length and dot and dash spacing are implementation dependent.

The @width attribute may take the following values:

  • narrow
  • medium
  • wide

These values are also qualitative, however, they are also relative. That is, ‘narrow’ is the default value, ‘medium’ is twice as wide as ‘narrow’, and ‘wide’ is twice as wide as ‘medium’.

In addition to these textual values, the width attribute may contain a numeric value and an optional unit value, “2mm” for example. If the unit value is not provided, staff interline units are presumed.

The @lstartsym and @lendsym attributes name the symbol that may start and/or end a line, while @lstartsymsize and @lendsymsize indicate the relative size of the symbol using a numeric value in the range from 1 to 9.

22.5. Limitations

The usersymbols module does not currently support continuous composite lines or filled areas. As mentioned above, the rendition of lines is highly implementation dependent. Coordinate system transforms are restricted to scaling using @scale.