Music Level 2

Music Level 2

For the next example we'll use the opening section of the famous chorale "Ein' feste Burg ist unser Gott", composed by Johann Sebastian Bach.


1) Score Definition (scoreDef)

Start your encoding with the creation of a score definition (<scoreDef>). As you've learned in the previous exercise, you need to encode a <scoreDef> element with its sub-elements and appropriate attributes within the <score> element. You might also want to indicate that the two staves are grouped by a brace. To do this, add a staff group (<staffGrp> element) as a child element to your score definition (<scoreDef>) and use the @symbol attribute with the value "brace" to encode this information. You can now insert two separate staff definitions (<staffDef> elements) into the staff group (<staffGrp>). Each <staffDef> should include specific staff information such as information on the shape (@clef.shape) and location (@clef.line) of its clef. Clef shapes are encoded using capital letters. The value of the attribute @clef.line should contain the number of the line where the clef is located, with the lines being counted from bottom to top. A traditional treble clef, then, should be encoded with the values @clef.shape="G" and @clef.line="2".


To see the result, click the button below. But before checking the answer, try it yourself!

2) Staff and layer

After encoding the score definition (<scoreDef>), you can start to encode the first staff. Please ignore the upbeat for a moment (we will encode it a few steps later), and concentrate on just the first measure. As you can see in the image below, the first staff contains two individual streams of musical events, requiring the encoding of two layers here. Start the encoding of the first measure by putting two <layer> elements within the <staff> element. As it is the first staff of the chorale, remember to encode the number using the @n attribute. While the <layer> element is used to encode multiple "voices" within a single staff this element is always required to complete the structure, even if there is only one voice to encode.


3) Note

Next, add each of the notes with their respective durations, pitch names and octaves. If desired, add the @stem.dir attribute, which indicates the direction of the stems. This might be helpful in distinguishing among the different layers.

4) Individual lyric syllables (syl) and lyric verses (verse)

In level 1 you learned an easy way to encode text with the @syl attribute. In addition to this, MEI also offers a <syl> element for the encoding of individual lyric syllables. This can be useful if, for instance, you want to provide additional details for the lyric syllables. The <syl> element has to be encoded as a child element of the <note> element.

If there are several lyric verses to encode, MEI also provides a <verse> element, which must also be encoded as a child element of the <note> element. It should be wrapped around the <syl> element. You can number the verses, if you like, using the @n attribute on <verse>.

The first section of the chorale has two verses, so you'll want to add <verse> and <syl> child elements to the relevant <note> elements.

The word "feste" contains a dash that acts as a syllable separator and "Burg" has a syllable extension. To encode these, you could add the appropriate @con attribute onto the <syl> element, choosing from the following list: s (space) = word separator, d (dash) = syllable separator, u (underscore) = syllable extension, t (tilde) = syllable elision. You can also define whether a syllable marks the beginning, middle or end of a word by using the @wordpos attribute. Approved values include "i" (initial), "m" (medial) or "t" (terminal).


5) Upbeat

As you can see from the image below, you now need to encode an upbeat by adding the @metcon attribute to the measure element. This attribute indicates the relationship between the content of a staff or layer and the prevailing meter. A value of "true" for the @metcon attribute indicates conformance with the prevailing meter (i.e., a complete measure) while "false" means the opposite, an incomplete measure. Please encode the complete upbeat, using the appropriate @metcon attribute.


6) Adding a new staff

Next, add the second staff in the same way that you’ve encoded the first one. There are no lyrics to encode here.

7) Adding a complete new measure

Now that you know how to encode complete measures, add the second measure on your own. Encode the second verse of text and add the update to the second verse, which is still missing, to your encoding. Don’t worry about the two fermatas just yet.


8) Fermata

Now we’re ready to deal with the fermatas by adding the @fermata attribute to the relevant <note> elements. Values for specifying its location include: "above", "below" or "within" the staff. Choose the appropriate value from the list to encode each fermata.


9) Encoding of measure 3 and 4 including fermatas

Now you can encode the last two measures (measures 3 and 4) of the first section of the chorale:


We’ll deal with the slurs, ties and the repetition in later steps, but do encode the two fermatas at the end of measure 4.

10) Slur

The most common approach for encoding slurs is to use a combination of the @tstamp (timestamp) attribute and the @tstamp2 attribute. Note that slurs are encoded at the end of a measure, following notes, chords, and rests. The @tstamp attribute is used to encode the onset time in terms of musical time, i.e. beats. Since our chorale is in four-four time, the main timestamps of the measure are tstamp="1", tstamp="2", tstamp="3" and tstamp="4". As an example, we’ll look at the slur in the second layer of the first staff, which begins on tstamp="1" and it ends on tstamp="2.5". The duration of a feature is encoded as a timestamp giving its endpoint, using the @tstamp2 attribute. In our example, you would enter a @tstamp2 attribute with the value "0m+2.5" (m stands for measure). You may choose to indicate the curve direction of the slurs ("above" or "below") and you can also specify the staff and the layer where they occur.

11) Repetition

Finally, you can encode the repetition on the last measure, using the @right attribute with the appropriate value from the following list: "dashed", "dotted", "dbl", "rptstart", "rptboth", "rptend". Please add a @right attribute to the <measure> element of measure 4 and insert the value "rptend".

12) Result

The encoding of the first section of the chorale is now complete. Well done! Please click the button below to see the entire encoding.

music notation