GNMIDI

Table of Contents Keyword Index

ASCII Text syntax
Previous  Top  Next

MIDI unit position and time position are shown in comments before each command:
/* U7765 */  /* 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.
beats 142.38051    
text "Contact: info@gnmidi.com"  
program Ensmble1

Program names (of GM instruments) can be used by number 0-127 or from following GM instrument list:
          0 GrandPno
          1 BritePno
          2 El.Grand
          3 HnkyTonk
          4 ElPiano1
          5 ElPiano2
          6 Harpsich
          7 Clavi.
          8 Celesta
          9 Glocken
         10 MusicBox
         11 Vibes
         12 Marimba
         13 Xylophon
         14 TubulBel
         15 Dulcimer
         16 DrawOrgn
         17 PercOrgn
         18 RockOrgn
         19 ChrcOrgn
         20 ReedOrgn
         21 Acordion
         22 Harmnica
         23 TangoAcd
         24 NylonGtr
         25 SteelGtr
         26 JazzGtr
         27 CleanGtr
         28 MuteGtr
         29 Ovrdrive
         30 Distortd
         31 Harmnics
         32 WoodBass
         33 FngrBass
         34 PickBass
         35 Fretless
         36 SlapBas1
         37 SlapBas2
         38 SynBass1
         39 SynBass2
         40 Violin
         41 Viola
         42 Cello
         43 Contra
         44 TremStrg
         45 Pizzicto
         46 Harp
         47 Timpani
         48 Ensmble1
         49 Ensmble2
         50 SynStrg1
         51 SynStrg2
         52 AahChoir
         53 OohChoir
         54 SynChoir
         55 OrchHit
         56 Trumpet
         57 Trombone
         58 Tuba
         59 MuteTrum
         60 FrenchHr
         61 BrasSect
         62 SynBras1
         63 SynBras2
         64 SprnoSax
         65 AltoSax
         66 TenorSax
         67 BariSax
         68 Oboe
         69 EnglHorn
         70 Bassoon
         71 Clarinet
         72 Piccolo
         73 Flute
         74 Recorder
         75 PanFlute
         76 Bottle
         77 Shakhchi
         78 Whistle
         79 Ocarina
         80 SquareLd
         81 SawLd
         82 CaliopLd
         83 ChiffLd
         84 CharanLd
         85 VoiceLd
         86 FifthLd
         87 Bass&Ld
         88 NewAgePd
         89 WarmPd
         90 PolySyPd
         91 ChoirPd
         92 BowedPd
         93 MetalPd
         94 HaloPd
         95 SweepPd
         96 Rain
         97 SoundTrk
         98 Crystal
         99 Atmosphr
        100 Bright
        101 Goblin
        102 Echoes
        103 SciFi
        104 Sitar
        105 Banjo
        106 Shamisen
        107 Koto
        108 Kalimba
        109 Bagpipe
        110 Fiddle
        111 Shanai
        112 TnklBell
        113 Agogo
        114 StlDrum
        115 WoodBlok
        116 TaikoDrm
        117 MelodTom
        118 SynthTom
        119 RevCymbl
        120 FretNoiz
        121 BrthNoiz
        122 Seashore
        123 Tweet
        124 Telphone
        125 Helicptr
        126 Applause
        127 Gunshot
The names must be written exactly.


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

note ::= notename | number ;

programname ::=
// korg i2/i3 only:
"Dr1"|"Dr2"|"Dr3"|"Dr4"|"Dr5"|"Dr6"|"Dr7"|"Dr8"|
// new program names
"GrandPno"|"BritePno"|"El.Grand"|"HnkyTonk"|"ElPiano1"|"ElPiano2"|
"Harpsich"| "Clavi."|"Celesta"|"Glocken"|"MusicBox"|"Vibes"|"Marimba"|
"Xylophon"|"TubulBel"|"Dulcimer"|"DrawOrgn"|"PercOrgn"|"RockOrgn"|"ChrcOrgn"|
"ReedOrgn"|"Acordion"|"Harmnica"|"TangoAcd"|"NylonGtr"|"SteelGtr"|"JazzGtr"|
"CleanGtr"|"MuteGtr"|"Ovrdrive"|"Distortd"|"Harmnics"|"WoodBass"|"FngrBass"|
"PickBass"|"Fretless"|"SlapBas1"|"SlapBas2"|"SynBass1"|"SynBass2"|"Violin"|
"Viola"|"Cello"|"Contra"|"TremStrg"|"Pizzicto"|"Harp"|"Timpani"|"Ensmble1"|
"Ensmble2"|"SynStrg1"|"SynStrg2"|"AahChoir"|"OohChoir"|"SynChoir"|"OrchHit"|
"Trumpet"|"Trombone"|"Tuba"|"MuteTrum"|"FrenchHr"|"BrasSect"|"SynBras1"|
"SynBras2"|"SprnoSax"|"AltoSax"|"TenorSax"|"BariSax"|"Oboe"|"EnglHorn"|
"Bassoon"|"Clarinet"|"Piccolo"|"Flute"|"Recorder"|"PanFlute"|"Bottle"|
"Shakhchi"|"Whistle"|"Ocarina"|"SquareLd"|"SawLd"|"CaliopLd"|"ChiffLd"|
"CharanLd"|"VoiceLd"|"FifthLd"|"Bass&Ld"|"NewAgePd"|"WarmPd"|"PolySyPd"|
"ChoirPd"|"BowedPd"|"MetalPd"|"HaloPd"|"SweepPd"|"Rain"|"SoundTrk"|
"Crystal"|"Atmosphr"|"Bright"|"Goblin"|"Echoes"|"SciFi"|"Sitar"|"Banjo"|
"Shamisen"|"Koto"|"Kalimba"|"Bagpipe"|"Fiddle"|"Shanai"|"TnklBell"|
"Agogo"|"StlDrum"|"WoodBlok"|"TaikoDrm"|"MelodTom"|"SynthTom"|"RevCymbl"|
"FretNoiz"|"BrthNoiz"|"Seashore"|"Tweet"|"Telphone"|"Helicptr"|"Applause"|
"Gunshot"|
// old general MIDI programs (GM):
"Piano"| "BritePiano"| "HammerPiano"| "HonkeyTonk"| "NewTines"| "DigiPiano"| "Harpsicord"| "Clav"|
"Celesta"| "Glocken"| "MusicBox"| "Vibes"| "Marimba"| "Xylophon"| "Tubular"| "Santur"|
"FullOrgan"| "PercOrgan"| "BX-3Organ"| "ChurchPipe"| "Positive"| "Musette"| "Harmonica"| "Tango"|
"ClassicGtr"| "A.Guitar"| "JazzGuitar"| "CleanGtr"| "MuteGuitar"| "OverDrive"| "DistGuitar"| "RockMonics"|
"JazzBass"| "DeepBass"| "PickBass"| "FretLess"| "SlapBass1"| "SlapBass2"| "SynthBass1"| "SynthBass2"|
"Violin"| "Viola"| "Cello"| "ContraBass"| "TremoloStr"| "Pizzicato"| "Harp"| "Timpani"|
"Marcato"| "SlowString"| "AnalogPad"| "StringPad"| "Choir"| "DooVoice"| "Voices"| "OrchHit"|
"Trumpet"| "Trombone"| "Tuba"| "MutedTrumpet"| "FrenchHorn"| "Brass"| "SynBrass1"| "SynBrass2"|
"SopranoSax"| "AltoSax"| "TenorSax"| "BariSax"| "SweetOboe"| "EnglishHorn"| "BasoonOboe"| "Clarinet"|
"Piccolo"| "Flute"| "Recorder"| "PanFlute"| "Bottle"| "Shakuhachi"|"Whistle"| "Ocarina"|
"SquareWave"| "SawWave"| "SynCalinope"| "SynChiff"| "Charang"| "AirChorus"| "Rezzo4ths"| "Bass&Lead"|
"Fantasia"| "WarmPad"| "PolyPad"| "GhostPad"| "BowedGlas"| "MetalPad"| "HaloPad"| "Sweep"|
"IceRain"| "SoundTrack"| "Crystal"| "Atmosphere"| "Brightness"| "Goblin"| "EchoDrop"| "StarTheme"|
"Sitar"| "Banjo"| "Shamisen"| "Koto"| "Kalimba"|"Scotland"|"Fiddle"| "Shanai"|
"MetalBell"| "Agogo"| "SteelDrums"| "Woodblock"| "Taiko"| "Tom"| "SynthTom"| "RevCymbal"|
"FretNoise"| "NoiseChiff"| "Seashore"| "Birds"| "Telephone"| "Helicopter"| "Stadium!!"| "GunShot"
;

Grammar in extended BNF
midifile ::= midisong
;

midisong ::= songoption* midihead songoption* miditrack+
;

songoption ::= "mute" channel+ // ignore these channels
| "solo" channel+ // use these channels only
;

channel ::= number // only 1-16 are valid channels
; // channel 10 should be used for drums

midihead ::= "mthd" [version] [unit] "end" "mthd"
;

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

unit ::= "unit" number // default unit: 192
;

miditrack ::= "mtrk" [ "(" channel ")" ]
       event*
    "end" "mtrk"
    ;

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
;

psrbasschord ::= // optional
| "basschord" literal ;

duration ::=
number // units as defined in header
| number "/" number (tact units, e.g. 3/4)
;

program ::= number | programname ;

bytes ::= (number|literal)+ ;

hexsequence ::= (hexdigits|literal)+ ;

hexdigits ::= hexdigit+ ;