newbank = channel[ch].bank_msb; break;  case XG_SYSTEM_MODE:  switch(channel[ch].bank_msb) { case 0:  if(ch == 9  && channel[ch].bank_lsb == 127 && channel[ch].mapID == XG_DRUM_MAP) {  ; } else { midi_drumpart_change(ch, 0); channel[ch].mapID = XG_NORMAL_MAP; } break; case 64:  midi_drumpart_change(ch, 0); channel[ch].mapID = XG_SFX64_MAP; break; case 126:  midi_drumpart_change(ch, 1); channel[ch].mapID = XG_SFX126_MAP; break; case 127:  midi_drumpart_change(ch, 1); channel[ch].mapID = XG_DRUM_MAP; break; default: break; } dr = ISDRUMCHANNEL(ch); newbank = channel[ch].bank_lsb; break;  default: newbank = channel[ch].bank_msb; break; }  if(dr) { channel[ch].bank = prog;  if(drumset[prog] == NULL || drumset[prog]->alt == NULL) channel[ch].altassign = drumset[0]->alt; else channel[ch].altassign = drumset[prog]->alt; ctl_mode_event(CTLE_DRUMPART, 1, ch, 1); } else { if(special_tonebank >= 0) newbank = special_tonebank; channel[ch].bank = newbank; channel[ch].altassign = NULL; ctl_mode_event(CTLE_DRUMPART, 1, ch, 0); }  if(!dr && default_program[ch] == SPECIAL_PROGRAM) channel[ch].program = SPECIAL_PROGRAM; else channel[ch].program = prog;  if(opt_realtime_playing && !dr && (play_mode->flag & PF_PCM_STREAM)) { int b, p;  p = prog; b = channel[ch].bank; instrument_map(channel[ch].mapID, &b, &p); play_midi_load_instrument(0, b, p);
if (dr) { channel[ch].bank = prog;	 channel[ch].program = prog; if (drumset[prog] == NULL || drumset[prog]->alt == NULL) channel[ch].altassign = drumset[0]->alt; else channel[ch].altassign = drumset[prog]->alt; ctl_mode_event(CTLE_DRUMPART, 1, ch, 1); } else { channel[ch].bank = (special_tonebank >= 0) ? special_tonebank : newbank; channel[ch].program = (default_program[ch] == SPECIAL_PROGRAM) ? SPECIAL_PROGRAM : prog; channel[ch].altassign = NULL; ctl_mode_event(CTLE_DRUMPART, 1, ch, 0); if (opt_realtime_playing && play_mode->flag & PF_PCM_STREAM) { b = channel[ch].bank, p = prog; instrument_map(channel[ch].mapID, &b, &p); play_midi_load_instrument(0, b, p); }
void midi_program_change(int ch, int prog){    int newbank, dr;    dr = (int)ISDRUMCHANNEL(ch);    if(dr)	newbank = channel[ch].program;    else	newbank = channel[ch].bank;    switch(play_system_mode)    {      case GS_SYSTEM_MODE: /* GS */	switch(channel[ch].bank_lsb)	{	  case 0:	/* No change */	    break;	  case 1:	    channel[ch].mapID = (!ISDRUMCHANNEL(ch) ? SC_55_TONE_MAP				 : SC_55_DRUM_MAP);	    break;	  case 2:	    channel[ch].mapID = (!ISDRUMCHANNEL(ch) ? SC_88_TONE_MAP				 : SC_88_DRUM_MAP);	    break;	  case 3:	    channel[ch].mapID = (!ISDRUMCHANNEL(ch) ? SC_88PRO_TONE_MAP				 : SC_88PRO_DRUM_MAP);	    break;	  default:	    break;	}	newbank = channel[ch].bank_msb;	break;      case XG_SYSTEM_MODE: /* XG */	switch(channel[ch].bank_msb)	{	  case 0: /* Normal */	    if(ch == 9  && channel[ch].bank_lsb == 127 && channel[ch].mapID == XG_DRUM_MAP) {	      /* FIXME: Why this part is drum?  Is this correct? */	      ;	    } else {	      midi_drumpart_change(ch, 0);	      channel[ch].mapID = XG_NORMAL_MAP;	    }	    break;	  case 64: /* SFX voice */	    midi_drumpart_change(ch, 0);	    channel[ch].mapID = XG_SFX64_MAP;	    break;	  case 126: /* SFX kit */	    midi_drumpart_change(ch, 1);	    channel[ch].mapID = XG_SFX126_MAP;	    break;	  case 127: /* Drumset */	    midi_drumpart_change(ch, 1);	    channel[ch].mapID = XG_DRUM_MAP;	    break;	  default:	    break;	}	dr = ISDRUMCHANNEL(ch);	newbank = channel[ch].bank_lsb;	break;      default:	newbank = channel[ch].bank_msb;	break;    }    if(dr)    {	channel[ch].bank = prog; /* newbank is ignored */	if(drumset[prog] == NULL || drumset[prog]->alt == NULL)	    channel[ch].altassign = drumset[0]->alt;	else	    channel[ch].altassign = drumset[prog]->alt;	ctl_mode_event(CTLE_DRUMPART, 1, ch, 1);    }    else    {	if(special_tonebank >= 0)	    newbank = special_tonebank;	channel[ch].bank = newbank;	channel[ch].altassign = NULL;	ctl_mode_event(CTLE_DRUMPART, 1, ch, 0);    }    if(!dr && default_program[ch] == SPECIAL_PROGRAM)      channel[ch].program = SPECIAL_PROGRAM;    else      channel[ch].program = prog;    if(opt_realtime_playing && !dr && (play_mode->flag & PF_PCM_STREAM))    {	int b, p;	p = prog;	b = channel[ch].bank;	instrument_map(channel[ch].mapID, &b, &p);	play_midi_load_instrument(0, b, p);	}}