Music Level 3

After learning the basic and intermediate elements and attributes in levels 1 and 2, you are well positioned to move ahead to some more advanced features of MEI, such as various types of articulation, ornamentation, cross-staff beaming and dynamics. You will also learn about the encoding of tuplets and XML identifiers.

Let's start by encoding the tuplets at the beginning of Schubert's "Erlkönig":


1) Tuplets

There's a flurry of details to encode here! To simplify matters, we’ll take it one step at a time. First, let’s concentrate on the tuplets.


You’ll have to decide whether you want to encode the tuplet as an element or as an attribute. In this encoding, we’ve chosen to use the <tuplet> element, which is wrapped around the notes of the tuplet. MEI offers several attributes for describing the details of the tuplet, among them: @bracket.visible, @num, @num.visible and For a list of other possible attributes, take a look at chapter 4.2.4 of the Guidelines .

Click the button below to see the encoding. Note that this is only one of several possible solutions.

2) Chords

MEI defines a chord as the "simultaneous sounding of two or more notes in the same layer with the same duration." Using this definition, the dyads in the right-hand of the piano are chords. The next step is to wrap a <chord> element around each simultaneous group of notes.


Once again, the given result illustrates only one of several possible solutions.

3) Using @copyof

As you’ve probably noticed, an encoding can be quite verbose when there's a lot of repetition of content. When encoding the XML directly using a QWERTY keyboard, this verbosity can lead to encoding errors. It would be helpful to be able to encode something correctly once and simply copy the encoded feature wherever it's needed. This can be accomplished through use of the @copyof attribute.

Using the @copyof attribute, however, requires the use of another attribute, @xml:id. Placing this attribute on an element gives it a name by which it can be referred to later. Each @xml:id attribute must have a value that is unique within the current document. This allows you to unambiguously refer to the element bearing this value elsewhere in your document. The value of an @xml:id attribute must also be an XML name. An XML name must follow some basic rules:

  • contain letters, numbers, and other characters, except spaces and colons
  • cannot start with a number or punctuation character
  • cannot start with the letters "xml" (or XML, or Xml, etc.)

In the current example, copying the tuplet will shorten your file and reduce the need for duplicate, and error-prone, encoding. First, you need to give the first tuplet an @xml:id attribute. Any tuplets that are exact copies of the first one can then be represented by an empty <tuplet> element whose @copyof attribute contains the name you gave to the first tuplet. Don't confuse the @copyof attribute with the @sameas attribute. For more information on relationships between elements, please have a look at chapter 7.1 of the Guidelines .

4) Instrument/Voice labels

Let's return to the beginning of the song and go on to the next feature. You've already learned to encode score definitions (<scoreDef>) and staff definitions (<staffDef>). Now we’ll talk about encoding the names of instruments and voices. You can use the attribute @label to encode information about instrumentation that appears at the beginning of the song. @label may occur as an attribute of the element <staffDef>. It can also appear on <staffGrp>, when an instrument, like the piano, is written on multiple staves.

5) Tempo instructions

Above the first staff, you find the following tempo instruction:


You can encode this using the <tempo> element. <tempo> elements should be placed inside the <measure>, following the encoding of the staff content. Details of the placement of the tempo marking may be captured using @tstamp, @staff and @place attributes. The quarter note symbol that occurs within the tempo marking can be represented by the Unicode character reference ♩. Note that the reference begins with an ampersand and ends with a semi-colon.

6) Dynamics


In the next step, you will learn how to encode some dynamic symbols, such as the one at the beginning of "Erlkönig". Dynamics are encoded using the <dynam> element. Like the <tempo> element, <dynam> should be placed within the measure, following the <staff> elements. Since each one makes reference to its related staff, the order in which the <dynam> and <tempo> elements occur is not important.

7) Note/chord repetition

Congratulations! You've encoded the first measure of the "Erlkönig."

Are you ready for the second measure?

In the next measure of the "Erlkönig", the tuplets in the right hand of the piano are replaced by shorthand notation that indicates repetition of a chord, called "bowed tremolo" in MEI.


MEI provides the <bTrem> element for this kind of repetition. Check chapter of the Guidelines for information about its use.

8) Complete measure

You got to know many new elements and attributes, so now you are able to encode a complete measure of the "Erlkönig", for example the second one!


There are additional features in this measure that didn't occur in the first one. Try to discover how to handle them, and then check your work against the example below.

You’re free to choose either elements or attributes for encoding this snippet, but be sure to use them consistently. Encoding the slur, for example, requires you to decide between markup using @tstamp and @tstamp2 attributes or using @startid and @endid attributes. You learned about the first option in the intermediate tutorial, and you know how to work with the XML IDs used in by the second option from the section on @copyof above.