play_mode->close_output();  
 #ifdef USE_PORTMIDI Pm_Terminate(); #else 
static void ctl_pass_playing_list(int n, char *args[])#else// 0: OK, 2: Require to reset.int ctl_pass_playing_list2(int n, char *args[])#endif{	int i, j;	UINT ID[MAX_PORT];	MidiEvent ev;	UINT port=0 ;#ifndef IA_W32G_SYN	if(n > MAX_PORT ){		printf( "Usage: timidity -iW [Midi interface No s]\n");		return;	}#endif	if(n>0){		port=0;		while(port<n && n!=0){			if( (ID[port] = atoi(args[port]))==0 ){				n=0;			}else{				if(MMSYSERR_NOERROR==midiInOpen(&hMidiIn[port],ID[port]-1,(DWORD)NULL,(DWORD)0L,CALLBACK_NULL)){					midiInReset(hMidiIn[port]);					midiInClose(hMidiIn[port]);				}else{					n=0;#ifdef IA_W32G_SYN					{						char buff[1024];						sprintf ( buff, "MIDI IN Device ID %d is not available. So set a proper ID for the MIDI port %d and restart.", ID[port], port );						MessageBox ( NULL, buff, "Error", MB_OK );						return 2;					}#endif				}			}		port++;		}		portnumber=port;	}#ifndef IA_W32G_SYN	if(n==0){		MIDIINCAPS InCaps;		char cbuf[80];		printf("Opening Devicedriver:");		InNum = midiInGetNumDevs();		printf("Available Midi Input devices:\n");		for (ID[port]=1;ID[port] <=InNum;ID[port]++){			midiInGetDevCaps(ID[port]-1,(LPMIDIINCAPSA) &InCaps,sizeof(InCaps));			printf("%d:%s\n",ID[port],(LPSTR)InCaps.szPname);		}		printf("Whow many ports do you use?(max %d)\n",MAX_PORT);		do{			if (0==scanf("%u",&portnumber)) scanf("%s",cbuf);		}while(portnumber == 0 ||portnumber > MAX_PORT);		printf("\n");		for(port=0;port<portnumber;port++){			printf("Keyin Input Device Number of port%d\n",port);			do{				if (0==scanf("%u",&ID[port])) scanf("%s",cbuf);			}while(ID[port] == 0 ||(ID[port] > InNum));			printf("\n");		}	}#endif	for(port=0;port<portnumber;port++){		wInID[port]=ID[port]-1;	}#ifndef IA_W32G_SYN	printf("TiMidity starting in Windows Synthesizer mode\n");	printf("Usage: timidity -iW [Midi interface No]\n");	printf("\n");//	printf("Please wait for piano 'C' sound\n");	printf("\n");	printf("N (Normal mode) M(GM mode) S(GS mode) X(XG mode) \n");	printf("(Only in Normal mode, Mode can be changed by MIDI data)\n");	printf("m(GM reset) s(GS reset) x(XG reset)\n");	printf("\n");	printf("Press 'q' key to stop\n");#endif/*	for(port=0;port<portnumber;port++){		//trick for MIDI Yoke		midiInOpen(&hMidiIn[port],wInID[port],(DWORD)NULL,(DWORD)0L,CALLBACK_NULL);		midiInStart(hMidiIn[port]);		midiOutOpen(&hMidiOut[port],wInID[port],(DWORD)NULL,(DWORD)0L,CALLBACK_NULL);		midiOutShortMsg(hMidiOut[port], 0x007f3c90);		midiOutShortMsg(hMidiOut[port], 0x00003c80);		midiOutReset(hMidiOut[port]);		midiOutClose(hMidiOut[port]);		midiInReset(hMidiIn[port]);		midiInClose(hMidiIn[port]);	}*/	opt_realtime_playing = 2; /* Enable loading patch while playing */	allocate_cache_size = 0; /* Don't use pre-calclated samples */	auto_reduce_polyphony = 0;	current_keysig = current_temper_keysig = opt_init_keysig;	note_key_offset = 0;	time_advance=play_mode->rate/TICKTIME_HZ*2;	if (!(play_mode->encoding & PE_MONO))		time_advance >>= 1;	if (play_mode->encoding & PE_16BIT)		time_advance >>= 1;	if (opt_force_keysig != 8) {		i = current_keysig + ((current_keysig < 8) ? 7 : -6);		j = opt_force_keysig + ((current_keysig < 8) ? 7 : 10);		while (i != j && i != j + 12) {			if (++note_key_offset > 6)				note_key_offset -= 12;			i += (i > 10) ? -5 : 7;		}	}	i = current_keysig + ((current_keysig < 8) ? 7 : -9), j = 0;	while (i != 7 && i != 19)		i += (i < 7) ? 5 : -7, j++;	j += note_key_offset, j -= floor(j / 12.0) * 12;	current_freq_table = j;	seq_reset();/*	for(port=0;port<portnumber;port++){		for (i=0;i<MAX_EXBUF;i++){			IMidiHdr[port][i] = (MIDIHDR*)safe_malloc(sizeof(MIDIHDR));			memset(IMidiHdr[port][i],0,sizeof(MIDIHDR));			IMidiHdr[port][i]->lpData = (char*)safe_malloc(BUFF_SIZE);			memset((IMidiHdr[port][i]->lpData),0,BUFF_SIZE);			IMidiHdr[port][i]->dwBufferLength = BUFF_SIZE;		}	}*/	for(port=0;port<portnumber;port++){		for (i=0;i<MAX_EXBUF;i++){			IMidiHdr[port][i] = sIMidiHdr[port][i];			memset(IMidiHdr[port][i],0,sizeof(MIDIHDR));			IMidiHdr[port][i]->lpData = sImidiHdr_data[port][i];			memset((IMidiHdr[port][i]->lpData),0,BUFF_SIZE);			IMidiHdr[port][i]->dwBufferLength = BUFF_SIZE;		}	}	evbuf[0].status=B_END;	evbwpoint=0;	evbrpoint=0;	mvbuse=0;	seq_quit=0;	for(port=0;port<portnumber;port++){		midiInOpen(&hMidiIn[port],wInID[port],(DWORD)MidiInProc,(DWORD)port,CALLBACK_FUNCTION);		for (i=0;i<MAX_EXBUF;i++){			midiInPrepareHeader(hMidiIn[port],IMidiHdr[port][i],sizeof(MIDIHDR));			midiInAddBuffer(hMidiIn[port],IMidiHdr[port][i],sizeof(MIDIHDR));		}	}		for(port=0;port<portnumber;port++){	if(MMSYSERR_NOERROR !=midiInStart(hMidiIn[port]))		printf("midiInStarterror\n");	}//	seq_reset();	system_mode=DEFAULT_SYSTEM_MODE;	change_system_mode(system_mode);	ev.type=ME_RESET;	ev.a=GS_SYSTEM_MODE; //GM is mor better ???	seq_play_event(&ev);/*	ev.channel=0x00;	ev.a=0x3c;	ev.b=0x7f;	ev.type = ME_NOTEON;	seq_play_event(&ev);	ev.type = ME_NOTEOFF;	seq_play_event(&ev);	for(i=0;i<0.4*TICKTIME_HZ;i++){			ev.type = ME_NONE;			seq_set_time(&ev);			play_event(&ev);			aq_fill_nonblocking();	}*/	while(seq_quit==0) {#ifndef IA_W32G_SYN		doit();#else		w32g_syn_doit();#endif	}	midiInStop(hMidiIn[port]);	stop_playing();	play_mode->close_output();	for(port=0;port<portnumber;port++){		midiInReset(hMidiIn[port]);		for (i=0;i<MAX_EXBUF;i++){			midiInUnprepareHeader(hMidiIn[port],IMidiHdr[port][i],sizeof(MIDIHDR));		}		midiInClose(hMidiIn[port]);/*		for (i=0;i<MAX_EXBUF;i++){			free(IMidiHdr[port][i]->lpData);			free(IMidiHdr[port][i]);		}*/	}#ifdef IA_W32G_SYN	return 0;#endif}
4357	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4357/07099d2b73d40a22ba156b7c9bb38b9160f91538/winsyn_c.c/clean/interface/winsyn_c.c