if (b!=0) ctl->cmsg(CMSG_INFO, VERB_DEBUG, "(Strange: tone bank change 0x20%02x)", b); else control=ME_TONE_BANK; 
if (b!=0) ctl->cmsg(CMSG_INFO, VERB_DEBUG, "(Strange: tone bank change 0x%02x)", b); #if 0	/* `Bank Select LSB' is not worked at GS. Please ignore it. */ else control=ME_TONE_BANK; #endif 
static MidiEventList *read_midi_event(void){  static uint8 laststatus, lastchan;  static uint8 nrpn=0, rpn_msb[16], rpn_lsb[16]; /* one per channel */  uint8 me, type, a,b,c;  int32 len;  MidiEventList *new;  for (;;)    {      at+=getvl();      if (fread(&me,1,1,fp)!=1)	{	  ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: read_midi_event: %s", 	       current_filename, sys_errlist[errno]);	  return 0;	}            if(me==0xF0 || me == 0xF7) /* SysEx event */	{	  len=getvl();	  skip(fp, len);	}      else if(me==0xFF) /* Meta event */	{	  fread(&type,1,1,fp);	  len=getvl();	  if (type>0 && type<16)	    {	      static char *label[]={		"Text event: ", "Text: ", "Copyright: ", "Track name: ",		"Instrument: ", "Lyric: ", "Marker: ", "Cue point: "};	      dumpstring(len, label[(type>7) ? 0 : type]);	    }	  else	    switch(type)	      {	      case 0x2F: /* End of Track */		return MAGIC_EOT;	      case 0x51: /* Tempo */		fread(&a,1,1,fp); fread(&b,1,1,fp); fread(&c,1,1,fp);		MIDIEVENT(at, ME_TEMPO, c, a, b);			      default:		ctl->cmsg(CMSG_INFO, VERB_DEBUG, 		     "(Meta event type 0x%02x, length %ld)", type, len);		skip(fp, len);		break;	      }	}      else	{	  a=me;	  if (a & 0x80) /* status byte */	    {	      lastchan=a & 0x0F;	      laststatus=(a>>4) & 0x07;	      fread(&a, 1,1, fp);	      a &= 0x7F;	    }	  switch(laststatus)	    {	    case 0: /* Note off */	      fread(&b, 1,1, fp);	      b &= 0x7F;	      MIDIEVENT(at, ME_NOTEOFF, lastchan, a,b);	    case 1: /* Note on */	      fread(&b, 1,1, fp);	      b &= 0x7F;	      MIDIEVENT(at, ME_NOTEON, lastchan, a,b);	    case 2: /* Key Pressure */	      fread(&b, 1,1, fp);	      b &= 0x7F;	      MIDIEVENT(at, ME_KEYPRESSURE, lastchan, a, b);	    case 3: /* Control change */	      fread(&b, 1,1, fp);	      b &= 0x7F;	      {		int control=255;		switch(a)		  {		  case 7: control=ME_MAINVOLUME; break;		  case 10: control=ME_PAN; break;		  case 11: control=ME_EXPRESSION; break;		  case 64: control=ME_SUSTAIN; break;		  case 120: control=ME_ALL_SOUNDS_OFF; break;		  case 121: control=ME_RESET_CONTROLLERS; break;		  case 123: control=ME_ALL_NOTES_OFF; break;		    /* These should be the SCC-1 tone bank switch		       commands. I don't know why there are two, or		       why the latter only allows switching to bank 0.		       Also, some MIDI files use 0 as some sort of		       continuous controller. This will cause lots of		       warnings about undefined tone banks. */		  case 0: control=ME_TONE_BANK; break;		  case 32: 		    if (b!=0)		      ctl->cmsg(CMSG_INFO, VERB_DEBUG, 				"(Strange: tone bank change 0x20%02x)", b);		    else		      control=ME_TONE_BANK;		    break;		  case 100: nrpn=0; rpn_msb[lastchan]=b; break;		  case 101: nrpn=0; rpn_lsb[lastchan]=b; break;		  case 99: nrpn=1; rpn_msb[lastchan]=b; break;		  case 98: nrpn=1; rpn_lsb[lastchan]=b; break;		    		  case 6:		    if (nrpn)		      {			ctl->cmsg(CMSG_INFO, VERB_DEBUG, 				  "(Data entry (MSB) for NRPN %02x,%02x: %ld)",				  rpn_msb[lastchan], rpn_lsb[lastchan],				  b);			break;		      }		    		    switch((rpn_msb[lastchan]<<8) | rpn_lsb[lastchan])		      {		      case 0x0000: /* Pitch bend sensitivity */			control=ME_PITCH_SENS;			break;		      case 0x7F7F: /* RPN reset */			/* reset pitch bend sensitivity to 2 */			MIDIEVENT(at, ME_PITCH_SENS, lastchan, 2, 0);		      default:			ctl->cmsg(CMSG_INFO, VERB_DEBUG, 				  "(Data entry (MSB) for RPN %02x,%02x: %ld)",				  rpn_msb[lastchan], rpn_lsb[lastchan],				  b);			break;		      }		    break;		    		  default:		    ctl->cmsg(CMSG_INFO, VERB_DEBUG, 			      "(Control %d: %d)", a, b);		    break;		  }		if (control != 255)		  { 		    MIDIEVENT(at, control, lastchan, b, 0); 		  }	      }	      break;	    case 4: /* Program change */	      a &= 0x7f;	      MIDIEVENT(at, ME_PROGRAM, lastchan, a, 0);	    case 5: /* Channel pressure - NOT IMPLEMENTED */	      break;	    case 6: /* Pitch wheel */	      fread(&b, 1,1, fp);	      b &= 0x7F;	      MIDIEVENT(at, ME_PITCHWHEEL, lastchan, a, b);	    default: 	      ctl->cmsg(CMSG_ERROR, VERB_NORMAL, 		   "*** Can't happen: status 0x%02X, channel 0x%02X",		   laststatus, lastchan);	      break;	    }	}    }    return new;}
4357	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4357/cb293c4705e0c7b93d3269c59bcf9bbcab7f6278/readmidi.c/buggy/readmidi.c