14Integrating MEI with other Standards and Formats

In this chapter, the combination of MEI with other relevant formats in the field is covered. Here, the MEI Guidelines try to serve as Best Practice Recommendations; they don't claim to provide full and / or authoritative documentation for those other formats. The intention is to provide good starting points and share experience across various projects, trying to unify both tools and workflows for better efficiency. Accordingly, if the information found here provides as outdated or incomplete, please get in touch.

14.1TEI

The TEI’s Special Interest Group on Music has come up with an ODD customization for TEI, which allows to embed MEI excerpts into TEI. However, the SIG Music is officially considered dormant, so the information provided is somewhat outdated. The most recent resources are available from GitHub.

As of yet, no official MEI customization to include elements from the TEI namespace into MEI has been written, even though this is definitely wanted.

14.2IIIF

This chapter will explain how to use MEI in an IIIF-compatible way.

14.3SMuFL

This section describes how to use MEI with the Standard Music Font Layout (SMuFL, https://www.smufl.org/) specification.

14.4SVG

In order to use Scalable Vector Graphics (SVG) in MEI, a new module needs to be compiled into ODD (see 1.3.5 Customizing MEI for an introduction on how to do that). In order to do that, you need to enter the following tei:moduleRef into the tei:schemaSpec of your ODD file:

<moduleRef url="http://www.w3.org/Graphics/SVG/1.1/rng/svg11.rng">
<content>
<rng:define name="mei_model.graphicLike" combine="choice"> <rng:ref name="svg"></rng:ref> </rng:define>
</content>
</moduleRef>
Listing 442.

With this addition, which can be added to any of the provided customizations of MEI (see 1.3.4 MEI Profiles), the <svg> element becomes available everywhere `model.graphicLike` (i.e., the graphic element) is currently allowed, that is: inside of fig, incip, surface, and zone.

In the following example, an <svg:path> element is inserted into a surface. It would now be possible for measures or other music features to point to the rectangular zone in MEI namespace, or the fancy shaped <svg:path> using their facs attribute (see 12.1.1 Elements of the Facsimile Module for that mechanism). It’s equally possible to use SVG content inside figures on title pages or anywhere else.

<surface lrx="3000" lry="2000" ulx="0" uly="0"> <graphic target="image1.jpg" width="3000px" height="2000px"></graphic>
<svg:svg version="1.1" width="3000px" height="2000px" viewBox="0 0 3000 2000">
<svg:path id="fancyShape" fill="#ff0000" d="…"/>
</svg:svg>
<zone xml:id="rectangle" lrx="370" lry="410" ulx="300" uly="200"/>
</surface>
Listing 443.

Of course it’s possible to allow elements in SVG namespace in other places in MEI as well, by adjusting the model classes that the SVG namespace shall join.

14.5Musical Instrument Digital Interface (MIDI)

This chapter describes the MIDI encoding functionality present in MEI. The purpose of this module is to allow for integrating MIDI data into MEI-encoded notation, to both aid software in translating MEI to MIDI, and to permit the capture of information in files that have been translated from MIDI to MEI. The MIDI model in MEI is similar to that of Mup, and the user is directed to the Mup User Guide for further reading.

The MIDI module defines certain generally-accepted MIDI units that may be used outside of a MIDI context. For example, the dur.ppq attribute accepts MIDI ppq (Pulses Per Quarter) as a valid measurement of duration. Similarly, the pnum attribute allows MIDI note numbers for specifying a pitch value.

14.5.1PPQ in scoreDef and staffDef

To define the MIDI resolution of a score, the ppq attribute may be used on the scoreDef element. This value can be used to interpret the values found in the dur.ppq attribute on elements in the att.duration.ges class.

<scoreDef keysig="1f" meter.count="4" meter.sym="common" meter.unit="4" ppq="48">
<staffGrp>
<staffDef clef.line="2" clef.shape="G" keysig="1f" lines="5" n="1" xml:id="midi.P1"/>
<staffDef clef.line="4" clef.shape="F" keysig="1f" lines="5" n="2" xml:id="midi.P2"/>
<staffDef clef.line="4" clef.shape="F" keysig="1f" lines="5" n="3" xml:id="midi.P3"/>
</staffGrp>
</scoreDef>
<!-- snip -->
<note dur="8" dur.ges="24p" oct="5" pname="a" stem.dir="up" xml:id="midi.d1e40"/>
<!-- 8th note -->
<rest dur="32" dur.ges="6p" vo="4" xml:id="midi.d1e58"/>
<!-- 32nd note -->
<!-- snip -->
Listing 444.

The ppq attribute is also available on the staffDef element in order to aid in the conversion to MEI from other representations that allow a different time base for each staff. However, these independent values for ppq are only interpretable in terms of a common time base. Therefore, the ppq attribute is required on scoreDef when the values of ppq on the staff definitions differ. In the following example, the values of the ppq attributes on the staffDef elements are all factors of the value of ppq attached to scoreDef.

<scoreDef keysig="1f" meter.count="4" meter.sym="common" meter.unit="4" ppq="48">
<staffGrp>
<staffDef clef.line="2" clef.shape="G" keysig="1f" lines="5" n="1" ppq="2" xml:id="midi.P1"/>
<staffDef clef.line="4" clef.shape="F" keysig="1f" lines="5" n="2" ppq="16" xml:id="midi.P2"/>
<staffDef clef.line="4" clef.shape="F" keysig="1f" lines="5" n="3" ppq="24" xml:id="midi.P3"/>
</staffGrp>
</scoreDef>
Listing 445.

14.5.2Recording General MIDI Instrumentation

The instrDef element can be used to record MIDI instrument names or numbers using the midi.instrname and midi.instrnum attributes. The midi.instrname attribute must contain an instrument name from the list provided by the data.MIDINAMES data type. By default, data.MIDINAMES contains General MIDI Instrument designations.

<scoreDef keysig="1f" meter.count="4" meter.sym="common" meter.unit="4" ppq="48">
<staffGrp>
<staffDef clef.line="2" clef.shape="G" lines="5" n="1" xml:id="midi.P5">
<instrDef midi.instrname="Violin"/>
</staffDef>
<staffDef clef.line="2" clef.shape="G" lines="5" n="2" xml:id="midi.P6">
<instrDef midi.instrname="Violin"/>
</staffDef>
<staffDef clef.line="3" clef.shape="C" lines="5" n="3" xml:id="midi.P7">
<instrDef midi.instrname="Viola"/>
</staffDef>
<staffDef clef.line="4" clef.shape="F" lines="5" n="3" xml:id="midi.P8">
<instrDef midi.instrname="Cello"/>
</staffDef>
</staffGrp>
</scoreDef>
Listing 446.

The midi.instrnum is provided for those cases when an instrument number is needed. It must contain valid MIDI values; that is, 0-127. In these cases, a General MIDI Instrument name is redundant.

<scoreDef keysig="1f" meter.count="4" meter.sym="common" meter.unit="4" ppq="48">
<staffGrp>
<staffDef clef.line="2" clef.shape="G" lines="5" n="1" xml:id="midi.P5">
<instrDef midi.instrnum="41"/>
</staffDef>
<staffDef clef.line="2" clef.shape="G" lines="5" n="2" xml:id="midi.P6">
<instrDef midi.instrnum="41"/>
</staffDef>
<staffDef clef.line="3" clef.shape="C" lines="5" n="3" xml:id="midi.P7">
<instrDef midi.instrnum="42"/>
</staffDef>
<staffDef clef.line="4" clef.shape="F" lines="5" n="3" xml:id="midi.P8">
<instrDef midi.instrnum="43"/>
</staffDef>
</staffGrp>
</scoreDef>
Listing 447.

14.5.3Recording MIDI Event Data

MIDI messages are encapsulated in the midi element, which is typically used in contexts like layer and measure. In earlier versions of MEI, the noteOn and noteOff elements were used to record MIDI note on/off events. The use of these elements is now discouraged in favor of using the note element directly. MIDI duration should be recorded using the dur.ges attribute, and MIDI pitch information should be recorded using the pnum attribute.

MIDI control changes (cc) are encoded using the num and val attributes. Control change numbers are specified in the General MIDI documentation. In the example below, the cc elements encode increasing controller event 7 (volume) values, or in musical terms, a crescendo. Other MIDI event messages follow this same pattern, using the num and val attributes to record the raw MIDI data.

<measure>
<staff>
<layer>
<note dur.ges="8" pnum="45"/>
<note dur.ges="8" pnum="42"/>
<note dur.ges="8" pnum="43"/>
<note dur.ges="8" pnum="44"/>
</layer>
</staff>
<midi layer="1" staff="1">
<cc num="7" tstamp=".5" val="50"/>
<cc num="7" tstamp="1.5" val="55"/>
<cc num="7" tstamp="2" val="60"/>
<cc num="7" tstamp="2.5" val="65"/>
</midi>
</measure>
Listing 448.

In the preceding example, each control change is associated with a time stamp. The tstamp attribute is required in order to indicate when the MIDI event should take place. It is often necessary to indicate a time stamp slightly earlier than the affected notes to compensate for MIDI delay.

For better legibility and error checking, the midi element may be used, as in the following example, to group MIDI parameter changes. Even so, the tstamp attribute is required on all parameters in order to associate them with their point of actuation:

<midi layer="1" staff="1">
<cc num="7" tstamp=".5" val="50"/>
<cc num="64" tstamp=".5" val="64"/>
</midi>
Listing 449.

14.5.4MIDI in Mensural and Neume Notation

In mensural, neume, and other historical or non-Western repertoires, there is often no measure-based time stamp with which to associate MIDI controller data. Therefore, in these notations MIDI controller data is assumed to be associated with the event that immediately follows in the same layer. Thus, a crescendo in mensural notation may be encoded like so:

<staff>
<layer>
<midi>
<cc num="7" val="50"/>
</midi>
<note dur="fusa" dur.ges="8p" pnum="42"/>
<midi>
<cc num="7" val="55"/>
</midi>
<note dur="fusa" dur.ges="8p" pnum="43"/>
<midi>
<cc num="7" val="60"/>
</midi>
<note dur="fusa" dur.ges="8p" pnum="44"/>
<midi>
<cc num="7" val="65"/>
</midi>
<note dur="fusa" dur.ges="8p" pnum="45"/>
</layer>
</staff>
Listing 450.