SETMIDIEVENT(*ev, 0, ME_RESET, 0, XG_SYSTEM_MODE, 0); 
SETMIDIEVENT(*ev, 0, ME_RESET, 0, XG_SYSTEM_MODE, SYSEX_TAG); 
int parse_sysex_event(uint8 *val, int32 len, MidiEvent *ev){	uint16 vol;	    if(current_file_info->mid == 0 || current_file_info->mid >= 0x7e)	current_file_info->mid = val[0];    if(len >= 10 &&       val[0] == 0x41 && /* Roland ID */       val[1] == 0x10 && /* Device ID */       val[2] == 0x42 && /* GS Model ID */       val[3] == 0x12)   /* Data Set Command */    {	/* Roland GS-Based Synthesizers.	 * val[4..6] is address, val[7..len-2] is body.	 *	 * GS     Channel part number	 * 0      10	 * 1-9    1-9	 * 10-15  11-16	 */	int32 addr,checksum,i;		/* SysEx address */	uint8 *body;		/* SysEx body */	uint8 p,gslen;		/* Channel part number [0..15] */	/* check Checksum */	checksum = 0;	for(gslen = 9; gslen < len; gslen++)		if(val[gslen] == 0xF7)			break;	for(i=4;i<gslen-1;i++) {		checksum += val[i];	}	if(((128 - (checksum & 0x7F)) & 0x7F) != val[gslen-1]) {		return 0;	}	addr = (((int32)val[4])<<16 |		((int32)val[5])<<8 |		(int32)val[6]);	body = val + 7;	p = (uint8)((addr >> 8) & 0xF);	if(p == 0)	    p = 9;	else if(p <= 9)	    p--;	p = MERGE_CHANNEL_PORT(p);	if(val[4] == 0x50) {	/* for double module mode */		p += 16;		addr = (((int32)0x40)<<16 |			((int32)val[5])<<8 |			(int32)val[6]);	} else {	/* single module mode */		addr = (((int32)val[4])<<16 |			((int32)val[5])<<8 |			(int32)val[6]);	}	if((addr & 0xFFF0FF) == 0x401015) /* Rhythm Parts */	{#ifdef GS_DRUMPART/* GS drum part check from Masaaki Koyanagi's patch (GS_Drum_Part_Check()) *//* Modified by Masanao Izumo */	    SETMIDIEVENT(*ev, 0, ME_DRUMPART, p, *body, 0);	    return 1;#else	    return 0;#endif /* GS_DRUMPART */	}	if((addr & 0xFFF0FF) == 0x401016) /* Key Shift */	{	    SETMIDIEVENT(*ev, 0, ME_KEYSHIFT, p, *body, 0);	    return 1;	}	if(addr == 0x400004) /* Master Volume */	{	    vol = gs_convert_master_vol(*body);	    SETMIDIEVENT(*ev, 0, ME_MASTER_VOLUME,			 0, vol & 0xFF, (vol >> 8) & 0xFF);	    return 1;	}	if((addr & 0xFFF0FF) == 0x401019) /* Volume on/off */	{#if 0	    SETMIDIEVENT(*ev, 0, ME_VOLUME_ONOFF, p, *body >= 64, 0);#endif	    return 0;	}	if((addr & 0xFFF0FF) == 0x401002) /* Receive channel on/off */	{#if 0	    SETMIDIEVENT(*ev, 0, ME_RECEIVE_CHANNEL, (uint8)p, *body >= 64, 0);#endif	    return 0;	}	if(0x402000 <= addr && addr <= 0x402F5A) /* Controller Routing */	    return 0;	if((addr & 0xFFF0FF) == 0x401040) /* Alternate Scale Tunings */	    return 0;	if((addr & 0xFFFFF0) == 0x400130) /* Changing Effects */	{	    switch(addr & 0xF)	    {	      case 0x8: /* macro */		memcpy(chorus_status.macro, body, 3);		break;	      case 0x9: /* PRE-LPF */		memcpy(chorus_status.pre_lpf, body, 3);		break;	      case 0xa: /* level */		memcpy(chorus_status.level, body, 3);		break;	      case 0xb: /* feed back */		memcpy(chorus_status.feed_back, body, 3);		break;	      case 0xc: /* delay */		memcpy(chorus_status.delay, body, 3);		break;	      case 0xd: /* rate */		memcpy(chorus_status.rate, body, 3);		break;	      case 0xe: /* depth */		memcpy(chorus_status.depth, body, 3);		break;	      case 0xf: /* send level */		memcpy(chorus_status.send_level, body, 3);		break;		  default: break;	    }	    check_chorus_text_start();	    return 0;	}	if((addr & 0xFFF0FF) == 0x401003) /* Rx Pitch-Bend */	    return 0;	if(addr == 0x400110) /* Voice Reserve */	{	    if(len >= 25)		memcpy(chorus_status.voice_reserve, body, 18);	    check_chorus_text_start();	    return 0;	}	if(addr == 0x40007F ||	/* GS Reset */	   addr == 0x00007F)	/* SC-88 Single Module */	{	    SETMIDIEVENT(*ev, 0, ME_RESET, 0, GS_SYSTEM_MODE, 0);	    return 1;	}	return 0;    }    if(len > 9 &&       val[0] == 0x41 && /* Roland ID */       val[1] == 0x10 && /* Device ID */       val[2] == 0x45 &&        val[3] == 0x12 &&        val[4] == 0x10 &&        val[5] == 0x00 &&        val[6] == 0x00)    {	/* Text Insert for SC */	uint8 save;	len -= 2;	save = val[len];	val[len] = '\0';	if(readmidi_make_string_event(ME_INSERT_TEXT, (char *)val + 7, ev, 1))	{	    val[len] = save;	    return 1;	}	val[len] = save;	return 0;    }    if(len > 9 &&                     /* GS lcd event. by T.Nogami*/       val[0] == 0x41 && /* Roland ID */       val[1] == 0x10 && /* Device ID */       val[2] == 0x45 &&        val[3] == 0x12 &&        val[4] == 0x10 &&        val[5] == 0x01 &&        val[6] == 0x00)    {	/* Text Insert for SC */	uint8 save;	len -= 2;	save = val[len];	val[len] = '\0';	if(readmidi_make_lcd_event(ME_GSLCD, (uint8 *)val + 7, ev))	{	    val[len] = save;	    return 1;	}	val[len] = save;	return 0;    }        if(len >= 8 &&       val[0] == 0x43 &&       val[1] == 0x10 &&       val[2] == 0x4C &&       val[3] == 0x00 &&       val[4] == 0x00 &&       val[5] == 0x7E)    {	/* XG SYSTEM ON */	SETMIDIEVENT(*ev, 0, ME_RESET, 0, XG_SYSTEM_MODE, 0);	return 1;    }	/* Non-RealTime / RealTime Universal SysEx messages	 * 0 0x7e(Non-RealTime) / 0x7f(RealTime)	 * 1 SysEx device ID.  Could be from 0x00 to 0x7f.	 *   0x7f means disregard device.	 * 2 Sub ID	 * ...	 * E 0xf7	 */	if (len > 4 && val[0] >= 0x7e)		switch (val[2]) {		case 0x01:	/* Sample Dump header */		case 0x02:	/* Sample Dump packet */		case 0x03:	/* Dump Request */			break;		case 0x04:	/* MIDI Time Code Setup/Device Control */			switch (val[3]) {			case 0x01:	/* Master Volume */				vol = gm_convert_master_vol(val[4], val[5]);				if (val[1] == 0x7f) {					SETMIDIEVENT(*ev, 0, ME_MASTER_VOLUME, 0,							vol & 0xff, vol >> 8 & 0xff);				} else {					SETMIDIEVENT(*ev, 0, ME_MAINVOLUME,							MERGE_CHANNEL_PORT(val[1]),							vol >> 8 & 0xff, 0);				}				return 1;			}			break;		case 0x05:	/* Sample Dump extensions */		case 0x06:	/* Inquiry Message */		case 0x07:	/* File Dump */			break;		case 0x08:	/* MIDI Tuning Standard */			switch (val[3]) {			case 0x0a:				SETMIDIEVENT(*ev, 0, ME_TEMPER_KEYSIG, 0,						val[4] - 0x40 + val[5] * 16, (val[0] == 0x7f));				return 1;			}			break;		case 0x09:	/* General MIDI Message */			/* GM System Enable/Disable */			if(val[3] == 1) {				ctl->cmsg(CMSG_INFO, VERB_DEBUG, "SysEx: GM System On");				SETMIDIEVENT(*ev, 0, ME_RESET, 0, GM_SYSTEM_MODE, 0);			} else if(val[3] == 3) {				ctl->cmsg(CMSG_INFO, VERB_DEBUG, "SysEx: GM2 System On");				SETMIDIEVENT(*ev, 0, ME_RESET, 0, GM2_SYSTEM_MODE, 0);			} else {				ctl->cmsg(CMSG_INFO, VERB_DEBUG, "SysEx: GM System Off");				SETMIDIEVENT(*ev, 0, ME_RESET, 0, DEFAULT_SYSTEM_MODE, 0);			}			return 1;		case 0x7b:	/* End of File */		case 0x7c:	/* Handshaking Message: Wait */		case 0x7d:	/* Handshaking Message: Cancel */		case 0x7e:	/* Handshaking Message: NAK */		case 0x7f:	/* Handshaking Message: ACK */			break;		}    return 0;}
4357	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4357/403ba9b56064914c7c63c083a316638ac27e072e/readmidi.c/buggy/timidity/readmidi.c