MStruct Syntax Overview

Full technical note: https://doi.org/10.5281/zenodo.23637500

An MStruct file mainly consists of three sections:

  • Metadata (METADATA:)

  • Analysis (MAIN:)

  • Comments (COMMENT:)

The editor provides dedicated interfaces for metadata and comments. Their syntax is straightforward, so these pages focus on the event syntax of the analysis section.

The analysis section is the code you edit in the pane on the right side of the editor.

Unless otherwise stated, this page and its subpages describe the syntax of the MStruct analysis section.

Basic syntax and settings

The analysis section consists of a series of events.

A comma (,) separates event positions, while a semicolon (;) separates measures. Both are ASCII characters.

As long as individual tokens remain complete, you can insert line breaks between them and arrange the code as you prefer.

Consider the following example:

Source:

{BN:1}{TS:4/4}{BPM:1/4=120}{TC:c}
{1/4}
Cm|i,Fm|iv,G|V,Cm|i;
Ab|bVI,Fm|iv,G|V,C|I;

Rendered result:

The following entries explain each of the events and settings in this example.


TL;DR:

These web docs are mostly the DOI edition, split into smaller sections. They cover the details, but they can get a bit long. To help you get going, I've added a TL;DR at the start of each syntax page.


Every MStruct event sits in a slot. Slots are separated by a comma (,), and one slot can hold several events.

Each slot has a duration, set with {D:} or a fraction directly inside braces, such as {1/16}.

Measures are separated by semicolons (;). Once the slot durations add up to a full measure, close it with a semicolon.

An empty slot adds its duration to the previous slot.

For example, in 4/4 time, these two MStruct snippets are equivalent: {1/4}C|I,,,; and {1}C|I;


In the first slot, set the measure number ({BN:1}) and time signature ({TS:4/4}).

The measure number must be a nonnegative integer, usually 1. A number above 1 means this analysis is an excerpt. Feel free to share excerpts privately, though this site generally doesn't accept incomplete analyses as submissions.

You can also use measure number 0 for a pickup measure. Its slot durations must add up to less than the current time signature.


You can then set a tempo ({BPM:1/4=120}) and tonal center ({TC:c}) in the first slot. These settings stay in effect until you change them.

For MStruct to play a preview at a specified tempo, BPM settings must cover the whole piece. Then enable "Stable tempo" in the analysis metadata editor.

To use Roman numeral analysis, the slot must fall within a region with a {TC:} setting, and that setting must not be {TC:None}.

  • Tempo syntax: {BPM:note value=beats per minute}

    • You can also use {BPMhidden:} with the same syntax. It changes the preview tempo without printing a tempo mark on the score.

    • For classical music with rubato or different interpretations, or other music with frequent, irregular tempo changes in performance, you can skip BPM marks and use a timeline instead. See the timeline page.

    • {TEMPO:} just reproduces the original tempo marking in a classical work and helps you identify its formal sections. For example, {TEMPO:Allegro} simply prints "Allegro"; it doesn't set a playback tempo.

  • Tonal-center syntax: {TC:tonal center}

    • Use uppercase for major and lowercase for minor. Accidentals go after the note name: b for flat and # for sharp.

    • Put the center in quotation marks if it's just an anchor for Roman numeral analysis, rather than a definite tonal center. For example, some modal jazz moves back and forth between IV7 and iii7 throughout. That doesn't make the corresponding I the tonal center, but you can still use a scale built on I as a reference for the Roman numerals.

    • Set the tonal center to None for passages with no tonal center. Roman numerals aren't allowed in those passages.


Finally, a slot's musical event can be a chord symbol or one of the events covered in More Events: X (placeholder), 0 (rest), - (continuation), N.C. (no chord), Clus (cluster), ClusBK (black-key cluster), or ClusWK (white-key cluster). The three cluster symbols can also fill a complete chord field and be paired with a Roman numeral.

The other events have their own page, so here's just a quick look at chord-symbol syntax.

The full form of a harmonic event is [C:chord symbol|R:Roman numeral]. You can shorten it to chord symbol|Roman numeral, as in Cm|i,Fm|iv,G|V,Cm|i;.

You can leave either the chord-symbol side or the Roman-numeral side empty when needed. For example, Cm| and |i are both valid, but you can't leave both sides empty.

Chord symbols and Roman numerals each follow their own rules. Follow the links for the details.


That's the basic MStruct syntax. You should now have enough to write your first MStruct file. If you'd like the full definitions, keep reading.



BN: bar number

Syntax / fields:

{BN:n}

BN stands for Bar Number.

BN must be defined before the first event.

BN takes a nonnegative decimal integer and sets the current source measure number.

Subsequent ordinary measures advance the number automatically.

A later BN setting belongs at a measure boundary.

BN 0 denotes a pickup measure.

On its initial traversal, the pickup must accumulate strictly less duration than the numeric TS.

Examples

{BN:0}{TS:4/4}{D:1/4}{TC:C}G|V;
{D:1}C|I;

A starting measure number greater than 1 is useful for an excerpt. For contributions to the archive, a complete analysis is preferable where possible.

TS: time signature

Syntax / fields:

{TS:p/q} / {TS:adlib}

TS stands for Time Signature.

TS must be defined at the beginning, including for BN 0.

The numerator and denominator accept any positive integers.

An ordinary metered measure must total exactly p/q whole notes.

TS changes belong at measure boundaries.

The exact lowercase value adlib allows measures of variable total duration.

An adlib pickup also follows this variable-duration rule.

D remains mandatory and determines each slot duration in an adlib passage.

Examples

