Hallo lmuse team,

Dear Werner Schweer,


I am a follower of lmuse for a long time.


I need for a project of myine a tool to parse midi files.

My understanding of all of the MIDI events is quite far.

But I have problems in understanding the runstate issue.


I used grepmidi.cpp at basis.


The only problem is,

How to handle midi events that don't have the uppermost bit set.

// semms to have anything in common with "runstate".


in grepmidi.cpp: in line 146 and folowing are some commandos I don't find any match in the documentation.



if ((me & 0x80) == 0) {

if (runstate == -1)

return -6; //WHAT IS THIS ABOUT 1)

a = me; //WHAT IS THIS ABOUT 2)

me = runstate; //WHAT IS THIS ABOUT 3)



switch (me & 0xf0) {

case 0x80:

case 0x90:

case 0xa0:

case 0xb0:

case 0xe0:



case 0xc0:

case 0xd0:

if (a == -1) { //WHAT IS HIS ABOUT 4)

a = getc(f);



runstate = me; //WHAT IS HIS ABOUT 5)


case 0xf0: // SYSTEM-EVENT




can anybody explain me what the marked issues really are about.


I use the MIDI docs:


"MIDI File Format - The Sonix Spot"

"Standard MIDI - File Format Spec. 1.1"