ModalJazz

The compact score text

mj read shows the music in this form, and mj write writes it. The MCP tools read_measures and write_measures use the same text. The text_format tool gives this page to an agent.

The compact score text is a short, exact text form of the music. An agent, a script, or a test can read it and write it. The mj tool uses it in mj read and mj write.

m1: time=3/4 tempo="Andante",q=72
m1 P1.1: !clef=treble !key=Eb !p ( Bb4:q C5:8 D5:8 Eb5:q )
m1 P1.2: !clef=bass !key=Eb (ped Eb3+G3+Bb3:h. )ped
m2 P1.1: 3[ G5:8 F5:8 Eb5:8 ] D5:h{ferm}
m2 P1.2: Eb3:h. v2 s:q G2:h

Lines

The text has one line for each measure and staff. Each line starts with a measure and a staff, then a colon, then tokens with spaces between them.

  • m5 is the measure. Measures count from 1, in time order, as in a :5-8 range. A pickup measure is m1.
  • P1 is the staff of a part with one staff. Parts count from 1, from the top of the page. P1.2 is staff 2 of part 1 (for example the left hand of a piano). mj info shows the parts. The same labels can come before a : command, for a command on that part or staff: :P5 instrument brace off.
  • A measure line (m5: ...) has no staff. It holds the settings that are the same for all staves: the time signature, the barlines, the breaks, and so on. A measure with default settings has no measure line.
  • An empty line, or a line that starts with %, is a comment.

The lines go in time order. For each measure, the measure line comes first, and then the staves from top to bottom.

Events

Each event is one token: the notes (or a rest), a colon, and the duration.

Token Meaning
C4:q a quarter-note C4 (middle C)
F#3:8. a dotted eighth-note F-sharp 3
Bb2:h a half-note B-flat 2
Fx5:16 a 16th-note F double sharp 5 (Ebb4 is a double flat)
C4+E4+G4:h. a chord, notes from low to high
C4:q~ a note tied to the next note of the voice
C4~+G4:q a chord where only C4 has a tie
r:8 an eighth rest
s:h a half-note space: it takes time, and shows nothing
R a whole-measure rest (R:h gives it a written half note)

Pitches are concert pitches, also for a transposing part. The octave number is that of scientific pitch notation: middle C is C4.

The durations are M (maxima), L (longa), B (breve), w, h, q, 8, 16, 32, 64, 128, and 256. Each . adds a dot.

The events of a voice must fill the measure exactly. A measure rest R must be the only event of its voice.

Event settings

Settings go in braces after the duration (and after the tie): C4:q{stacc,acc}.

Setting Meaning
stacc, ten, acc, marc, ferm, caes, breath staccato, tenuto, accent, marcato (strong accent), fermata, caesura, breath mark
downbow, upbow a down-bow or an up-bow mark, above the staff; an event has at most one
stacc=above, ten=below, acc=above, marc=below, ... staccato, tenuto, accent, and marcato on one side; they share the side, so ten=below puts a staccato below too. Alone, they go on the notehead side, or on the stem side when another voice has music at the same time. A marcato puts them above, except when another voice has music at the same time
ferm=above, ferm=below a fermata on one side; ferm alone is above, but below on the lowest staff of a part with two or more staves (the left hand of a piano)
mord, imord, turn, iturn, dturn a mordent, an inverted mordent (a short trill), a turn, an inverted turn, and a delayed turn (after the note). The ornament goes above, or below in a lower voice
turn=#/b, mord=/#, imord=n the small accidentals of an ornament: the upper note's, a /, and the lower note's. Each is #, b, n, x, or bb, or empty
grace, grace=slash a grace event (no time); slash for an acciaccatura
cue a cue event: the notes or the rest draw small and do not play. Cue notes show the music of another part, usually in a voice of their own: v2 r:h E5:8{cue} D5:8{cue} r:q
stem=up, stem=down, stem=none the stem direction
beam=start, beam=join, beam=none, beam=inner2 a change from the default beams
staff=2 cross-staff: the event shows on staff 2 of the part
pos=4 the staff position of a rest
ly1=Twin-, ly2="la la"_ a lyric syllable of verse 1 or 2; - is a hyphen after it, _ an extender line
lv a laissez-vibrer (l.v.) tie on each note: a short tie to nothing, and the note rings on through the rests after it
trem=3, trem=z, trem2=3 a tremolo: trem=1 to trem=4 puts slashes through the stem, and the chord repeats in notes with that many more beams; trem=z is a buzz roll (a "z" on the stem); trem2=1 to trem2=4 puts beams between this chord and the next chord, and the two alternate. The two chords of trem2 each show the length of the two together, so C4:h{trem2=2} E4:h fills one half note
smufl=accdnRH3RanksClarinet a symbol above the notes, by its SMuFL glyph name, for example an accordion register. Give smufl= again for more symbols: they go in a row. A name that the music font (or Bravura) does not have draws nothing
ly1:above=Up- a lyric syllable above the staff, for example the upper voice's words when two voices share a staff; ly1:below is the same as ly1
ly1:italic=1, ly1:above:italic=Up an italic lyric syllable, for example a refrain or a second language; the hyphen and the extender stay the same