{BN:1}{TS:3/4}{D:1/4}{TC:C}C|I,F|IV,G|V;
{BN:1}{TS:adlib}{D:1/4}{TC:C}C|I,G|V;

Tempo and recording alignment

BPM: metronome setting

Syntax / fields:

{BPM:p/q=v}

BPM stands for Beats Per Minute.

The beat unit p/q is a positive rational duration measured in whole notes.

v is a finite positive decimal number giving the number of beats per minute.

For example, 1/4=120 means 120 quarter notes per minute.

The tempo setting persists until a later tempo change.

A BPM setting applies to its entire slot and can be written before or after the harmonic event in that slot.

A slot lasting d whole notes takes 60000*d/((p/q)*v) milliseconds.

The stable-tempo option ({IS_STABLE_TEMPO}True in metadata) calculates playback time from slot durations and numeric tempo settings.

Each event slot included in this playback must therefore have a defined numeric tempo.

Examples

{BN:1}{TS:4/4}{D:1/2}{TC:C}{BPM:1/4=120}C|I,{BPM:1/4=90}G|V;

BPMhidden: hidden metronome setting

Syntax / fields:

{BPMhidden:p/q=v}

BPMhidden sets the playback tempo using the same numeric syntax as BPM.

The score displays a metronome label for BPM and hides it for BPMhidden.

Both settings change the current playback tempo.

Settings within one slot apply from left to right.

The final value drives playback, while an earlier BPM label can remain visible.

Examples

{BN:1}{TS:4/4}{D:1}{TC:C}{BPM:1/4=120}{BPMhidden:1/4=119.5}C|I;

The example above plays at 119.5 quarter notes per minute in preview, while the visible label remains 120.

Stable tempo and recording alignment

For music with constant numeric tempo or tempo changes that can be described explicitly, enable stable tempo in the metadata. Small performance fluctuations can be recorded with BPMhidden without repeatedly displaying tempo marks. MStructTime timelines provide another way to align the analysis with a particular recording.

Read more: Timeline

TEMPO: verbal tempo marking

Syntax / fields:

{TEMPO:text}

TEMPO attaches a nonempty text marking above the BPM row.

A marking such as Allegro supplies the verbal indication.

A stable-tempo file requires a separate numeric BPM or BPMhidden setting.

Examples

{BN:1}{TS:4/4}{D:1}{TC:C}{TEMPO:Allegro}{BPM:1/4=120}C|I;

TC: tonal reference

Syntax / fields:

{TC:C} / {TC:c} / {TC:"C"} / {TC:None}

TC stands for Tonal Center.

An ordinary TC uses A-G for major or a-g for minor.

The note letter can be followed by a single b or #.

Matched ASCII double quotes mark an ambiguous center or a center used only as a reference.

The quoted center retains its major or minor mode for Roman interpretation.

The reference is initially undefined.

Once established, it persists across subsequent events until a setting changes it.

A later TC changes the reference from that event boundary onward.

The exact value None explicitly clears the reference.

Roman fields can resume after a valid tonal reference has been established again.

The modulation entries in More Events explain their reference requirements.

A slot using a Roman field must have a defined tonal reference other than None.

Examples

{BN:1}{TS:4/4}{D:1/2}{TC:"C"}FM7|IV7,Em7|iii7;
{TC:None}C|,G|;

The ambiguous reference {TC:"C"} allows FM7–Em7 to be analysed as IV7–iii7. A DTC tag names the two tonalities of a double-tonic complex; TC separately supplies the reference for the current Roman layer.

Source

Rendered result

FM7 Em7

FM7 Em7

IV7 iii7

IV7 iii7

In note names, accidentals follow the letter; in scale degrees, they precede the degree.

Tonality and mode tags

D: slot duration

Syntax / fields:

{D:p/q} / {p/q} / {n}

D stands for Division.

D expresses slot duration as a positive integer or positive fraction of a whole note.

{1/4} abbreviates {D:1/4}.

{1} gives a duration of one whole note.

D must be defined before the first slot.

Its value persists across commas and ordinary barlines.

A later D changes the current and following slots.

For example, D 1/8 gives each slot an eighth-note duration under any TS.

Examples

{BN:1}{TS:4/4}{D:1/2}{TC:C}C|I,{1/4}F|IV,G|V;

Comma, semicolon and empty slots

Syntax / fields:

, / ;

A comma closes the current slot using its D.

A semicolon closes the current slot and the measure.

Newlines act as whitespace between tokens.

An ordinary final measure also requires a semicolon.

The last measure may place {||END} before its semicolon to display a final barline. Only whitespace may follow that semicolon in MAIN.

An empty comma-separated slot continues the preceding event for another D.

Separators inside a matched field list divide the items in that field.

A comma immediately before a semicolon creates an additional slot.

Examples

{BN:1}{TS:4/4}{D:1/4}{TC:C}C|I,,,;

Harmonic event fields

Syntax / fields:

[C:chord|R:roman] / chord|roman / chord| / |roman

The explicit form contains a C field, an R field, or both.

Each included field requires a nonempty value.

Every shorthand event requires a vertical bar.

C| supplies only the chord field, while |I supplies only the Roman field.

[C:C] and [R:I] are valid explicit forms for those single fields.

Roman requires a tonal reference.

When both fields are present, each gives an independently interpreted analysis of the same position.

Examples

{BN:1}{TS:4/4}{D:1/4}{TC:C}[C:C|R:I],F|IV,[C:G],[R:I];

These basic events and settings are enough to begin writing an MStruct analysis. Continue with the following pages for additional events and detailed rules for the two harmonic fields:

More Events · Chord Symbols · Roman Numerals