MIDI unit position and bar position (measure.beat.tick) and time position (millisecond) are shown in comments before each command:
/* U7765 */ /* M10.1.085 */ /* 34085ms */
Comments are inside /* ... */ or start with // till end of line.
Pauses are shown before commands either in MIDI units ( 47; ) or musical notation ( 536/4; ).
MIDI notes consists of pairs of commands: Note on is displayed as + and Note off is displayed as -
MIDI channel are displayed in mtrk(channel number) or as [channel number] inside a track before a command.
Values are shown decimal (0-127) or hexadecimal ($00 - $7F).
Most commands begin with a keyword and have parameters e.g.
The following scheme explains the syntax of MIDI ASCII text in E-BNF (Extended Backus-Naur-Form).
Extended BNF rules:
symbol ::= expr ; rule for symbol
expr can be:
expr* optional list of expr's
expr+ repetition of expr's (at least 1)
[expr] optional expr (0 or 1 occurrences)
expr1 expr2 ... exprN sequence of expr1 ... exprN (in this order)
expr1|expr2|...|exprN alternatives between expr1...exprN (choose one)
(expr) expr itself for grouping (e.g. ("+"|"-")*
"mthd" "(" keywords and operators (case sensitive, use
without " characters)
// text comment until next line
literal ::= characters enclosed in "..." e.g. "Track 1"
(special characters can be escaped by preceding \
e.g. "\"" is " character itself
lexical symbols (in E-BNF):
digit ::= "0"|"1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"9" ;
hexdigit ::= digit|"A"|"B"|"C"|"D"|"E"|"F"|"a"|"b"|"c"|"d"|"e"|"f" ;
decnumber ::= digit+ ;
hexnumber ::= "0" ("x"|"X") hexdigit+
| "$" hexdigit+
;
number ::= decnumber | hexnumber ;
floatnumber ::= decnumber | decnumber "." decnumber ;
notekey ::= "C"|"D"|"E"|"F"|"G"|"A"|"H"|"B"
| "c"|"d"|"e"|"f"|"g"|"a"|"h"|"b" ;
// notekey "h" used in German language is equal to
// notekey "b"
notename ::= notekey ["#" | "is" | "b" | "es"] decnumber ;
// only legal notes as known in music theory are allowed
// suffixes "is" and "es" are used in German language
// "is" is equal to "#"
// "es" is equal to "b"
// exceptions rules (in German language):
// As is equal to Ab
// Es is equal to Eb
// Use F instead of Eis
// Use C instead of His
// Use As instead of Aes
// Use Es instead of Ees
// Use H instead of Ces
// Use E instead of Fes
version ::= "version" number // default version: 1
// currently only versions 0-2 are allowed
// version 0 = single multichannel track
// version 1 = some singlechannel tracks playing together
// version 2 = some multichannel tracks playing one after one
event ::= [ "[" channel "]" ] midievent
| "velocyon" number // default is 127
| "velocyoff" number // default is 0
| duration sep // pause: delay between events
| "print" sep
| "transpose" ["+"|"-"] number sep
| sep
| "copy" "part" literal ;
| "part" literal
event*
"end" "part" literal
;
| "loop" number
event*
"end" "loop"
;
sep ::= ";";
midievent ::=
"seqnumber" number
| "text" literal
| "copyright" literal
| "trackname" literal
| "instrument" literal
| "lyric" literal
| "prefixchannel" channel // following sysex or meta event is applied to this channel
| "prefixport" number // following sysex or meta event is applied to this port
| "smpteofs" number number ":" number ":" number ":" number ":" number
// SMPTE mode hour:minute:second:frame:fractional_frame
// mode 0: 24 frames/second
// mode 1: 25 frames/second
// mode 2: 30 frames/second allow dropping frames
// mode 3: 30 frames/second no dropping allowed
| "tact" number "/" number number number // tactnom / (2 ^^ tactdenom) clicks/beat 32th/beat
| "tempo" number // microseconds per quarter note
| "beats" floatnumber // same as 60.000.000/tempo
// quarter notes per minute
| "key" literal // literal must contain a valid key:
// "Cmin" "Cmaj" "1bmin" "1bmaj" ... "7bmaj" ... "7#min" "7#maj"
| "event" // enter event bytes without change
bytes // no length is added
"end" "event"
| "metaevent" number // metaevent nr. 0-127
bytes // length will be automatically added
"end" "metaevent" // metaevents are 0xff-codes
| "psrmeta" "chord" literal psrbasschord // special meta events for Yamaha PSR chords
| "sysevent" // sysex event (0xf0)
bytes // length will be automatically added
"end" "sysevent"
// end sysevent code 0xf7 is appended automatically!
| "syshex" // sysex event (0xf0)
hexbytes // length will be automatically added
"eox"
// end sysevent code 0xf7 is appended automatically!
| "gmreset" // common sysex command to set GM mode on
| "gsreset" // common sysex command to set GS mode on (mainly used for Roland, Yamaha)
| "gsenter" // same as command gsreset
| "gsexit" // common sysex command to set GS mode off (mainly used for Roland, Yamaha)
| "program" (programname | number | ("A"|"B"|"C"|"D") number
| "control" number number
| "hbank" number
| "lbank" number
| "banka"
| "bankb"
| "bankc"
| "bankd"
| "bankdrum" // bank*: korg i2/i3 only!
| "balance" ("left" | "right" | number)
// number is a value between 0 and 127: 0 is left and 127 is right
| "hold" ("on" | "off" | number)
| "reverb" number
| "chorus" number
| "brightness" number
| "expression" number
| "pitchmodulation" number
| "wheel" number
| "breath" number
| "foot" number
| "portamentotime" number
| "portamento" number
| "data" number
| "volume" number
| "sustain" number
| "sostenuto" number
| "softpedal" number
| "datainc" number
| "datadec" number
| "highRPN" number
| "lowRPN" number
| "pitchbendrange" number
| "localon"
| "localoff"
| "silent"
| "allnotesoff"
| "omnioff"
| "omnion"
| "monoon"
| "polyon"
| "songpos" number
| "songselect" number
| "tunerequest"
| "timingclock"
| "start"
| "continue"
| "stop"
| "activesensing"
| "polyaftertouch" note number
| "aftertouch" number
| "pitch bend" number
| notename duration number sep
| "+" notename (number|"velocyon") sep
| "-" notename (number|"velocyoff) sep
| "+" number number sep // note on with velocity
| "-" number number sep // note off with velocity
;