An unknown setting, or a value that a setting does not take (caes=below), gives an error.

Note settings

Settings for one note go in braces after its pitch: C#4{acc=paren}+E4:q.

Setting Meaning
acc=force, acc=courtesy, acc=paren, acc=hidden the accidental display
head=x, head=diamond, head=slash the notehead
paren the notehead (and its accidental) in parentheses: an optional note
fing=3, fing="1-2" a fingering
lv a laissez-vibrer (l.v.) tie on this note only: D5{lv}+F5:h
staff=1 cross-staff: this note shows on staff 1 of the part
spell=Db4 a spelling for the written (transposed) view

Voices and tuplets

  • A line starts in voice 1. v2, v3, and v4 start the next voice. Voices go in order, and each voice fills the measure.
  • 3[ C4:8 D4:8 E4:8 ] is a triplet: three eighths in the time of two. Other tuplets give the ratio: 5:4[ ... ], 2:3[ ... ]. Tuplets can be in tuplets.
  • Tuplet settings go in braces before the [: 3{show=ratio,bracket=yes}[. show is number, ratio, or none; bracket is auto, yes, or no; unit=8 gives the note value that the numbers count. side is above, below, or auto: the side of the number and the bracket. auto puts them on the stem side. On the other side they go outside the staff, with a bracket: 3{side=above}[ C5:8 D5:8 E5:8 ].

Marks at a time

These tokens start with !. A mark is at the time of the next event of the voice. @ gives another time in the measure: !mf@1/4 is a quarter note after the start of the measure. Times are fractions of a whole note.

Token Meaning
!clef=bass a clef: treble, bass, alto, tenor, or sign, line, and octave: G2-8, F4, C3, perc2
!key=Eb a key: Eb (major), C#m (minor), Dbm (8 flats), 3b, 0, none, "2#:dorian", "custom:F#,Bb4" (a value with : needs quotes)
!p, !mf, !sfz a dynamic: ppp to fff, sf, sfz, fp, rfz
!dyn=sfp any other dynamic text
!text="with pedal" staff text, in italics; :roman gives upright text: !text="Psalm 23:1":roman (:italic is the default)
!expr=dolce expression text (italic)
!chord=Cmaj7 a chord symbol (concert pitch)
!smufl=accdnRH3RanksClarinet a symbol by its SMuFL glyph name, above the staff and centered on the note

In measure 1, !clef= and !key= at time 0 are the start clef of the staff and the start key of the score (for all staves).

Keys are in concert pitch. A transposing part shows each key moved by its interval. When the moved key has six sharps or six flats, the part takes the side of its opening key, or flats when the opening key has none or six. A key past seven sharps or flats keeps the spelling of its name: on a B-flat clarinet, Dbm always shows E-flat minor.

A dynamic or an expression goes below the staff, and a text or a chord symbol goes above it. :above and :below change this. :between puts the mark between this staff and the next staff of the part (for piano); :between=3 puts it between this staff and staff 3 of the part.

Texts at one time and on one side of the staff make a stack. The order of their tokens is the order of the stack: the first token is the top line. !text=Heading !text=Labels puts "Heading" over "Labels", above or below the staff. A write in another order changes the stack, and a text with new words keeps its line. A dynamic or a chord symbol at the same time is not in the stack of the texts. In the app, :text up and :text down move a text of the stack at the cursor.

Marks over time

A mark over time, for example a slur, has a start token and an end token. A start token belongs to the next event of the voice, and an end token to the event before it.

m1 P1.1: !clef=treble !key=C ( C4:q D4:q E4:q ) (< F4:q
m2 P1.1: G4:h )< !f G4:h
Start End Meaning
( ) a slur; (:above or (:below puts it on that side of the notes, and (:auto (the same as () lets the layout choose
(phrase )phrase a phrase mark; :above, :below, and :auto set its side, as for a slur
(< / (> )< / )> a crescendo or diminuendo hairpin; (<:niente has a circle; (<:above puts it above the staff, on one line with the dynamics there (for vocal music with lyrics), and (<:below or (<:auto (the same as (<) puts it below
(ped )ped a sustain pedal mark; :line or :text changes the style; :open (\___) or :plain (a bare line) resumes a pedal line with no hook and no "Ped."; )ped:notch ends the line on a change notch, not a hook
(sost, (unacorda )sost, )unacorda the other pedals
(8va, (8vb, (15ma, (15mb )8va, ... an ottava line
(arp )arp an arpeggio; :up or :down adds an arrow
(tr )tr a trill line
(tie )tie a tie to another voice or staff
(gliss )gliss a glissando
(line="rit." )line a text with a dashed line; :below puts it below the staff; :roman gives upright text and :bold bold upright text: (line="rit.":bold (:italic is the default)
(bracket )bracket a solid line with a hook down at each end; :start keeps only the start hook, :end only the end hook (:nostart and :noend remove one hook); (bracket="Solo" has a text; :below puts it below the staff, with the hooks up
  • An end token closes the last open mark of the same kind in the same staff and voice. The end can be in a later measure.
  • A label pairs a start and an end in any place: (&1 and )&1. Use a label for a mark from one voice or staff to another.
  • @ with a time gives a mark at that time, not at an event: (<@1/8. @ with a pitch gives a mark on one note of the event: (gliss@E4.
  • ^ is a change point of the last open pedal mark on the staff. It can have a label (^&2) and a time (^@1/2, or ^@m5:1/4 for a time in another measure).
  • A bracket line covers the time of its events: the end hook comes just before the next event, or before the barline when the last event ends its measure. A bracket with one hook and no text is a short mark: its line is as long as the hook is tall. A hymn introduction has a start bracket over its first event and an end bracket over its last event: (bracket:start C5:q )bracket and (bracket:end G5:h )bracket.
  • A pedal mark with )ped:notch ends on a change notch at the time of the end token: the pedal is changed there, and the pedalling goes on with no more marks (for example after "sim."). Put the end at the time of the change, often the next downbeat: )ped:notch@0 before the first event of the next measure. In the :text style, the end is "*" and "Ped.".

Measure lines

Token Meaning
time=3/4 a time signature: 6/8, C, C|, 3+2+2/8, 2/4+3/8; :hidden, :single, :common, :cut set the symbol
length=1/4 a length that is not the time signature's (a pickup); add number=hidden so that the next measure is 1
number=hidden, number="12a", number=10 the measure number: hidden does not count; a whole number sets the count (the next measure is 11); other text does not count (after 12a comes 13)
bar=double the barline at the end: double, final, dashed, none
startbar=double the barline at the start
repeat-start, repeat-end, repeat-end=3 repeat barlines; =3 plays the section 3 times
volta=1, volta=1,2 a 1st (or 1st and 2nd) ending starts
volta-end=closed, volta-end=open the ending stops at the end of the measure
segno, coda, tocoda, fine navigation marks
dc, dc:fine, dc:coda, ds, ds:fine, ds:coda jumps: D.C., D.C. al Fine, and so on
tempo="Andante",q=72 a tempo mark: a text, a beat and a speed, a "note = note" mark, or some of them. The parts print in the order written: tempo=q=84,"(swing eighth notes)" prints "♩ = 84 (swing eighth notes)"
tempo="Swing",q=178,swing, tempo=straight, tempo=q=q. a tempo mark with a "note = note" mark. After a speed it goes in parentheses: "Swing ♩ = 178 (♫ = ♩³♪)". Before the speed it has none: tempo=swing,q=178 prints "♫ = ♩³♪ ♩ = 178". The mark is swing (two eighths = a triplet quarter and eighth; the eighths play swung), straight (two eighths = two eighths; ends the swing), or two note values (a metric modulation; only the mark changes). A right note value that is a number goes in parentheses: tempo=q=(8)
tempo=q=88-96, tempo=q=c.72 a speed range ("♩ = 88–96"), or a speed with "c." ("♩ = c. 72")
rehearsal=A a rehearsal mark
section, section="II." a new section, such as a movement, starts here: a new system with the full part names, measure numbers from 1, and the heading above it
break, pagebreak a system break or a page break after the measure, as :break and :pagebreak set it. The other system ends come from the layout: the MCP tool layout and mj info --layout show the measures of each system on each page

Navigation and tempo marks can have a time: tempo="a tempo"@1/2. Without a time, tocoda, fine and the jumps go at the end of the measure, at the end barline; segno, coda and tempo marks go at the start. dc@0 puts a jump at the start.

Text values

A value with spaces or with one of " , : & @ { } = + [ ] goes in quotes: !text="r.h.". In quotes, \" is a quote and \\ is a backslash.

Writing text over measures

mj write <file> 5-6 "<text>" (and the write_measures tool) replaces staff measures with the text, as one undo step.

  • Each staff line replaces the music of that staff in that measure: its voices, clef and key changes, marks at a time, and marks over time. A staff measure without a line in the text does not change.
  • A measure line replaces the settings of that measure, also its breaks. A measure without a measure line keeps its settings. To clear them, write an empty line m5:.
  • The first measure needs a time signature. So a measure line for measure 1 must have time=.
  • Each line must be in the measure range of the command.
  • A mark over time can run past the edge of the text. When you read measures, the text shows the ends of such a mark that are in the measures, with a label: (ped&1 for a mark that ends after the text, )ped&1 for a mark that starts before it, and ^&1 for its pedal changes in the measures. A pedal mark that runs through all the measures shows only its changes. A comment line before the measures gives each such mark and its measures: % (ped&1 … )ped&1 on P1.2 runs from m5 to m20.
  • When you write text, a start or end token with no partner in the text belongs to the mark of the same kind on the same staff that crosses the edge of the measures. The token can have a label or not. The options of the token ((:below, (ped:line, )ped:notch) and its place in the measures come from the text. The other end does not change. A pedal change with no open pedal mark in the text, or with the label of no mark in the text, belongs to the pedal mark of the staff that starts before the text.
  • The pedal changes of a staff line are the changes of that staff in that measure: a line with no ^ has no changes, also for a pedal mark that runs past the text.
  • An end of a mark that is in the measures but not in the text stays. It moves to the new event of the same voice at the same time. If no event is there, the mark goes. To remove a mark, write measures that hold both of its ends.
  • The editor checks the result. An error names the line, the measure and staff, and the token. A failed write changes nothing.

When you read measures and write the same text back, the score does not change.