• R/O
  • HTTP
  • SSH
  • HTTPS

timidity41: Commit


Commit MetaInfo

Revision01e80eb8d3fe7e78aa45722c4c911c914f717881 (tree)
Time2019-07-25 16:49:14
AuthorStarg <starg@user...>
CommiterStarg

Log Message

Import unkotim227

Change Summary

Incremental Difference

--- a/interface/portmidisyn_c.c
+++ b/interface/portmidisyn_c.c
@@ -96,8 +96,8 @@ extern int seq_quit;
9696
9797 static int ctl_open(int using_stdin, int using_stdout);
9898 static void ctl_close(void);
99-static int ctl_read(int32 *valp);
100-static int cmsg(int type, int verbosity_level, char *fmt, ...);
99+static int ctl_read(ptr_size_t *valp);
100+static int cmsg(int type, int verbosity_level, const char *fmt, ...);
101101 static void ctl_event(CtlEvent *e);
102102 static int ctl_pass_playing_list(int n, char *args[]);
103103
@@ -135,27 +135,29 @@ static FILE *outfp;
135135
136136 static int ctl_open(int using_stdin, int using_stdout)
137137 {
138- ctl.opened = 1;
139- ctl.flags &= ~(CTLF_LIST_RANDOM|CTLF_LIST_SORT);
140- if (using_stdout)
141- outfp = stderr;
142- else
143- outfp = stdout;
144- return 0;
138+ rtsyn_pm_setup();
139+
140+ ctl.opened = 1;
141+ ctl.flags &= ~(CTLF_LIST_RANDOM | CTLF_LIST_SORT);
142+ if (using_stdout)
143+ outfp = stderr;
144+ else
145+ outfp = stdout;
146+ return 0;
145147 }
146148
147149 static void ctl_close(void)
148150 {
149- fflush(outfp);
150- if(seq_quit==0){
151- rtsyn_synth_stop();
152- rtsyn_close();
153- seq_quit=~0;
154- }
155- ctl.opened=0;
151+ fflush(outfp);
152+ if (seq_quit == 0) {
153+ rtsyn_synth_stop();
154+ rtsyn_close();
155+ seq_quit = ~0;
156+ }
157+ ctl.opened = 0;
156158 }
157159
158-static int ctl_read(int32 *valp)
160+static int ctl_read(ptr_size_t *valp)
159161 {
160162 return RC_NONE;
161163 }
@@ -164,50 +166,47 @@ static int ctl_read(int32 *valp)
164166 extern void PutsConsoleWnd(const char *str);
165167 extern int ConsoleWndFlag;
166168 #endif
167-static int cmsg(int type, int verbosity_level, char *fmt, ...)
169+static int cmsg(int type, int verbosity_level, const char *fmt, ...)
168170 {
169171 #ifndef IA_W32G_SYN
172+ va_list ap;
170173
171- va_list ap;
172-
173- if ((type==CMSG_TEXT || type==CMSG_INFO || type==CMSG_WARNING) &&
174- ctl.verbosity<verbosity_level)
175- return 0;
176- va_start(ap, fmt);
177- if(type == CMSG_WARNING || type == CMSG_ERROR || type == CMSG_FATAL)
178- dumb_error_count++;
179- if (!ctl.opened)
180- {
181- vfprintf(stderr, fmt, ap);
182- fputs(NLS, stderr);
174+ if ((type == CMSG_TEXT || type == CMSG_INFO || type == CMSG_WARNING) &&
175+ ctl.verbosity < verbosity_level)
176+ return 0;
177+ va_start(ap, fmt);
178+ if (type == CMSG_WARNING || type == CMSG_ERROR || type == CMSG_FATAL)
179+ dumb_error_count++;
180+ if (!ctl.opened) {
181+ vfprintf(stderr, fmt, ap);
182+ fputs(NLS, stderr);
183183 }
184- else
185- {
186- vfprintf(outfp, fmt, ap);
187- fputs(NLS, outfp);
188- fflush(outfp);
184+ else {
185+ vfprintf(outfp, fmt, ap);
186+ fputs(NLS, outfp);
187+ fflush(outfp);
189188 }
190- va_end(ap);
191-
192-#else
193- if ( !ConsoleWndFlag ) return 0;
194- {
195- char buffer[1024];
196- va_list ap;
197- va_start(ap, fmt);
198- vsnprintf(buffer, sizeof(buffer), fmt, ap);
199189 va_end(ap);
190+#else
191+ if (!ConsoleWndFlag) return 0;
200192
201- if((type==CMSG_TEXT || type==CMSG_INFO || type==CMSG_WARNING) &&
202- ctl.verbosity<verbosity_level)
203- return 0;
204-// if(type == CMSG_FATAL)
205-// w32g_msg_box(buffer, "TiMidity Error", MB_OK);
206- PutsConsoleWnd(buffer);
207- PutsConsoleWnd("\n");
208- return 0;
209- }
210-#endif
193+ {
194+ char buffer[1024];
195+ va_list ap;
196+ va_start(ap, fmt);
197+ vsnprintf(buffer, sizeof(buffer), fmt, ap);
198+ va_end(ap);
199+
200+ if ((type == CMSG_TEXT || type == CMSG_INFO || type == CMSG_WARNING) &&
201+ ctl.verbosity < verbosity_level)
202+ return 0;
203+// if (type == CMSG_FATAL)
204+// w32g_msg_box(buffer, "TiMidity Error", MB_OK);
205+ PutsConsoleWnd(buffer);
206+ PutsConsoleWnd("\n");
207+ return 0;
208+ }
209+#endif /* !IA_W32G_SYN */
211210
212211 return 0;
213212 }
@@ -218,206 +217,221 @@ static void ctl_event(CtlEvent *e)
218217
219218 static void doit(void);
220219
221-#ifdef IA_W32G_SYN
222-extern void w32g_syn_doit(void);
223-extern int w32g_syn_ctl_pass_playing_list(int n_, char *args_[]);
224-
225-
226-static int ctl_pass_playing_list(int n, char *args[])
227-{
228- return w32g_syn_ctl_pass_playing_list ( n, args );
229-}
230-#endif
231-
232220 #ifndef IA_W32G_SYN
233221 static int ctl_pass_playing_list(int n, char *args[])
234222 #else
235223 // 0: OK, 2: Require to reset.
236-static int ctl_pass_playing_list2(int n, char *args[])
224+int ctl_pass_playing_list2(int n, char *args[])
237225 #endif
238226 {
239- int i, j,devnum,devok;
240- unsigned int port=0 ;
241- int started;
242- char cbuf[80];
227+ int i, j, devnum, devok;
228+ unsigned int port = 0;
229+ int started;
230+ char cbuf[80];
243231 #if defined(__W32__) && defined(FORCE_TIME_PERIOD)
244- TIMECAPS tcaps;
232+ TIMECAPS tcaps;
245233 #endif /* __W32__ && FORCE_TIME_PERIOD */
246234
247-rtsyn_get_port_list();
235+ rtsyn_get_port_list();
248236
249237 #ifndef IA_W32G_SYN
250- if(n > MAX_PORT ){
251- printf( "Usage: timidity -iW [Midi interface No s]\n");
252- return 1;
253- }
238+ if (n > MAX_PORT) {
239+ ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
240+ "Usage: timidity -i%c [Midi interface No s]" NLS, ctl.id_character);
241+ return 1;
242+ }
254243 #endif
255244
256- if(n>0){
257- port=0;
258- while(port<n && n!=0){
259- if( (portID[port] = atoi(args[port]))==0 ){
260- n=0;
261- }else{
262- devok=0;
263- for(i=0;i<rtsyn_nportlist;i++){
264- sscanf( rtsyn_portlist[i],"%d:%s",&devnum,cbuf);
265- if(devnum==portID[port]) devok=1;
266- }
267- if(devok==0){
268- n=0;
245+ if (rtsyn_nportlist == 0) {
246+ ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
247+ "Opening Device drivers:" "MIDI IN device is not found" NLS);
248+ return 2;
249+ }
250+
251+ if (n > 0) {
252+ port = 0;
253+ while (port < n && n != 0) {
254+ if ((portID[port] = atoi(args[port])) == 0) {
255+ n = 0;
256+ } else {
257+ devok = 0;
258+ for (i = 0; i < rtsyn_nportlist; i++) {
259+ sscanf(rtsyn_portlist[i], "%d:%s", &devnum, cbuf);
260+ if (devnum == portID[port]) devok = 1;
261+ }
262+ if (devok == 0) {
263+ n = 0;
269264 #ifdef IA_W32G_SYN
270- {
271- char buff[1024];
272- sprintf ( buff, "MIDI IN Device ID %d is not available. So set a proper ID for the MIDI port %d and restart.", portID[port], port );
273- MessageBox ( NULL, buff, "Error", MB_OK );
274- return 2;
275- }
265+ {
266+ char buff[1024];
267+ sprintf(buff, "MIDI IN Device ID %d is not available. So set a proper ID for the MIDI port %d and restart.", portID[port], port);
268+ MessageBoxA(NULL, buff, "Error", MB_OK);
269+ return 2;
270+ }
276271 #endif
277- }
278- }
279- port++;
280- }
281- }
282- if(n==0){
283- rtsyn_portnumber=0;
284- }else{
285- rtsyn_portnumber=port;
286- }
272+ }
273+ }
274+ port++;
275+ }
276+ }
277+ if (n == 0) {
278+ rtsyn_portnumber = 0;
279+ } else {
280+ rtsyn_portnumber = port;
281+ }
287282
288283 #if !defined(IA_W32G_SYN) && !defined(USE_GTK_GUI)
289- if(n==0){
290- char cbuf[80];
291- printf("Whow many ports do you use?(max %d)\n",MAX_PORT);
292- do{
293- if (0==scanf("%u",&rtsyn_portnumber)) scanf("%s",cbuf);
294- }while(rtsyn_portnumber == 0 ||rtsyn_portnumber > MAX_PORT);
295- printf("\n");
296- printf("Opening Device drivers:");
297- printf("Available Midi Input devices:\n");
298-
299- for(i=0;i<rtsyn_nportlist;i++){
300- printf("%s\n",rtsyn_portlist[i]);
301- }
302- for(port=0;port<rtsyn_portnumber;port++){
303- printf("Keyin Input Device Number of port%d\n",port+1);
304- do{
305- devok=0;
306- if (0==scanf("%u",&portID[port])) scanf("%s",cbuf);
307- for(i=0;i<rtsyn_nportlist;i++){
308- sscanf( rtsyn_portlist[i],"%d:%s",&devnum,cbuf);
309- if(devnum==portID[port]) devok=1;
310- }
311- }while(devok==0);
312- printf("\n");
313- }
314- }
284+ if (n == 0) {
285+ char cbuf[MAX_RTSYN_PORTLIST_LEN + 8], fmt[64];
286+ ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
287+ "Whow many ports do you use?(max %d)" NLS, MAX_PORT);
288+ do {
289+ snprintf(fmt, sizeof(fmt), "%%.%ds", MAX_RTSYN_PORTLIST_LEN - 1);
290+ if (0 == scanf("%u", &rtsyn_portnumber)) { scanf(fmt, cbuf); }
291+ } while (intr == 0 &&
292+ (rtsyn_portnumber == 0 || rtsyn_portnumber > MAX_PORT));
293+ ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
294+ "\nOpening Device drivers:" "Available Midi Input devices:" "%d" NLS, rtsyn_nportlist);
295+
296+ ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
297+ "NUM:NAME");
298+ for (i = 0; i < rtsyn_nportlist; i++) {
299+ ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
300+ "%s", rtsyn_portlist[i]);
301+ }
302+ ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
303+ "");
304+
305+ for (port = 0; port < rtsyn_portnumber; port++) {
306+ ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
307+ "Keyin Input Device Number of port%d", port + 1);
308+ do {
309+ devok = 0;
310+ snprintf(fmt, sizeof(fmt), "%%.%ds", MAX_RTSYN_PORTLIST_LEN - 1);
311+ if (0 == scanf("%u", &portID[port])) { scanf(fmt, cbuf); }
312+ for (i = 0; intr == 0 && i < rtsyn_nportlist; i++) {
313+ snprintf(fmt, sizeof(fmt), "%%d:%%.%ds", MAX_RTSYN_PORTLIST_LEN - 1);
314+ sscanf(rtsyn_portlist[i], fmt, &devnum, cbuf);
315+ if (devnum == portID[port]) devok = 1;
316+ }
317+ } while (devok == 0);
318+ ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
319+ "");
320+ }
321+ }
315322 #endif
316323
317- for(port=0;port<rtsyn_portnumber;port++){
318- portID[port]=portID[port]-1;
319- }
320-
324+ for (port = 0; port < rtsyn_portnumber; port++) {
325+ portID[port] = portID[port] - 1;
326+ }
321327
322328 #if !defined(IA_W32G_SYN) && !defined(USE_GTK_GUI)
323- printf("TiMidity starting in PortMIDI Synthesizer mode\n");
324- printf("Usage: timidity -iP [Midi interface No]\n");
325- printf("\n");
326- printf("N (Normal mode) M(GM mode) S(GS mode) X(XG mode) \n");
327- printf("(Only in Normal mode, Mode can be changed by MIDI data)\n");
328- printf("m(GM reset) s(GS reset) x(XG reset)\n");
329- printf("\n");
330- printf("Press 'q' key to stop\n");
329+ ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
330+ "TiMidity starting in PortMIDI Synthesizer mode");
331+ ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
332+ "Usage: timidity -i%c [Midi interface No]" NLS, ctl.id_character);
333+ ctl.cmsg(CMSG_WARNING, VERB_NORMAL, "c(Reset)");
334+ ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
335+ "N(Normal mode) M(GM mode) S(GS mode) X(XG mode) G(GM2 mode) D(SD mode) K(KG mode) J(CM mode)");
336+ ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
337+ "(Only in Normal mode, Mode can be changed by MIDI data)");
338+ ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
339+ "m(GM reset) s(GS reset) x(XG reset) g(GM2 reset) d(SD reset) k(KG reset) j(CM reset)" NLS);
340+ ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
341+ "Press 'q' key to stop");
331342 #endif
332343
333- rtsyn_init();
344+ rtsyn_init();
334345
335-#ifdef USE_GTK_GUI
336- twgtk_main();
337-#else
338346 #if defined(__W32__) && defined(FORCE_TIME_PERIOD)
339- if (timeGetDevCaps(&tcaps, sizeof(TIMECAPS)) != TIMERR_NOERROR)
340- tcaps.wPeriodMin = 10;
341- timeBeginPeriod(tcaps.wPeriodMin);
347+ if (timeGetDevCaps(&tcaps, sizeof(TIMECAPS)) != TIMERR_NOERROR)
348+ tcaps.wPeriodMin = 10;
349+ timeBeginPeriod(tcaps.wPeriodMin);
342350 #endif /* __W32__ && FORCE_TIME_PERIOD */
351+
352+#ifdef USE_GTK_GUI
353+ twgtk_main();
354+#else
343355 #ifdef IA_W32G_SYN
344- if(0!=rtsyn_synth_start()){
345- seq_quit=0;
346- while(seq_quit==0) {
347- w32g_syn_doit();
348- }
349- rtsyn_synth_stop();
350- }
356+ if (0 != rtsyn_synth_start()) {
357+ seq_quit = 0;
358+ while (seq_quit == 0) {
359+ w32g_syn_doit();
360+ }
361+ rtsyn_synth_stop();
362+ }
351363 #else
352- if(0!=rtsyn_synth_start()){
353- seq_quit=0;
354- while(seq_quit==0) {
355- doit();
356- }
357- rtsyn_synth_stop();
358- }
364+ if (0 != rtsyn_synth_start()) {
365+ seq_quit = 0;
366+ while (seq_quit == 0) {
367+ doit();
368+ }
369+ rtsyn_synth_stop();
370+ }
359371 #endif /* IA_W32G_SYN */
372+#endif /* USE_GTK_GUI */
373+
360374 #if defined(__W32__) && defined(FORCE_TIME_PERIOD)
361- timeEndPeriod(tcaps.wPeriodMin);
375+ timeEndPeriod(tcaps.wPeriodMin);
362376 #endif /* __W32__ && FORCE_TIME_PERIOD */
363-#endif /* USE_GTK_GUI */
364- rtsyn_close();
377+ rtsyn_close();
365378
366- return 0;
379+ return 0;
367380 }
368381
369382
370383 #ifndef IA_W32G_SYN
371384
372-
373385 #ifndef __W32__
374-static void init_keybord(void){
375- tcgetattr(0,&initial_settings);
376- tcgetattr(0,&new_settings);
377- new_settings.c_lflag &= ~ICANON;
378- new_settings.c_lflag &= ~ECHO;
379- new_settings.c_lflag &= ~ISIG;
380- new_settings.c_cc[VMIN] = 1;
381- new_settings.c_cc[VTIME] = 0;
382- tcsetattr(0, TCSANOW, &new_settings);
386+static void init_keybord(void)
387+{
388+ tcgetattr(0, &initial_settings);
389+ tcgetattr(0, &new_settings);
390+ new_settings.c_lflag &= ~ICANON;
391+ new_settings.c_lflag &= ~ECHO;
392+ new_settings.c_lflag &= ~ISIG;
393+ new_settings.c_cc[VMIN] = 1;
394+ new_settings.c_cc[VTIME] = 0;
395+ tcsetattr(0, TCSANOW, &new_settings);
383396 }
384397
385-static void close_keybord(void){
386- tcsetattr(0, TCSANOW, &initial_settings);
398+static void close_keybord(void)
399+{
400+ tcsetattr(0, TCSANOW, &initial_settings);
387401 }
388402
389-static int kbhit(void){
390- char ch;
391- int nread;
392-
393- if(peek_character != -1)
394- return 1;
395- new_settings.c_cc[VMIN]=0;
396- tcsetattr(0,TCSANOW, &new_settings);
397- nread = read(0, &ch, 1);
398- new_settings.c_cc[VMIN]=1;
399- tcsetattr(0,TCSANOW, &new_settings);
400-
401- if(nread == 1) {
402- peek_character = ch;
403- return 1;
404- }
405- return 0;
403+static int kbhit(void)
404+{
405+ char ch;
406+ int nread;
407+
408+ if (peek_character != -1)
409+ return 1;
410+ new_settings.c_cc[VMIN] = 0;
411+ tcsetattr(0, TCSANOW, &new_settings);
412+ nread = read(0, &ch, 1);
413+ new_settings.c_cc[VMIN] = 1;
414+ tcsetattr(0, TCSANOW, &new_settings);
415+
416+ if (nread == 1) {
417+ peek_character = ch;
418+ return 1;
419+ }
420+ return 0;
406421 }
407422
408-
409-static char readch(void){
410- char ch;
411- if(peek_character != -1){
412- ch = peek_character;
413- peek_character = -1;
414- return ch;
415- }
416- read(0,&ch,1);
417- return ch;
423+static char readch(void)
424+{
425+ char ch;
426+ if (peek_character != -1) {
427+ ch = peek_character;
428+ peek_character = -1;
429+ return ch;
430+ }
431+ read(0, &ch, 1);
432+ return ch;
418433 }
419-#endif
420-
434+#endif /* !__W32__ */
421435
422436 static void doit(void)
423437 {
--- a/interface/rtsyn_common.c
+++ b/interface/rtsyn_common.c
@@ -109,7 +109,7 @@ static double active_sensing_time = 0;
109109
110110 /*
111111 #define EX_RESET_NO 7
112-static char sysex_resets[EX_RESET_NO][11]={
112+static uint8 sysex_resets[EX_RESET_NO][11]={
113113 '\xf0','\x7e','\x7f','\x09','\x00','\xf7','\x00','\x00','\x00','\x00','\x00',
114114 '\xf0','\x7e','\x7f','\x09','\x01','\xf7','\x00','\x00','\x00','\x00','\x00',
115115 '\xf0','\x7e','\x7f','\x09','\x03','\xf7','\x00','\x00','\x00','\x00','\x00',
@@ -120,7 +120,7 @@ static char sysex_resets[EX_RESET_NO][11]={
120120 */
121121 /*
122122 #define EX_RESET_NO 9
123-static char sysex_resets[EX_RESET_NO][11]={
123+static uint8 sysex_resets[EX_RESET_NO][11]={
124124 '\xf0','\x7e','\x7f','\x09','\x00','\xf7','\x00','\x00','\x00','\x00','\x00', //gm off
125125 '\xf0','\x7e','\x7f','\x09','\x01','\xf7','\x00','\x00','\x00','\x00','\x00', //gm1
126126 '\xf0','\x7e','\x7f','\x09','\x02','\xf7','\x00','\x00','\x00','\x00','\x00', //gm off
@@ -611,7 +611,7 @@ int rtsyn_play_one_data (int port, uint32 dwParam1, double event_time)
611611 #if 0
612612 if ((dwParam1 & 0x000000ff) == 0xf1)
613613 //MIDI Time Code Qtr. Frame (not need)
614- printf("MIDI Time Code Qtr\n");
614+ ctl->cmsg(CMSG_INFO, VERB_DEBUG_SILLY, "MIDI Time Code Qtr");
615615 if ((dwParam1 & 0x000000ff) == 0xf3)
616616 //Song Select(Song #) (not need)
617617 #endif
@@ -629,19 +629,19 @@ int rtsyn_play_one_data (int port, uint32 dwParam1, double event_time)
629629 #if 0
630630 if ((dwParam1 & 0x000000ff) == 0xf8)
631631 //Timing Clock (not need)
632- printf("Timing Clock\n");
632+ ctl->cmsg(CMSG_INFO, VERB_DEBUG_SILLY, "Timing Clock");
633633 if ((dwParam1&0x000000ff)==0xfa)
634- //Start
634+ {}//Start
635635 if ((dwParam1 & 0x000000ff) == 0xfb)
636- //Continue
636+ {}//Continue
637637 if ((dwParam1 & 0x000000ff) == 0xfc) {
638638 //Stop
639- printf("Stop\n");
639+ ctl->cmsg(CMSG_INFO, VERB_DEBUG_SILLY, "Stop");
640640 }
641641 #endif
642642 if ((dwParam1 & 0x000000ff) == 0xfe) {
643643 //Active Sensing
644-// printf("Active Sensing\n");
644+// ctl->cmsg(CMSG_INFO, VERB_DEBUG_SILLY, "Active Sensing");
645645 active_sensing_flag = ~0;
646646 active_sensing_time = get_current_calender_time();
647647 }
@@ -650,12 +650,12 @@ int rtsyn_play_one_data (int port, uint32 dwParam1, double event_time)
650650 if(rtsyn_sample_time_mode == 1){
651651 rtsyn_tmr_reset();
652652 }else{
653- //printf("System Reset\n");
653+ //ctl->cmsg(CMSG_INFO, VERB_DEBUG_SILLY, "System Reset");
654654 }
655655 }
656656 break;
657657 default:
658-// printf("Unsup/ed event %d\n", aevp->type);
658+// ctl->cmsg(CMSG_INFO, VERB_DEBUG_SILLY, "Unsupported event %d", aevp->type);
659659 break;
660660 }
661661 if (ev.type != ME_NONE) {
@@ -669,7 +669,7 @@ int rtsyn_play_one_data (int port, uint32 dwParam1, double event_time)
669669 }
670670
671671
672-void rtsyn_play_one_sysex (uint8 *sysexbuffer, int exlen, double event_time )
672+void rtsyn_play_one_sysex(uint8 *sysexbuffer, int exlen, double event_time )
673673 {
674674 int i, j, chk, ne;
675675 MidiEvent ev;
--- a/interface/vt100.c
+++ b/interface/vt100.c
@@ -47,7 +47,8 @@ d0|vt100|vt100-am|vt100am|Digital VT100:\
4747
4848 void vt100_init_screen(void)
4949 {
50- vt100_reset_attr();
50+ fputs("\033[?1049h", stdout);
51+ vt100_reset_attr();
5152 fputs("\033[H\033[J", stdout);
5253 }
5354
@@ -59,7 +60,13 @@ void vt100_refresh(void)
5960
6061 void vt100_clrtoeol(void)
6162 {
62- fputs("\033[K", stdout);
63+ fputs("\033[K", stdout);
64+}
65+
66+void vt100_free_screen(void)
67+{
68+ fputs("\033[?1049l", stdout);
69+ fputs("\033[H\033[J", stdout);
6370 }
6471
6572 void vt100_move(int row, int col)
@@ -91,6 +98,7 @@ void vt100_reset_attr(void)
9198 void vt100_init_screen(void) { }
9299 void vt100_refresh(void) { fflush(stdout); }
93100 void vt100_clrtoeol(void) { }
101+void vt100_free_screen(void) { }
94102 void vt100_move(int row, int col) { }
95103 void vt100_set_attr(int attr) { }
96104 void vt100_reset_attr(void) { }
--- a/interface/vt100.h
+++ b/interface/vt100.h
@@ -32,6 +32,7 @@
3232 extern void vt100_init_screen(void);
3333 extern void vt100_refresh(void);
3434 extern void vt100_clrtoeol(void);
35+extern void vt100_free_screen(void);
3536 extern void vt100_move(int row, int col);
3637 extern void vt100_set_attr(int attr);
3738 extern void vt100_reset_attr(void);
--- a/interface/vt100_c.c
+++ b/interface/vt100_c.c
@@ -30,11 +30,6 @@
3030 #include <stdarg.h>
3131 #include <ctype.h>
3232 #include <sys/types.h>
33-#ifndef NO_STRING_H
34-#include <string.h>
35-#else
36-#include <strings.h>
37-#endif
3833
3934 #ifdef HAVE_UNISTD_H
4035 #include <unistd.h>
@@ -130,7 +125,7 @@ static void ctl_reset(void);
130125 static int ctl_open(int using_stdin, int using_stdout);
131126 static void ctl_close(void);
132127 static int ctl_read(ptr_size_t *valp);
133-static int32 ctl_write(const uint8 *valp, int32 size);
128+static int32 ctl_write(const uint8 *valp, size_t size);
134129 static int cmsg(int type, int verbosity_level, const char *fmt, ...);
135130 static void ctl_event(CtlEvent *e);
136131
@@ -615,6 +610,7 @@ static void ctl_close(void)
615610 {
616611 ctl.opened = 0;
617612 vt100_move(24, 0);
613+ vt100_free_screen();
618614 vt100_refresh();
619615 }
620616
--- a/interface/w32g_c.c
+++ b/interface/w32g_c.c
@@ -68,7 +68,7 @@ extern void MPanelReset(void);
6868 extern void MPanelUpdate(void);
6969 extern void MPanelUpdateAll(void);
7070 extern void MPanelPaint(void);
71-extern int is_directory(char *path);
71+extern int is_directory(const char *path);
7272 extern int directory_form(char *buffer);
7373 extern int TracerWndDrawSkip;
7474
--- a/interface/w32g_i.c
+++ b/interface/w32g_i.c
@@ -268,15 +268,13 @@ long SetValue(int32 value, int32 min, int32 max)
268268 return v;
269269 }
270270
271-int w32gSecondTiMidity(int opt, int argc, char **argv);
271+int w32gSecondTiMidity(int opt, int argc, char **argv, int nfiles, char **files);
272272 int w32gSecondTiMidityExit(void);
273273 int SecondMode = 1;
274274
275275 void FirstLoadIniFile(void);
276276
277-#if (defined(IA_W32GUI) || defined(IA_W32G_SYN)) && \
278- (!defined(__GNUC__) || /* _MSC_VER, _BORLANDC_, __WATCOMC__ */ \
279- (defined(__GNUC__) && defined(SUPPORT_WINMAIN)))
277+#if (defined(__W32G__) && !defined(TWSYNG32)) && !defined(WIN32GCC)
280278 extern void CmdLineToArgv(LPSTR lpCmdLine, int *argc, CHAR ***argv);
281279 extern int win_main(int argc, char **argv); /* timidity.c */
282280 int WINAPI
@@ -291,7 +289,7 @@ LPSTR lpCmdLine, int nCmdShow)
291289 static int first = 0;
292290
293291 Sleep(100); // Restartで前プロセスの終了待機
294-#ifdef _CRTDBG_MAP_ALLOC
292+#ifdef TIMIDITY_LEAK_CHECK
295293 _CrtSetDbgFlag(CRTDEBUGFLAGS);
296294 #endif
297295 CmdLineToArgv(lpCmdLine,&argc,&argv);
@@ -334,7 +332,7 @@ LPSTR lpCmdLine, int nCmdShow)
334332 return errcode;
335333 #endif
336334 }
337-#endif /* __W32G__ && SUPPORT_WINMAIN */
335+#endif /* (__W32G__ && !TWSYNG32) && !WIN32GCC */
338336
339337 // ***************************************************************************
340338 // System Function
@@ -5118,23 +5116,25 @@ static char *DlgFileOpen(HWND hwnd, const char *title, const char *filter, const
51185116 static void DlgMidiFileOpen(HWND hwnd)
51195117 {
51205118 char *dir, *file;
5121- const char *filter;
5122- const char *filter_en = "timidity file\0*.mid;*.smf;*.rcp;*.r36;*.g18;*.g36;*.rmi;*.mod;*.xm;*.s3m;*.it;*.669;*.amf;*.dsm;*.far;*.gdm;*.imf;*.med;*.mtm;*.stm;*.stx;*.ult;*.uni;*.lzh;*.zip;*.gz;*.pls;*.m3u;*.asx\0"
5123- "midi file\0*.mid;*.midi;*.smf;*.rmi\0"
5124- "rcp file\0*.rcp;*.r36;*.g18;*.g36\0"
5125- "mod file\0*.mod;*.xm;*.s3m;*.it;*.669;*.amf;*.dsm;*.far;*.gdm;*.imf;*.med;*.mtm;*.stm;*.stx;*.ult;*.uni\0"
5126- "archive file\0*.lzh;*.zip;*.gz\0"
5127- "playlist file\0*.pls;*.m3u;*.asx\0"
5128- "all files\0*.*\0"
5129- "\0\0";
5130- const char *filter_jp = "Timidity サポート済みファイル\0*.mid;*.smf;*.rcp;*.r36;*.g18;*.g36;*.rmi;*.mod;*.xm;*.s3m;*.it;*.669;*.amf;*.dsm;*.far;*.gdm;*.imf;*.med;*.mtm;*.stm;*.stx;*.ult;*.uni;*.lzh;*.zip;*.gz;*.pls;*.m3u;*.asx\0"
5131- "SMF/RMID (*.mid;*.midi;*.smf;*.rmi)\0*.mid;*.midi;*.smf;*.rmi\0"
5132- "RCP (*.rcp;*.r36;*.g18;*.g36)\0*.rcp;*.r36;*.g18;*.g36\0"
5133- "MOD (*.mod;*.xm;*.s3m;*.it;*.669;*.amf;*.dsm;*.far;*.gdm;*.imf;*.med;*.mtm;*.stm;*.stx;*.ult;*.uni)\0*.mod;*.xm;*.s3m;*.it;*.669;*.amf;*.dsm;*.far;*.gdm;*.imf;*.med;*.mtm;*.stm;*.stx;*.ult;*.uni\0"
5134- "圧縮済みアーカイブ (*.lzh;*.zip;*.gz)\0*.lzh;*.zip;*.gz\0"
5135- "プレイリストファイル (*.pls;*.m3u;*.asx)\0*.pls;*.m3u;*.asx\0"
5136- "すべてのファイル (*.*)\0*.*\0"
5137- "\0\0";
5119+ const char *filter,
5120+ filter_en[] = "timidity file\0*.mid;*.smf;*.rcp;*.r36;*.g18;*.g36;*.rmi;*.mld;*.mod;*.xm;*.s3m;*.it;*.669;*.amf;*.dsm;*.far;*.gdm;*.imf;*.med;*.mtm;*.stm;*.stx;*.ult;*.uni;*.lzh;*.zip;*.gz;*.pls;*.m3u;*.asx\0"
5121+ "midi file\0*.mid;*.midi;*.smf;*.rmi\0"
5122+ "rcp file\0*.rcp;*.r36;*.g18;*.g36\0"
5123+ "mfi file\0*.mld\0"
5124+ "mod file\0*.mod;*.xm;*.s3m;*.it;*.669;*.amf;*.dsm;*.far;*.gdm;*.imf;*.med;*.mtm;*.stm;*.stx;*.ult;*.uni\0"
5125+ "archive file\0*.lzh;*.zip;*.gz\0"
5126+ "playlist file\0*.pls;*.m3u;*.asx\0"
5127+ "all files\0*.*\0"
5128+ "\0\0",
5129+ filter_jp[] = "Timidity サポート済みファイル\0*.mid;*.smf;*.rcp;*.r36;*.g18;*.g36;*.rmi;*.mld;*.mod;*.xm;*.s3m;*.it;*.669;*.amf;*.dsm;*.far;*.gdm;*.imf;*.med;*.mtm;*.stm;*.stx;*.ult;*.uni;*.lzh;*.zip;*.gz;*.pls;*.m3u;*.asx\0"
5130+ "SMF/RMID (*.mid;*.midi;*.smf;*.rmi)\0*.mid;*.midi;*.smf;*.rmi\0"
5131+ "RCP (*.rcp;*.r36;*.g18;*.g36)\0*.rcp;*.r36;*.g18;*.g36\0"
5132+ "MFi (*.mld)\0*.mld\0"
5133+ "MOD (*.mod;*.xm;*.s3m;*.it;*.669;*.amf;*.dsm;*.far;*.gdm;*.imf;*.med;*.mtm;*.stm;*.stx;*.ult;*.uni)\0*.mod;*.xm;*.s3m;*.it;*.669;*.amf;*.dsm;*.far;*.gdm;*.imf;*.med;*.mtm;*.stm;*.stx;*.ult;*.uni\0"
5134+ "圧縮済みアーカイブ (*.lzh;*.zip;*.gz)\0*.lzh;*.zip;*.gz\0"
5135+ "プレイリストファイル (*.pls;*.m3u;*.asx)\0*.pls;*.m3u;*.asx\0"
5136+ "すべてのファイル (*.*)\0*.*\0"
5137+ "\0\0";
51385138
51395139 if ( PlayerLanguage == LANGUAGE_JAPANESE )
51405140 filter = filter_jp;
--- a/interface/w32g_pref.c
+++ b/interface/w32g_pref.c
@@ -278,6 +278,11 @@ static int w32_reset_exe_directory(void)
278278 #endif
279279 #endif
280280
281+#define MAX_CFG_HISTORY 10
282+
283+static void LoadCfgHistoryINI(HWND hwnd, int cb_id);
284+static void SaveCfgHistoryINI(HWND hwnd, int cb_id);
285+static void AddCurrentTextToCfgHistory(HWND hwnd, int cb_id);
281286
282287 extern int waveConfigDialog(void);
283288 #ifdef AU_W32
@@ -392,8 +397,8 @@ static pref_page_t pref_pages_en[] = {
392397 { 3, TEXT("Output"), (HWND)NULL, IDD_PREF_TIMIDITY3_EN, (DLGPROC) PrefTiMidity3DialogProc, 0 },
393398 { 4, TEXT("sf_ini1"), (HWND)NULL, IDD_PREF_SFINI1_EN, (DLGPROC) PrefSFINI1DialogProc, 0 },
394399 { 5, TEXT("sf_ini2"), (HWND)NULL, IDD_PREF_SFINI2_EN, (DLGPROC) PrefSFINI2DialogProc, 0 },
395- { 6, TEXT("Custom1"), (HWND)NULL, IDD_PREF_CUSTOM1, (DLGPROC) PrefCustom1DialogProc, 0 },
396- { 7, TEXT("Custom2"), (HWND)NULL, IDD_PREF_CUSTOM2, (DLGPROC) PrefCustom2DialogProc, 0 },
400+ { 6, TEXT("Custom1"), (HWND)NULL, IDD_PREF_CUSTOM1_EN, (DLGPROC) PrefCustom1DialogProc, 0 },
401+ { 7, TEXT("Custom2"), (HWND)NULL, IDD_PREF_CUSTOM2_EN, (DLGPROC) PrefCustom2DialogProc, 0 },
397402 { 8, TEXT("InternalSynth"), (HWND)NULL, IDD_PREF_INT_SYNTH_EN, (DLGPROC) PrefIntSynthDialogProc, 0 },
398403 #else
399404 { 0, TEXT("Player"), (HWND)NULL, IDD_PREF_PLAYER_EN, (DLGPROC) PrefPlayerDialogProc, 0 },
@@ -402,8 +407,8 @@ static pref_page_t pref_pages_en[] = {
402407 { 3, TEXT("Output"), (HWND)NULL, IDD_PREF_TIMIDITY3_EN, (DLGPROC) PrefTiMidity3DialogProc, 0 },
403408 { 4, TEXT("sf_ini1"), (HWND)NULL, IDD_PREF_SFINI1_EN, (DLGPROC) PrefSFINI1DialogProc, 0 },
404409 { 5, TEXT("sf_ini2"), (HWND)NULL, IDD_PREF_SFINI2_EN, (DLGPROC) PrefSFINI2DialogProc, 0 },
405- { 6, TEXT("custom1"), (HWND)NULL, IDD_PREF_CUSTOM1, (DLGPROC) PrefCustom1DialogProc, 0 },
406- { 7, TEXT("custom2"), (HWND)NULL, IDD_PREF_CUSTOM2, (DLGPROC) PrefCustom2DialogProc, 0 },
410+ { 6, TEXT("custom1"), (HWND)NULL, IDD_PREF_CUSTOM1_EN, (DLGPROC) PrefCustom1DialogProc, 0 },
411+ { 7, TEXT("custom2"), (HWND)NULL, IDD_PREF_CUSTOM2_EN, (DLGPROC) PrefCustom2DialogProc, 0 },
407412 { 8, TEXT("InternalSynth"), (HWND)NULL, IDD_PREF_INT_SYNTH_EN, (DLGPROC) PrefIntSynthDialogProc, 0 },
408413 #endif
409414 };
@@ -553,7 +558,10 @@ static void PrefWndDelayLoad(void)
553558
554559 void PrefWndCreate(HWND hwnd, UINT cid)
555560 {
556- UINT page = cid ? PrefSearchPageFromCID(cid) : PrefInitialPage;
561+ UINT page;
562+
563+ CurrentPlayerLanguage = PlayerLanguage;
564+ page = cid ? PrefSearchPageFromCID(cid) : PrefInitialPage;
557565
558566 VOLATILE_TOUCH(PrefWndDoing);
559567 if (PrefWndDoing)
@@ -562,7 +570,6 @@ void PrefWndCreate(HWND hwnd, UINT cid)
562570 PrefWndSetOK = 1;
563571
564572 PrefInitialPage = page;
565- CurrentPlayerLanguage = PlayerLanguage;
566573 #if defined(KBTIM_SETUP) || defined(WINDRV_SETUP)
567574 switch(CurrentPlayerLanguage) {
568575 case LANGUAGE_JAPANESE:
@@ -1354,16 +1361,18 @@ PrefPlayerDialogProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam)
13541361 DI_DISABLE(IDC_CHECKBOX_LOOP_CC2);
13551362 DI_DISABLE(IDC_EDIT_LOOP_REPEAT);
13561363 #endif
1357-
1364+
13581365 if (!sp_temp->ConfigFile[0]) {
13591366 strcpy(sp_temp->ConfigFile, ConfigFile);
13601367 }
1361- EB_SETTEXTA(IDC_EDIT_CONFIG_FILE, sp_temp->ConfigFile);
1362- tmp = SendDlgItemMessage(hwnd, IDC_EDIT_CONFIG_FILE, WM_GETTEXTLENGTH, 0, 0); // A/W
1363- SendDlgItemMessage(hwnd, IDC_EDIT_CONFIG_FILE, EM_SETSEL, (WPARAM) tmp, (LPARAM) tmp); // A/W
1368+ EB_SETTEXTA(IDC_COMBO_CONFIG_FILE, sp_temp->ConfigFile);
1369+ tmp = SendDlgItemMessage(hwnd, IDC_COMBO_CONFIG_FILE, WM_GETTEXTLENGTH, 0, 0); // A/W
1370+ SendDlgItemMessage(hwnd, IDC_COMBO_CONFIG_FILE, CB_SETEDITSEL, 0, MAKELPARAM(tmp, tmp)); // A/W
13641371 safe_free(CurrentConfigFile);
13651372 CurrentConfigFile = safe_strdup(sp_temp->ConfigFile);
13661373
1374+ LoadCfgHistoryINI(hwnd, IDC_COMBO_CONFIG_FILE);
1375+
13671376 switch (CurrentPlayerLanguage) {
13681377 case LANGUAGE_ENGLISH:
13691378 CheckRadioButton(hwnd, IDC_RADIOBUTTON_JAPANESE, IDC_RADIOBUTTON_ENGLISH,
@@ -1467,13 +1476,15 @@ PrefPlayerDialogProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam)
14671476 case IDC_BUTTON_CONFIG_FILE: {
14681477 char filename[FILEPATH_MAX];
14691478 filename[0] = '\0';
1470- EB_GETTEXTA(IDC_EDIT_CONFIG_FILE, filename, FILEPATH_MAX - 1);
1479+ EB_GETTEXTA(IDC_COMBO_CONFIG_FILE, filename, FILEPATH_MAX - 1);
14711480 if (!DlgOpenConfigFile(filename, hwnd))
14721481 if (filename[0] != '\0') {
1473- EB_SETTEXTA(IDC_EDIT_CONFIG_FILE, filename);
1474- tmp = SendDlgItemMessage(hwnd, IDC_EDIT_CONFIG_FILE, WM_GETTEXTLENGTH, 0, 0); // A/W
1475- SendDlgItemMessage(hwnd, IDC_EDIT_CONFIG_FILE, EM_SETSEL, (WPARAM) tmp, (LPARAM) tmp); // A/W
1476- }
1482+ EB_SETTEXTA(IDC_COMBO_CONFIG_FILE, filename);
1483+ tmp = SendDlgItemMessage(hwnd, IDC_COMBO_CONFIG_FILE, WM_GETTEXTLENGTH, 0, 0); // A/W
1484+ SendDlgItemMessage(hwnd, IDC_COMBO_CONFIG_FILE, CB_SETEDITSEL, 0, MAKELPARAM(tmp, tmp)); // A/W
1485+ AddCurrentTextToCfgHistory(hwnd, IDC_COMBO_CONFIG_FILE);
1486+ SaveCfgHistoryINI(hwnd, IDC_COMBO_CONFIG_FILE);
1487+ }
14771488 break; }
14781489
14791490 case IDC_BUTTON_CFG_EDIT: {
@@ -1488,7 +1499,7 @@ PrefPlayerDialogProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam)
14881499 }
14891500
14901501 filename[0] = '\0';
1491- EB_GETTEXTA(IDC_EDIT_CONFIG_FILE, filename, FILEPATH_MAX - 1);
1502+ EB_GETTEXTA(IDC_COMBO_CONFIG_FILE, filename, FILEPATH_MAX - 1);
14921503
14931504 w32_reset_exe_directory();
14941505
@@ -1553,8 +1564,10 @@ PrefPlayerDialogProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam)
15531564
15541565 if (initflag)
15551566 break;
1556-
1557- EB_GETTEXTA(IDC_EDIT_CONFIG_FILE, sp_temp->ConfigFile, FILEPATH_MAX - 1);
1567+
1568+ EB_GETTEXTA(IDC_COMBO_CONFIG_FILE, sp_temp->ConfigFile, FILEPATH_MAX - 1);
1569+ AddCurrentTextToCfgHistory(hwnd, IDC_COMBO_CONFIG_FILE);
1570+ SaveCfgHistoryINI(hwnd, IDC_COMBO_CONFIG_FILE);
15581571
15591572 if (CH_GET(IDC_RADIOBUTTON_ENGLISH))
15601573 sp_temp->PlayerLanguage = LANGUAGE_ENGLISH;
@@ -1731,17 +1744,18 @@ PrefSyn1DialogProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam)
17311744 switch (uMess){
17321745 case WM_INITDIALOG:
17331746 if (hFixedPointFont != NULL)
1734- SendDlgItemMessage(hwnd, IDC_EDIT_CONFIG_FILE, WM_SETFONT, (WPARAM) hFixedPointFont, MAKELPARAM(TRUE, 0));
1747+ SendDlgItemMessage(hwnd, IDC_COMBO_CONFIG_FILE, WM_SETFONT, (WPARAM) hFixedPointFont, MAKELPARAM(TRUE, 0));
17351748
17361749
17371750 if (!sp_temp->ConfigFile[0]) {
17381751 strcpy(sp_temp->ConfigFile, ConfigFile);
17391752 }
1740- EB_SETTEXTA(IDC_EDIT_CONFIG_FILE, sp_temp->ConfigFile);
1741- tmp = SendDlgItemMessage(hwnd, IDC_EDIT_CONFIG_FILE, WM_GETTEXTLENGTH, 0, 0); // A/W
1742- SendDlgItemMessage(hwnd, IDC_EDIT_CONFIG_FILE, EM_SETSEL, (WPARAM) tmp, (LPARAM) tmp); // A/W
1753+ EB_SETTEXTA(IDC_COMBO_CONFIG_FILE, sp_temp->ConfigFile);
1754+ tmp = SendDlgItemMessage(hwnd, IDC_COMBO_CONFIG_FILE, WM_GETTEXTLENGTH, 0, 0); // A/W
1755+ SendDlgItemMessage(hwnd, IDC_COMBO_CONFIG_FILE, CB_SETEDITSEL, 0, MAKELPARAM(tmp, tmp)); // A/W
17431756 safe_free(CurrentConfigFile);
17441757 CurrentConfigFile = safe_strdup(sp_temp->ConfigFile);
1758+ LoadCfgHistoryINI(hwnd, IDC_COMBO_CONFIG_FILE);
17451759
17461760 #if defined(WINDRV_SETUP)
17471761 DI_DISABLE(IDC_BUTTON_CFG_RELOAD);
@@ -1892,13 +1906,15 @@ PrefSyn1DialogProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam)
18921906 case IDC_BUTTON_CONFIG_FILE: {
18931907 char filename[FILEPATH_MAX];
18941908 filename[0] = '\0';
1895- EB_GETTEXTA(IDC_EDIT_CONFIG_FILE, filename, FILEPATH_MAX - 1);
1909+ EB_GETTEXTA(IDC_COMBO_CONFIG_FILE, filename, FILEPATH_MAX - 1);
18961910 if (!DlgOpenConfigFile(filename, hwnd))
18971911 if (filename[0] != '\0') {
1898- EB_SETTEXTA(IDC_EDIT_CONFIG_FILE, filename); // A
1899- tmp = SendDlgItemMessage(hwnd, IDC_EDIT_CONFIG_FILE, WM_GETTEXTLENGTH, 0, 0); // A/W
1900- SendDlgItemMessage(hwnd, IDC_EDIT_CONFIG_FILE, EM_SETSEL, (WPARAM) tmp, (LPARAM) tmp); // A/W
1901- }
1912+ EB_SETTEXTA(IDC_COMBO_CONFIG_FILE, filename); // A
1913+ tmp = SendDlgItemMessage(hwnd, IDC_COMBO_CONFIG_FILE, WM_GETTEXTLENGTH, 0, 0); // A/W
1914+ SendDlgItemMessage(hwnd, IDC_COMBO_CONFIG_FILE, CB_SETEDITSEL, 0, MAKELPARAM(tmp, tmp)); // A/W
1915+ AddCurrentTextToCfgHistory(hwnd, IDC_COMBO_CONFIG_FILE);
1916+ SaveCfgHistoryINI(hwnd, IDC_COMBO_CONFIG_FILE);
1917+ }
19021918 break; }
19031919 case IDC_BUTTON_CFG_EDIT: {
19041920 char filename[FILEPATH_MAX];
@@ -1912,7 +1928,7 @@ PrefSyn1DialogProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam)
19121928 }
19131929
19141930 filename[0] = '\0';
1915- EB_GETTEXTA(IDC_EDIT_CONFIG_FILE, filename, FILEPATH_MAX - 1);
1931+ EB_GETTEXTA(IDC_COMBO_CONFIG_FILE, filename, FILEPATH_MAX - 1);
19161932
19171933 w32_reset_exe_directory();
19181934
@@ -1956,8 +1972,11 @@ PrefSyn1DialogProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam)
19561972 case WM_MYSAVE:
19571973 if (initflag)
19581974 break;
1975+
1976+ EB_GETTEXTA(IDC_COMBO_CONFIG_FILE, sp_temp->ConfigFile, FILEPATH_MAX - 1);
1977+ AddCurrentTextToCfgHistory(hwnd, IDC_COMBO_CONFIG_FILE);
1978+ SaveCfgHistoryINI(hwnd, IDC_COMBO_CONFIG_FILE);
19591979
1960- EB_GETTEXTA(IDC_EDIT_CONFIG_FILE, sp_temp->ConfigFile, FILEPATH_MAX - 1);
19611980 if (CH_GET(IDC_RADIOBUTTON_ENGLISH)) {
19621981 sp_temp->PlayerLanguage = LANGUAGE_ENGLISH;
19631982 } else if (CH_GET(IDC_RADIOBUTTON_JAPANESE)) {
@@ -5883,12 +5902,12 @@ static int DlgOpenConfigFile(char *Filename, HWND hwnd)
58835902 dir[FILEPATH_MAX];
58845903 int i, res;
58855904 const char *filter,
5886- filter_en[] = "All Supported file (*.cfg;*.config;*.sf2;*.sf3)\0*.cfg;*.config;*.sf2;*.sf3\0"
5905+ filter_en[] = "All Supported files (*.cfg;*.config;*.sf2;*.sf3)\0*.cfg;*.config;*.sf2;*.sf3\0"
58875906 "SoundFont file (*.sf2)\0*.sf2;*.sf3\0"
58885907 "Config file (*.cfg;*.config)\0*.cfg;*.config\0"
58895908 "All files (*.*)\0*.*\0"
58905909 "\0\0",
5891- filter_jp[] = "すべての対応ファイル (*.cfg;*.config;*.sf2;*.sf2)\0*.cfg;*.config;*.sf2;*.sf3\0"
5910+ filter_jp[] = "すべての対応ファイル (*.cfg;*.config;*.sf2;*.sf3)\0*.cfg;*.config;*.sf2;*.sf3\0"
58925911 "SoundFont ファイル (*.sf2)\0*.sf2;*.sf3\0"
58935912 "Config ファイル (*.cfg;*.config)\0*.cfg;*.config\0"
58945913 "すべてのファイル (*.*)\0*.*\0"
@@ -6097,6 +6116,76 @@ int w32g_gogo_id3_tag_dialog(void)
60976116 return 0;
60986117 }
60996118
6119+static void LoadCfgHistoryINI(HWND hwnd, int cb_id)
6120+{
6121+ TCHAR buffer1[FILEPATH_MAX + 1] = {0};
6122+ TCHAR buffer2[FILEPATH_MAX + 1] = {0};
6123+ LPCTSTR inifile = timidity_history_inifile;
6124+ int count = GetPrivateProfileInt(_T("cfg"), _T("count"), 0, inifile);
6125+ int i;
6126+
6127+ // remove old items
6128+ for (i = SendDlgItemMessage(hwnd, cb_id, CB_GETCOUNT, 0, 0) - 1; i >= 0; i--) {
6129+ SendDlgItemMessage(hwnd, cb_id, CB_DELETESTRING, i, 0);
6130+ }
6131+
6132+ if (count > MAX_CFG_HISTORY)
6133+ count = MAX_CFG_HISTORY;
6134+
6135+ for (i = 0; i < count; i++) {
6136+ _sntprintf(buffer1, FILEPATH_MAX, _T("item%02d"), i);
6137+ GetPrivateProfileString(_T("cfg"), buffer1, _T(""), buffer2, FILEPATH_MAX, inifile);
6138+
6139+ if (buffer2[0] != _T('\0')) {
6140+ CB_INSSTR(cb_id, buffer2);
6141+ }
6142+ }
6143+}
6144+
6145+static void SaveCfgHistoryINI(HWND hwnd, int cb_id)
6146+{
6147+ TCHAR buffer1[FILEPATH_MAX + 1] = {0};
6148+ TCHAR buffer2[FILEPATH_MAX + 1] = {0};
6149+ LPCTSTR inifile = timidity_history_inifile;
6150+ int count = SendDlgItemMessage(hwnd, cb_id, CB_GETCOUNT, 0, 0);
6151+ int i;
6152+ DWORD e;
6153+
6154+ _sntprintf(buffer1, FILEPATH_MAX, _T("%d"), count);
6155+ SetLastError(0);
6156+ WritePrivateProfileString(_T("cfg"), _T("count"), buffer1, inifile);
6157+
6158+ e = GetLastError();
6159+
6160+ for (i = 0; i < count; i++) {
6161+ _sntprintf(buffer1, FILEPATH_MAX, _T("item%02d"), i);
6162+
6163+ if (SendDlgItemMessage(hwnd, cb_id, CB_GETLBTEXTLEN, i, 0) < FILEPATH_MAX) {
6164+ SendDlgItemMessage(hwnd, cb_id, CB_GETLBTEXT, i, (LPARAM)buffer2);
6165+ WritePrivateProfileString(_T("cfg"), buffer1, buffer2, inifile);
6166+ }
6167+ }
6168+
6169+ WritePrivateProfileString(NULL, NULL, NULL, inifile); // flush
6170+}
6171+
6172+static void AddCurrentTextToCfgHistory(HWND hwnd, int cb_id)
6173+{
6174+ TCHAR buffer[FILEPATH_MAX + 1] = {0};
6175+ int index;
6176+
6177+ EB_GETTEXT(cb_id, buffer, FILEPATH_MAX);
6178+
6179+ index = SendDlgItemMessage(hwnd, cb_id, CB_FINDSTRINGEXACT, -1, (LPARAM)buffer);
6180+
6181+ if (index != CB_ERR)
6182+ SendDlgItemMessage(hwnd, cb_id, CB_DELETESTRING, index, 0);
6183+
6184+ SendDlgItemMessage(hwnd, cb_id, CB_INSERTSTRING, 0, buffer);
6185+ SendDlgItemMessage(hwnd, cb_id, CB_DELETESTRING, MAX_CFG_HISTORY, 0);
6186+ EB_SETTEXT(cb_id, buffer);
6187+}
6188+
61006189
61016190 //
61026191 //
@@ -8218,13 +8307,6 @@ static const TCHAR *cb_info_IDC_COMBO_PA_WASAPI_STREAM_CATEGORY[] = {
82188307 TEXT("Media"),
82198308 };
82208309
8221-#define cb_num_IDC_COMBO_PA_WASAPI_STREAM_OPTION 3
8222-static const TCHAR *cb_info_IDC_COMBO_PA_WASAPI_STREAM_OPTION[] = {
8223- TEXT("None"),
8224- TEXT("Raw"),
8225- TEXT("MatchFormat"),
8226-};
8227-
82288310
82298311 LRESULT WINAPI portaudioConfigDialogProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
82308312 {
@@ -8267,21 +8349,20 @@ LRESULT WINAPI portaudioConfigDialogProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM
82678349 DI_DISABLE(IDC_COMBO_PA_WASAPI_STREAM_CATEGORY);
82688350 }
82698351 // WASAPI StreamOption
8270- if(winver >= 6) // win10
8271- max = cb_num_IDC_COMBO_PA_WASAPI_STREAM_OPTION;
8272- else if(winver >= 4) // win8.1
8273- max = 2;
8274- else
8275- max = 1;
8276- for (i = 0; i < max; i++)
8277- CB_INSSTR(IDC_COMBO_PA_WASAPI_STREAM_OPTION, cb_info_IDC_COMBO_PA_WASAPI_STREAM_OPTION[i]);
8278- if(winver >= 6){ // win10
8279- CB_SET(IDC_COMBO_PA_WASAPI_STREAM_OPTION, (st_temp->pa_wasapi_stream_option));
8280- }else if(winver >= 4){ // win8.1
8281- CB_SET(IDC_COMBO_PA_WASAPI_STREAM_OPTION, (st_temp->pa_wasapi_stream_option >= 2 ? 0 : st_temp->pa_wasapi_stream_option));
8282- }else{
8283- CB_SET(IDC_COMBO_PA_WASAPI_STREAM_OPTION, 0);
8284- DI_DISABLE(IDC_COMBO_PA_WASAPI_STREAM_OPTION);
8352+ if (winver >= 6) { // win10
8353+ SendDlgItemMessage(hwnd, IDC_CHECKBOX_PA_WASAPI_STREAM_OPTIONS_RAW, BM_SETCHECK, (st_temp->pa_wasapi_stream_option & 1) ? BST_CHECKED : BST_UNCHECKED, 0);
8354+ SendDlgItemMessage(hwnd, IDC_CHECKBOX_PA_WASAPI_STREAM_OPTIONS_MATCH_FORMAT, BM_SETCHECK, (st_temp->pa_wasapi_stream_option & 2) ? BST_CHECKED : BST_UNCHECKED, 0);
8355+ SendDlgItemMessage(hwnd, IDC_CHECKBOX_PA_WASAPI_STREAM_OPTIONS_AMBISONICS, BM_SETCHECK, (st_temp->pa_wasapi_stream_option & 4) ? BST_CHECKED : BST_UNCHECKED, 0);
8356+ }
8357+ else if (winver >= 4) { // win8.1
8358+ SendDlgItemMessage(hwnd, IDC_CHECKBOX_PA_WASAPI_STREAM_OPTIONS_RAW, BM_SETCHECK, (st_temp->pa_wasapi_stream_option & 1) ? BST_CHECKED : BST_UNCHECKED, 0);
8359+ DI_DISABLE(IDC_CHECKBOX_PA_WASAPI_STREAM_OPTIONS_MATCH_FORMAT);
8360+ DI_DISABLE(IDC_CHECKBOX_PA_WASAPI_STREAM_OPTIONS_AMBISONICS);
8361+ }
8362+ else {
8363+ DI_DISABLE(IDC_CHECKBOX_PA_WASAPI_STREAM_OPTIONS_RAW);
8364+ DI_DISABLE(IDC_CHECKBOX_PA_WASAPI_STREAM_OPTIONS_MATCH_FORMAT);
8365+ DI_DISABLE(IDC_CHECKBOX_PA_WASAPI_STREAM_OPTIONS_AMBISONICS);
82858366 }
82868367
82878368
@@ -8449,7 +8530,13 @@ LRESULT WINAPI portaudioConfigDialogProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM
84498530 // WASAPI StreamCategory
84508531 st_temp->pa_wasapi_stream_category = CB_GET(IDC_COMBO_PA_WASAPI_STREAM_CATEGORY);
84518532 // WASAPI StreamOption
8452- st_temp->pa_wasapi_stream_option = CB_GET(IDC_COMBO_PA_WASAPI_STREAM_OPTION);
8533+ st_temp->pa_wasapi_stream_option = 0;
8534+ if (SendDlgItemMessage(hwnd, IDC_CHECKBOX_PA_WASAPI_STREAM_OPTIONS_RAW, BM_GETCHECK, 0, 0))
8535+ st_temp->pa_wasapi_stream_option |= 1;
8536+ if (SendDlgItemMessage(hwnd, IDC_CHECKBOX_PA_WASAPI_STREAM_OPTIONS_MATCH_FORMAT, BM_GETCHECK, 0, 0))
8537+ st_temp->pa_wasapi_stream_option |= 2;
8538+ if (SendDlgItemMessage(hwnd, IDC_CHECKBOX_PA_WASAPI_STREAM_OPTIONS_AMBISONICS, BM_GETCHECK, 0, 0))
8539+ st_temp->pa_wasapi_stream_option |= 4;
84538540
84548541 EndDialog(hwnd,TRUE);
84558542 break;
--- a/interface/w32g_pref.h
+++ b/interface/w32g_pref.h
@@ -1,6 +1,6 @@
11 /*
22 TiMidity++ -- MIDI to WAVE converter and player
3- Copyright (C) 1999-2018 Masanao Izumo <iz@onicos.co.jp>
3+ Copyright (C) 1999-2002 Masanao Izumo <mo@goice.co.jp>
44 Copyright (C) 1995 Tuukka Toivonen <tt@cgs.fi>
55
66 This program is free software; you can redistribute it and/or modify
@@ -22,17 +22,16 @@
2222 #define __W32G2_PREF_H__
2323
2424
25-extern void tmdy_free_config(void);
26-extern void timidity_start_initialize(void);
25+extern void tmdy_free_config(void);
26+extern void timidity_start_initialize(void);
2727 extern int read_config_file(char *name, int self, int allow_missing_file);
2828
2929 extern volatile int PrefWndDoing;
3030 void PrefWndCreate(HWND hwnd, UINT cid);
3131
32-
3332 typedef struct wave_ConfigDialogInfo_t {
34- char optIDC_EDIT_RIFFWAVE_UPDATE_STEP[1024 + 1];
35- int optIDC_CHECKBOX_RIFFWAVE_EXTENSIBLE;
33+ char optIDC_EDIT_RIFFWAVE_UPDATE_STEP[1024 + 1];
34+ int optIDC_CHECKBOX_RIFFWAVE_EXTENSIBLE;
3635 } wave_ConfigDialogInfo_t;
3736
3837 extern int wave_ConfigDialogInfoInit(void);
@@ -40,49 +39,50 @@ extern int wave_ConfigDialogInfoApply(void);
4039 extern int wave_ConfigDialogInfoSaveINI(void);
4140 extern int wave_ConfigDialogInfoLoadINI(void);
4241
42+extern int waveConfigDialog(void);
4343
4444 #ifdef AU_GOGO
4545
4646 // ダイアログの情報をほとんどそのまま保存する。
4747 // コンボボックスについては Index は無意味なので値を保存する。
4848 typedef struct gogo_ConfigDialogInfo_t_ {
49- int optIDC_CHECK_DEFAULT;
50- int optIDC_CHECK_COMMANDLINE_OPTS;
51- char optIDC_EDIT_COMMANDLINE_OPTION[1024+1];
52- int optIDC_CHECK_OUTPUT_FORMAT;
53- int optIDC_COMBO_OUTPUT_FORMAT;
54- int optIDC_CHECK_MPEG1AUDIOBITRATE;
55- int optIDC_COMBO_MPEG1_AUDIO_BITRATE;
56- int optIDC_CHECK_MPEG2AUDIOBITRATE;
57- int optIDC_COMBO_MPEG2_AUDIO_BITRATE;
58- int optIDC_CHECK_ENHANCED_LOW_PASS_FILTER;
59- char optIDC_EDIT_LPF_PARA1[4+1];
60- char optIDC_EDIT_LPF_PARA2[4+1];
61- int optIDC_CHECK_ENCODE_MODE;
62- int optIDC_COMBO_ENCODE_MODE;
63- int optIDC_CHECK_EMPHASIS_TYPE;
64- int optIDC_COMBO_EMPHASIS_TYPE;
65- int optIDC_CHECK_OUTFREQ;
66- char optIDC_EDIT_OUTFREQ[6+1];
67- int optIDC_CHECK_MSTHRESHOLD;
68- char optIDC_EDIT_MSTHRESHOLD_THRESHOLD[4+1];
69- char optIDC_EDIT_MSTHRESHOLD_MSPOWER[4+1];
70- int optIDC_CHECK_USE_CPU_OPTS;
71- int optIDC_CHECK_CPUMMX;
72- int optIDC_CHECK_CPUSSE;
73- int optIDC_CHECK_CPU3DNOW;
74- int optIDC_CHECK_CPUE3DNOW;
75- int optIDC_CHECK_CPUCMOV;
76- int optIDC_CHECK_CPUEMMX;
77- int optIDC_CHECK_CPUSSE2;
78- int optIDC_CHECK_VBR;
79- int optIDC_COMBO_VBR;
80- int optIDC_CHECK_VBR_BITRATE;
81- int optIDC_COMBO_VBR_BITRATE_LOW;
82- int optIDC_COMBO_VBR_BITRATE_HIGH;
83- int optIDC_CHECK_USEPSY;
84- int optIDC_CHECK_VERIFY;
85- int optIDC_CHECK_16KHZ_LOW_PASS_FILTER;
49+ int optIDC_CHECK_DEFAULT;
50+ int optIDC_CHECK_COMMANDLINE_OPTS;
51+ char optIDC_EDIT_COMMANDLINE_OPTION[1024+1];
52+ int optIDC_CHECK_OUTPUT_FORMAT;
53+ int optIDC_COMBO_OUTPUT_FORMAT;
54+ int optIDC_CHECK_MPEG1AUDIOBITRATE;
55+ int optIDC_COMBO_MPEG1_AUDIO_BITRATE;
56+ int optIDC_CHECK_MPEG2AUDIOBITRATE;
57+ int optIDC_COMBO_MPEG2_AUDIO_BITRATE;
58+ int optIDC_CHECK_ENHANCED_LOW_PASS_FILTER;
59+ char optIDC_EDIT_LPF_PARA1[4+1];
60+ char optIDC_EDIT_LPF_PARA2[4+1];
61+ int optIDC_CHECK_ENCODE_MODE;
62+ int optIDC_COMBO_ENCODE_MODE;
63+ int optIDC_CHECK_EMPHASIS_TYPE;
64+ int optIDC_COMBO_EMPHASIS_TYPE;
65+ int optIDC_CHECK_OUTFREQ;
66+ char optIDC_EDIT_OUTFREQ[6+1];
67+ int optIDC_CHECK_MSTHRESHOLD;
68+ char optIDC_EDIT_MSTHRESHOLD_THRESHOLD[4+1];
69+ char optIDC_EDIT_MSTHRESHOLD_MSPOWER[4+1];
70+ int optIDC_CHECK_USE_CPU_OPTS;
71+ int optIDC_CHECK_CPUMMX;
72+ int optIDC_CHECK_CPUSSE;
73+ int optIDC_CHECK_CPU3DNOW;
74+ int optIDC_CHECK_CPUE3DNOW;
75+ int optIDC_CHECK_CPUCMOV;
76+ int optIDC_CHECK_CPUEMMX;
77+ int optIDC_CHECK_CPUSSE2;
78+ int optIDC_CHECK_VBR;
79+ int optIDC_COMBO_VBR;
80+ int optIDC_CHECK_VBR_BITRATE;
81+ int optIDC_COMBO_VBR_BITRATE_LOW;
82+ int optIDC_COMBO_VBR_BITRATE_HIGH;
83+ int optIDC_CHECK_USEPSY;
84+ int optIDC_CHECK_VERIFY;
85+ int optIDC_CHECK_16KHZ_LOW_PASS_FILTER;
8686 } gogo_ConfigDialogInfo_t;
8787
8888 extern volatile gogo_ConfigDialogInfo_t gogo_ConfigDialogInfo;
@@ -98,12 +98,12 @@ extern int gogo_ConfigDialogInfoLoadINI(void);
9898 #ifdef AU_VORBIS
9999
100100 typedef struct vorbis_ConfigDialogInfo_t_ {
101- int optIDC_CHECK_DEFAULT;
102- int optIDC_COMBO_MODE;
103- int optIDC_CHECK_USE_TAG;
104- char optIDC_EDIT1[256];
105- char optIDC_EDIT2[256];
106- char optIDC_EDIT3[256];
101+ int optIDC_CHECK_DEFAULT;
102+ int optIDC_COMBO_MODE;
103+ int optIDC_CHECK_USE_TAG;
104+ char optIDC_EDIT1[256];
105+ char optIDC_EDIT2[256];
106+ char optIDC_EDIT3[256];
107107 } vorbis_ConfigDialogInfo_t;
108108
109109 extern int vorbis_ConfigDialogInfoInit(void);
@@ -117,7 +117,7 @@ extern int vorbis_ConfigDialogInfoLoadINI(void);
117117 #ifdef AU_LAME
118118
119119 typedef struct lame_ConfigDialogInfo_t_ {
120- int optIDC_LAME_CBPRESET;
120+ int optIDC_LAME_CBPRESET;
121121 } lame_ConfigDialogInfo_t;
122122
123123 extern int lame_encode_preset;
@@ -133,8 +133,8 @@ extern int lame_ConfigDialogInfoLoadINI(void);
133133 #ifdef AU_FLAC
134134
135135 typedef struct flac_ConfigDialogInfo_t_ {
136- int optIDC_COMBO_ENCODE_MODE;
137- int optIDC_CHECKBOX_OGGFLAC_CONTAINER;
136+ int optIDC_COMBO_ENCODE_MODE;
137+ int optIDC_CHECKBOX_OGGFLAC_CONTAINER;
138138 } flac_ConfigDialogInfo_t;
139139
140140 extern int flac_ConfigDialogInfoInit(void);
@@ -148,6 +148,7 @@ extern int flac_ConfigDialogInfoLoadINI(void);
148148 #ifdef AU_OPUS
149149
150150 typedef struct opus_ConfigDialogInfo_t_ {
151+ char unused;
151152 } opus_ConfigDialogInfo_t;
152153
153154 extern int opus_ConfigDialogInfoInit(void);
@@ -161,6 +162,7 @@ extern int opus_ConfigDialogInfoLoadINI(void);
161162 #ifdef AU_SPEEX
162163
163164 typedef struct speex_ConfigDialogInfo_t_ {
165+ char unused;
164166 } speex_ConfigDialogInfo_t;
165167
166168 extern int speex_ConfigDialogInfoInit(void);
--- a/pdcurses/pdcurses.vcxproj
+++ b/pdcurses/pdcurses.vcxproj
@@ -170,7 +170,7 @@
170170 <ExceptionHandling>
171171 </ExceptionHandling>
172172 <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
173- <StructMemberAlignment>8Bytes</StructMemberAlignment>
173+ <StructMemberAlignment>16Bytes</StructMemberAlignment>
174174 <BufferSecurityCheck>false</BufferSecurityCheck>
175175 <FunctionLevelLinking>true</FunctionLevelLinking>
176176 <PrecompiledHeaderFile>..\config.h</PrecompiledHeaderFile>
--- a/sf_view_gui/CMakeLists.txt
+++ b/sf_view_gui/CMakeLists.txt
@@ -2,6 +2,7 @@
22 add_definitions(
33 -DCFG_FOR_SF
44 -DSF2VIEWER_GUI
5+ -DENABLE_DLS
56 )
67
78 add_executable(
@@ -10,55 +11,20 @@ add_executable(
1011 mysndfont.c
1112 OpenDlg.cpp
1213 sfview_main.cpp
13- ../interface/dumb_c.c
14- ../timidity/common.c
15- ../timidity/controls.c
16- ../timidity/envelope.c
17- ../timidity/filter.c
18- ../timidity/freq.c
19- ../timidity/instrum.c
20- ../timidity/int_synth.c
21- ../timidity/mt19937ar.c
14+ ../timidity/dls.cpp
2215 ../timidity/myini.c
23- ../timidity/quantity.c
24- ../timidity/resample.c
25- ../timidity/sbkconv.c
26- ../timidity/sffile.c
27- ../timidity/sfitem.c
28- ../timidity/smplfile.c
29- ../timidity/tables.c
30- ../timidity/version.c
3116
3217 OpenDlg.h
3318 resource.h
34- ../libarc/arc.h
35- ../timidity/common.h
36- ../timidity/controls.h
37- ../timidity/envelope.h
38- ../timidity/filter.h
39- ../timidity/instrum.h
40- ../timidity/int_synth.h
41- ../timidity/mt19937ar.h
19+ ../timidity/dls.h
4220 ../timidity/myini.h
43- ../timidity/output.h
44- ../timidity/playmidi.h
45- ../timidity/quantity.h
46- ../timidity/readmidi.h
47- ../timidity/resample.h
48- ../timidity/sffile.h
49- ../timidity/sfitem.h
50- ../timidity/sflayer.h
51- ../timidity/tables.h
52- ../timidity/timidity.h
53- ../timidity/wrd.h
54- ../utils/mblock.h
55- ../utils/support.h
5621
5722 sfview_dlg.rc
5823
24+ $<TARGET_OBJECTS:timidity_cfgforsf>
5925 $<TARGET_OBJECTS:libarc>
6026 $<TARGET_OBJECTS:utils>
6127 )
6228
6329 add_dependencies(sfviewer UpdateTim41Version)
64-target_link_libraries(sfviewer comctl32 shlwapi winmm ws2_32)
30+target_link_libraries(sfviewer comctl32 shlwapi ws2_32)
--- a/sf_view_gui/mysndfont.c
+++ b/sf_view_gui/mysndfont.c
@@ -5,8 +5,14 @@
55 #pragma warning(disable:4133)
66 #pragma warning(disable:4028)
77 #define main _dummy_main
8+#include <windows.h>
89 #include "sndfont.c"
910 #include "myini.h"
11+
12+#ifdef ENABLE_DLS
13+#include "dls.h"
14+#endif
15+
1016 #pragma warning(pop)
1117
1218 void sfgui_str_free(void **p)
@@ -21,8 +27,23 @@ void sfgui_str_free(void **p)
2127 #include <shlwapi.h>
2228 #include "resource.h"
2329
24-void InsertInst(int bank, int preset, const char *str, const char *sfname);
25-void InsertDrum(int bank, int preset, int note, const char *str, const char *sfname);
30+void InsertInst(BOOL dls, int bank, int preset, const char *str, const char *sfname);
31+void InsertDrum(BOOL dls, int bank, int preset, int note, const char *str, const char *sfname);
32+
33+BOOL IsDLSFile(LPCSTR filename)
34+{
35+ struct timidity_file *tf = open_file(filename, 1, OF_NORMAL);
36+ char buf[12];
37+ BOOL isDLS = FALSE;
38+
39+ if (tf_read(buf, 1, 12, tf) == 12 && memcmp(&buf[0], "RIFF", 4) == 0 && memcmp(&buf[8], "DLS ", 4) == 0) {
40+ isDLS = TRUE;
41+ }
42+
43+ close_file(tf);
44+ return isDLS;
45+}
46+
2647 void CreateSoundFontTree(HWND hDlg, LPCSTR x_sf_filename_)
2748 {
2849 HWND hTree = GetDlgItem(hDlg, IDC_TREE1);
@@ -38,10 +59,6 @@ void CreateSoundFontTree(HWND hDlg, LPCSTR x_sf_filename_)
3859
3960 //TreeView_DeleteAllItems(hTree);
4061
41- if (_stricmp(PathFindExtension(x_sf_filename_), ".sf2")) {
42- return;
43- }
44-
4562 for (x_bank = 0; x_bank <= 127; x_bank++) {
4663 for (x_preset = 0; x_preset <= 127; x_preset++) {
4764 x_cfg_info.m_str[x_bank][x_preset] = NULL;
@@ -99,126 +116,190 @@ void CreateSoundFontTree(HWND hDlg, LPCSTR x_sf_filename_)
99116 init_bend_coarse();
100117 initialize_resampler_coeffs();
101118 control_ratio = play_mode->rate / CONTROLS_PER_SECOND;
102- sf = new_soundfont(x_sf_file_name);
103- sf->next = NULL;
104- sf->def_order = 2;
105- sfrecs = sf;
106- x_cfg_info_init();
107- init_sf(sf);
108- if (x_sort) {
109- for (x_bank = 0; x_bank <= 127; x_bank++) {
110- flag = 0;
111-
112- for (x_preset = 0; x_preset <= 127; x_preset++) {
113- if (x_cfg_info.m_bank[x_bank][x_preset] >= 0 && x_cfg_info.m_preset[x_bank][x_preset] >= 0) {
114- flag = 1;
115- }
116- }
117- if (!flag)
118- continue;
119- if (!initial) {
120- initial = 1;
121- }
122119
123- // insert bank
124- tv.hInsertAfter = TVI_LAST;
125- tv.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
126- tv.hParent = hBank;
127- sprintf(str_, "Bank %03d", x_bank);
128- tv.item.pszText = str_;
129- tv.item.iImage = 0;
130- tv.item.iSelectedImage = 1;
131- hBankSub = TreeView_InsertItem(hTree, &tv);
120+ if (IsDLSFile(x_sf_filename_)) {
121+#ifdef ENABLE_DLS
122+ DLSCollectionInfo *list = get_dls_instrument_list(x_sf_filename_);
123+ if (list) {
124+ for (int i = 0; i < list->bank_count; i++) {
125+ DLSBankInfo *b = &list->banks[i];
132126
133- for (x_preset = 0; x_preset <= 127; x_preset++) {
134- if (x_cfg_info.m_bank[x_bank][x_preset] >= 0 && x_cfg_info.m_preset[x_bank][x_preset] >= 0) {
135-
136- // insert bank
137127 tv.hInsertAfter = TVI_LAST;
138128 tv.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
139- tv.hParent = hBankSub;
129+ tv.hParent = hBank;
130+ sprintf(str_, "Bank %03u", b->bank);
131+ tv.item.pszText = str_;
132+ tv.item.iImage = 0;
133+ tv.item.iSelectedImage = 1;
134+ hBankSub = TreeView_InsertItem(hTree, &tv);
135+
136+ for (int j = 0; j < b->program_count; j++) {
137+ DLSProgramInfo *p = &b->programs[j];
138+
139+ tv.hInsertAfter = TVI_LAST;
140+ tv.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
141+ tv.hParent = hBankSub;
142+ sprintf(str_, "%03u:%03u %s", b->bank, p->program, p->name);
143+ tv.item.pszText = str_;
144+ tv.item.iImage = 2;
145+ tv.item.iSelectedImage = 3;
146+ TreeView_InsertItem(hTree, &tv);
147+
148+ InsertInst(TRUE, b->bank, p->program, p->name, x_sf_filename_);
149+ }
150+ }
140151
141- pname_ =sf_preset_name[x_bank][x_preset];
142-// if (x_cfg_info.m_rom[x_bank][x_preset])
143-// sprintf(str_, "%03d:%03d[ROM] %s\0\0", x_bank, x_preset, pname_);
144-// else
145- sprintf(str_, "%03d:%03d %s\0\0", x_bank, x_preset, pname_);
152+ for (int i = 0; i < list->drumset_count; i++) {
153+ DLSDrumsetInfo *d = &list->drumsets[i];
146154
155+ tv.hInsertAfter = TVI_LAST;
156+ tv.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
157+ tv.hParent = hDrum;
158+ sprintf(str_, "Drumset %03u (%s)", d->program, d->name);
147159 tv.item.pszText = str_;
148- tv.item.cchTextMax = strlen(str_);
149- tv.item.iImage = 2;
150- tv.item.iSelectedImage = 3;
151- TreeView_InsertItem(hTree, &tv);
152-
153- InsertInst(x_bank, x_preset, pname_, x_sf_filename_);
160+ tv.item.iImage = 0;
161+ tv.item.iSelectedImage = 1;
162+ hDrumSub = TreeView_InsertItem(hTree, &tv);
163+
164+ for (int j = 0; j < d->note_count; j++) {
165+ tv.hInsertAfter = TVI_LAST;
166+ tv.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
167+ tv.hParent = hDrumSub;
168+ sprintf(str_, "%03u:%03u", d->program, d->notes[j]);
169+ tv.item.pszText = str_;
170+ tv.item.iImage = 2;
171+ tv.item.iSelectedImage = 3;
172+ TreeView_InsertItem(hTree, &tv);
173+
174+ InsertDrum(TRUE, 128, d->program, d->notes[j], "", x_sf_filename_);
175+ }
154176 }
155177
178+ free_dls_instrument_list(list);
156179 }
157- }
158- for (x_preset = 0; x_preset <= 127; x_preset++) {
159- flag = 0;
160- for (x_keynote = 0; x_keynote <= 127; x_keynote++) {
161- if (x_cfg_info.d_preset[x_preset][x_keynote] >= 0 && x_cfg_info.d_keynote[x_preset][x_keynote] >= 0) {
162- flag = 1;
163- }
164- }
165- if (!flag)
166- continue;
167- if (!initial) {
168- initial = 1;
169-// fprintf(x_out, "drumset %d\n", x_preset);
170- } else {
171-// fprintf(x_out, "\ndrumset %d\n", x_preset);
172- }
173-
174- // insert bank
175- tv.hInsertAfter = TVI_LAST;
176- tv.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
177- tv.hParent = hDrum;
178- sprintf(str_, "Drumset %03d (%s)", x_preset, sf_preset_name[128][x_preset]);
179- tv.item.pszText = str_;
180- tv.item.iImage = 0;
181- tv.item.iSelectedImage = 1;
182- hDrumSub = TreeView_InsertItem(hTree, &tv);
183-
184- for (x_keynote = 0; x_keynote <= 127; x_keynote++) {
185- if (x_cfg_info.d_preset[x_preset][x_keynote] >= 0 && x_cfg_info.d_keynote[x_preset][x_keynote] >= 0) {
180+#endif
181+ } else {
182+ sf = new_soundfont(x_sf_file_name);
183+ sf->next = NULL;
184+ sf->def_order = 2;
185+ sfrecs = sf;
186+ x_cfg_info_init();
187+ init_sf(sf);
188+ if (x_sort) {
189+ for (x_bank = 0; x_bank <= 127; x_bank++) {
190+ flag = 0;
191+
192+ for (x_preset = 0; x_preset <= 127; x_preset++) {
193+ if (x_cfg_info.m_bank[x_bank][x_preset] >= 0 && x_cfg_info.m_preset[x_bank][x_preset] >= 0) {
194+ flag = 1;
195+ }
196+ }
197+ if (!flag)
198+ continue;
199+ if (!initial) {
200+ initial = 1;
201+ }
186202
187203 // insert bank
188204 tv.hInsertAfter = TVI_LAST;
189205 tv.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
190- tv.hParent = hDrumSub;
191-
192- pname_b_ = strtok(x_cfg_info.d_str[x_preset][x_keynote], "#");
193- if (pname_b_) {
194- if ((pname_ = strstr(pname_b_, ":")) == NULL)
195- pname_ = pname_b_;
196- else pname_ = "";
197- } else pname_ = "";
198-
199-// if (x_cfg_info.d_rom[x_preset][x_keynote])
200-// sprintf(str_, "Bank%03d Note%03d[ROM] %s\0\0", x_preset, x_keynote, pname_);
201-// else
202- sprintf(str_, "%03d:%03d %s\0\0", x_preset, x_keynote, pname_);
206+ tv.hParent = hBank;
207+ sprintf(str_, "Bank %03d", x_bank);
208+ tv.item.pszText = str_;
209+ tv.item.iImage = 0;
210+ tv.item.iSelectedImage = 1;
211+ hBankSub = TreeView_InsertItem(hTree, &tv);
212+
213+ for (x_preset = 0; x_preset <= 127; x_preset++) {
214+ if (x_cfg_info.m_bank[x_bank][x_preset] >= 0 && x_cfg_info.m_preset[x_bank][x_preset] >= 0) {
215+
216+ // insert bank
217+ tv.hInsertAfter = TVI_LAST;
218+ tv.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
219+ tv.hParent = hBankSub;
220+
221+ pname_ =sf_preset_name[x_bank][x_preset];
222+ // if (x_cfg_info.m_rom[x_bank][x_preset])
223+ // sprintf(str_, "%03d:%03d[ROM] %s\0\0", x_bank, x_preset, pname_);
224+ // else
225+ sprintf(str_, "%03d:%03d %s\0\0", x_bank, x_preset, pname_);
226+
227+ tv.item.pszText = str_;
228+ tv.item.cchTextMax = strlen(str_);
229+ tv.item.iImage = 2;
230+ tv.item.iSelectedImage = 3;
231+ TreeView_InsertItem(hTree, &tv);
232+
233+ InsertInst(FALSE, x_bank, x_preset, pname_, x_sf_filename_);
234+ }
235+
236+ }
237+ }
238+ for (x_preset = 0; x_preset <= 127; x_preset++) {
239+ flag = 0;
240+ for (x_keynote = 0; x_keynote <= 127; x_keynote++) {
241+ if (x_cfg_info.d_preset[x_preset][x_keynote] >= 0 && x_cfg_info.d_keynote[x_preset][x_keynote] >= 0) {
242+ flag = 1;
243+ }
244+ }
245+ if (!flag)
246+ continue;
247+ if (!initial) {
248+ initial = 1;
249+ // fprintf(x_out, "drumset %d\n", x_preset);
250+ } else {
251+ // fprintf(x_out, "\ndrumset %d\n", x_preset);
252+ }
203253
254+ // insert bank
255+ tv.hInsertAfter = TVI_LAST;
256+ tv.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
257+ tv.hParent = hDrum;
258+ sprintf(str_, "Drumset %03d (%s)", x_preset, sf_preset_name[128][x_preset]);
204259 tv.item.pszText = str_;
205- tv.item.cchTextMax = strlen(str_);
206- tv.item.iImage = 2;
207- tv.item.iSelectedImage = 3;
208- TreeView_InsertItem(hTree, &tv);
209- InsertDrum(128, x_preset, x_keynote, pname_, x_sf_filename_);
260+ tv.item.iImage = 0;
261+ tv.item.iSelectedImage = 1;
262+ hDrumSub = TreeView_InsertItem(hTree, &tv);
263+
264+ for (x_keynote = 0; x_keynote <= 127; x_keynote++) {
265+ if (x_cfg_info.d_preset[x_preset][x_keynote] >= 0 && x_cfg_info.d_keynote[x_preset][x_keynote] >= 0) {
266+
267+ // insert bank
268+ tv.hInsertAfter = TVI_LAST;
269+ tv.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
270+ tv.hParent = hDrumSub;
271+
272+ pname_b_ = strtok(x_cfg_info.d_str[x_preset][x_keynote], "#");
273+ if (pname_b_) {
274+ if ((pname_ = strstr(pname_b_, ":")) == NULL)
275+ pname_ = pname_b_;
276+ else pname_ = "";
277+ } else pname_ = "";
278+
279+ // if (x_cfg_info.d_rom[x_preset][x_keynote])
280+ // sprintf(str_, "Bank%03d Note%03d[ROM] %s\0\0", x_preset, x_keynote, pname_);
281+ // else
282+ sprintf(str_, "%03d:%03d %s\0\0", x_preset, x_keynote, pname_);
283+
284+ tv.item.pszText = str_;
285+ tv.item.cchTextMax = strlen(str_);
286+ tv.item.iImage = 2;
287+ tv.item.iSelectedImage = 3;
288+ TreeView_InsertItem(hTree, &tv);
289+ InsertDrum(FALSE, 128, x_preset, x_keynote, pname_, x_sf_filename_);
290+ }
291+ }
210292 }
211293 }
212- }
213- }
214294
215- for (x_bank = 0; x_bank <= 127; x_bank++) {
216- for (x_preset = 0; x_preset <= 127; x_preset++) {
217- sfgui_str_free(&x_cfg_info.m_str[x_bank][x_preset]);
218- sfgui_str_free(&x_cfg_info.d_str[x_bank][x_preset]);
295+ for (x_bank = 0; x_bank <= 127; x_bank++) {
296+ for (x_preset = 0; x_preset <= 127; x_preset++) {
297+ sfgui_str_free(&x_cfg_info.m_str[x_bank][x_preset]);
298+ sfgui_str_free(&x_cfg_info.d_str[x_bank][x_preset]);
299+ }
219300 }
301+ end_soundfont(sf);
220302 }
221- end_soundfont(sf);
222303
223304 TreeView_Expand(hTree, hSF2, TVE_EXPAND);
224305 TreeView_Expand(hTree, hBank, TVE_EXPAND);
--- a/sf_view_gui/resource.h
+++ b/sf_view_gui/resource.h
@@ -8,8 +8,8 @@
88 #define IDB_BITMAP1 104
99 #define IDB_TREEICON 104
1010 #define IDC_TREE1 1001
11-#define IDC_EDIT1 1002
1211 #define IDC_EDSFNAME 1002
12+#define IDC_EDSFLABEL 1003
1313 #define ID_FILE_OPENSOUNDFONT 40001
1414 #define ID_FILE_QUIT 40002
1515 #define ID_FILE_SAVETIMIDITYCONFIGFILE 40003
@@ -22,14 +22,15 @@
2222 #define IDM_OPT_APPEND_COMMENT 40010
2323 #define IDM_OPT_APPEND_FSPACES 40011
2424 #define IDM_OPT_KEEP_FULLPATH 40012
25+#define IDM_OPT_PREPEND_BASEDIR 40013
2526
2627 // Next default values for new objects
2728 //
2829 #ifdef APSTUDIO_INVOKED
2930 #ifndef APSTUDIO_READONLY_SYMBOLS
3031 #define _APS_NEXT_RESOURCE_VALUE 105
31-#define _APS_NEXT_COMMAND_VALUE 40013
32-#define _APS_NEXT_CONTROL_VALUE 1003
32+#define _APS_NEXT_COMMAND_VALUE 40014
33+#define _APS_NEXT_CONTROL_VALUE 1004
3334 #define _APS_NEXT_SYMED_VALUE 101
3435 #endif
3536 #endif
--- a/sf_view_gui/sfview_dlg.rc
+++ b/sf_view_gui/sfview_dlg.rc
@@ -23,11 +23,12 @@ BEGIN
2323 MENUITEM "Append first spaces(&P)", IDM_OPT_APPEND_FSPACES
2424 MENUITEM SEPARATOR
2525 MENUITEM "Keep original full-path(&K)", IDM_OPT_KEEP_FULLPATH
26+ MENUITEM "Prepend ""dir ${basedir}""(&D)", IDM_OPT_PREPEND_BASEDIR
2627 END
2728 END
2829
2930 101 DIALOGEX 0, 0, 255, 195
30-STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU
31+STYLE WS_OVERLAPPEDWINDOW
3132 EXSTYLE WS_EX_ACCEPTFILES
3233 CAPTION "Soundfont Viewer 1.01"
3334 MENU IDR_MENU1
@@ -35,7 +36,7 @@ LANGUAGE LANG_JAPANESE, 0x1
3536 FONT 9, "MS UI Gothic", FW_NORMAL, 0, 128
3637 BEGIN
3738 CONTROL "", IDC_TREE1, WC_TREEVIEW, WS_TABSTOP | WS_HSCROLL | WS_BORDER | TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT, 0, 0, 255, 182
38- LTEXT "Soundfont Path", -1, 0, 183, 56, 12, SS_LEFT
39+ LTEXT "Soundfont Path", IDC_EDSFLABEL, 0, 183, 56, 12, SS_LEFT
3940 EDITTEXT IDC_EDSFNAME, 57, 183, 198, 12, NOT WS_BORDER | ES_AUTOHSCROLL | ES_READONLY
4041 END
4142
--- a/sf_view_gui/sfview_main.cpp
+++ b/sf_view_gui/sfview_main.cpp
@@ -3,6 +3,7 @@
33 #define _CRT_SECURE_NO_WARNINGS
44 #pragma warning(disable:4530) // アンワインド セマンティクスが無効
55 #include <windows.h>
6+#include <windowsx.h>
67 #include <commctrl.h>
78 #include "resource.h"
89 #pragma comment(lib, "shlwapi.lib")
@@ -17,6 +18,7 @@ extern "C" {
1718 #include <string>
1819 struct sfvSFInst
1920 {
21+ BOOL dls;
2022 unsigned char bank;
2123 unsigned char preset;
2224 std::string str;
@@ -25,6 +27,7 @@ struct sfvSFInst
2527 std::map< int, std::map< int, sfvSFInst > > g_sfInst;
2628 struct sfvSFDrum
2729 {
30+ BOOL dls;
2831 unsigned char bank;
2932 unsigned char preset;
3033 unsigned char note;
@@ -33,12 +36,13 @@ struct sfvSFDrum
3336 };
3437 std::map< int, std::map< int, sfvSFDrum > > g_sfDrum;
3538
36-extern "C" void InsertInst(int bank, int preset, char *str, const char *sfname)
39+extern "C" void InsertInst(BOOL dls, int bank, int preset, char *str, const char *sfname)
3740 {
3841 std::map< int, std::map< int, sfvSFInst > >::iterator it = g_sfInst.find(bank);
3942 if (it != g_sfInst.end()) {
4043
4144 sfvSFInst newdata;
45+ newdata.dls = dls;
4246 newdata.bank = bank;
4347 newdata.preset = preset;
4448 newdata.str = sfname;
@@ -52,16 +56,17 @@ extern "C" void InsertInst(int bank, int preset, char *str, const char *sfname)
5256 }
5357 } else {
5458 g_sfInst.insert(std::make_pair(bank, std::map< int, sfvSFInst >()));
55- InsertInst(bank, preset, str, sfname);
59+ InsertInst(dls, bank, preset, str, sfname);
5660 }
5761 }
5862
59-extern "C" void InsertDrum(int bank, int preset, int note, const char *str, const char *sfname)
63+extern "C" void InsertDrum(BOOL dls, int bank, int preset, int note, const char *str, const char *sfname)
6064 {
6165 std::map< int, std::map< int, sfvSFDrum > >::iterator it = g_sfDrum.find(preset);
6266 if (it != g_sfDrum.end()) {
6367
6468 sfvSFDrum newdata;
69+ newdata.dls = dls;
6570 newdata.bank = bank;
6671 newdata.preset = preset;
6772 newdata.note = note;
@@ -76,19 +81,21 @@ extern "C" void InsertDrum(int bank, int preset, int note, const char *str, cons
7681 }
7782 } else {
7883 g_sfDrum.insert(std::make_pair(preset, std::map< int, sfvSFDrum >()));
79- InsertDrum(bank, preset, note, str, sfname);
84+ InsertDrum(dls, bank, preset, note, str, sfname);
8085 }
8186 }
8287
83-void SFView_ExportConfigFile(char *outFileName, int outListEnable, int outComment, int outSpace, int keepFullPath)
88+void SFView_ExportConfigFile(char *outFileName, int outListEnable, int outComment, int outSpace, int keepFullPath, int prependBaseDir)
8489 {
8590 FILE *fp = fopen(outFileName, "w");
91+ if (!outListEnable && prependBaseDir)
92+ fprintf(fp, "\ndir \"${basedir}\"\n");
8693 for (std::map< int, std::map< int, sfvSFInst > >::iterator it = g_sfInst.begin(); it != g_sfInst.end(); ++it) {
87- if (outListEnable)
88- fprintf(fp, "bank %d\n", (*it).first);
89- else
90- fprintf(fp, "bank %d\n", (*it).first);
94+ if (!outListEnable)
95+ fprintf(fp, "\n");
96+ fprintf(fp, "bank %d\n", (*it).first);
9197 for (std::map< int, sfvSFInst >::iterator itc = (*it).second.begin(); itc != (*it).second.end(); ++itc) {
98+ BOOL dls = (*itc).second.dls;
9299 const char *file = (*itc).second.str.c_str();
93100 const int program = (*itc).first;
94101 const int bank = (*itc).second.bank;
@@ -102,22 +109,22 @@ void SFView_ExportConfigFile(char *outFileName, int outListEnable, int outCommen
102109 fprintf(fp, "%03d:%03d %s (%s)\n", bank, preset, comment, file);
103110 else {
104111 if (strstr(file, " "))
105- fprintf(fp, "%d %%font \"%s\" %d %d", program, file, bank, preset);
112+ fprintf(fp, "%d %s \"%s\" %d %d", program, (dls ? "%dls" : "%font"), file, bank, preset);
106113 else
107- fprintf(fp, "%d %%font %s %d %d", program, file, bank, preset);
108- if (outComment)
109- fprintf(fp, " # %s ", comment);
114+ fprintf(fp, "%d %s %s %d %d", program, (dls ? "%dls" : "%font"), file, bank, preset);
115+ if (outComment && comment && strlen(comment))
116+ fprintf(fp, " # %s", comment);
110117 fprintf(fp, "\n");
111118 }
112119 }
113120 }
114121
115122 for (std::map< int, std::map< int, sfvSFDrum > >::iterator it = g_sfDrum.begin(); it != g_sfDrum.end(); ++it) {
116- if (outListEnable)
117- fprintf(fp, "drumset %d\n", (*it).first);
118- else
119- fprintf(fp, "drumset %d\n", (*it).first);
123+ if (!outListEnable)
124+ fprintf(fp, "\n");
125+ fprintf(fp, "drumset %d\n", (*it).first);
120126 for (std::map< int, sfvSFDrum >::iterator itc = (*it).second.begin(); itc != (*it).second.end(); ++itc) {
127+ BOOL dls = (*itc).second.dls;
121128 const char *file = (*itc).second.str.c_str();
122129 const int program = (*itc).first;
123130 const int bank = (*itc).second.bank;
@@ -132,11 +139,11 @@ void SFView_ExportConfigFile(char *outFileName, int outListEnable, int outCommen
132139 fprintf(fp, "%03d:%03d %s (%s)\n", preset, note, comment, file);
133140 else {
134141 if (strstr(file, " "))
135- fprintf(fp, "%d %%font \"%s\" %d %d %d", program, file, bank, preset, note);
142+ fprintf(fp, "%d %s \"%s\" %d %d %d", program, (dls ? "%dls" : "%font"), file, bank, preset, note);
136143 else
137- fprintf(fp, "%d %%font %s %d %d %d", program, file, bank, preset, note);
138- if (outComment)
139- fprintf(fp, " # %s ", comment);
144+ fprintf(fp, "%d %s %s %d %d %d", program, (dls ? "%dls" : "%font"), file, bank, preset, note);
145+ if (outComment && comment && strlen(comment))
146+ fprintf(fp, " # %s", comment);
140147 fprintf(fp, "\n");
141148 }
142149 }
@@ -152,8 +159,8 @@ void ExportFile(HWND hDlg, bool bExportList)
152159 {
153160 MENUITEMINFO mii = { sizeof(MENUITEMINFO) };
154161 HMENU hMenu = GetMenu(hDlg);
155- CONST UINT menuIDs[] = { IDM_OPT_APPEND_COMMENT, IDM_OPT_APPEND_FSPACES, IDM_OPT_KEEP_FULLPATH };
156- BOOL states[] = { FALSE, FALSE, FALSE };
162+ CONST UINT menuIDs[] = { IDM_OPT_APPEND_COMMENT, IDM_OPT_APPEND_FSPACES, IDM_OPT_KEEP_FULLPATH, IDM_OPT_PREPEND_BASEDIR};
163+ BOOL states[] = { FALSE, FALSE, FALSE, FALSE };
157164 CMyFileDialog fd;
158165 fd.setSaveDlgDefaultSetting();
159166 fd.setTitle("Export filename ..");
@@ -172,13 +179,15 @@ void ExportFile(HWND hDlg, bool bExportList)
172179 fd.setDefaultExt("cfg");
173180 fd.setFilter("TiMidity++ Config File (*.cfg)\0*.cfg\0\0");
174181 }
175- if (fd.Execute()) {
176- SFView_ExportConfigFile((char*)fd.getFile(0),
177- (int)bExportList,
178- (int)states[0],
179- (int)states[1],
180- (int)states[2]);
181- }
182+ if (fd.Execute()) {
183+ SFView_ExportConfigFile((char*)fd.getFile(0),
184+ (int)bExportList,
185+ (int)states[0],
186+ (int)states[1],
187+ (int)states[2],
188+ (int)states[3]
189+ );
190+ }
182191 }
183192
184193 HIMAGELIST g_hil = NULL;
@@ -188,8 +197,8 @@ LRESULT DlgMainProc_INITDIALOG(HWND hDlg, WPARAM wParam, LPARAM lParam)
188197 {
189198 MENUITEMINFO mii = { sizeof(MENUITEMINFO) };
190199 HMENU hMenu = GetMenu(hDlg);
191- CONST UINT menuIDs[] = { IDM_OPT_APPEND_COMMENT, IDM_OPT_APPEND_FSPACES, IDM_OPT_KEEP_FULLPATH };
192- CONST UINT states[] = { MFS_UNCHECKED, MFS_UNCHECKED, MFS_CHECKED };
200+ CONST UINT menuIDs[] = { IDM_OPT_APPEND_COMMENT, IDM_OPT_APPEND_FSPACES, IDM_OPT_KEEP_FULLPATH, IDM_OPT_PREPEND_BASEDIR};
201+ CONST UINT states[] = { MFS_CHECKED, MFS_UNCHECKED, MFS_UNCHECKED, MFS_CHECKED };
193202
194203 if (__argc == 2) {
195204 ResetSoundFontTree(hDlg);
@@ -247,7 +256,18 @@ LRESULT DlgMainProc_COMMAND(HWND hDlg, WPARAM wParam, LPARAM lParam)
247256 CMyFileDialog fd;
248257 fd.setOpenDlgDefaultSetting();
249258 fd.setTitle("open soundfont");
250- fd.setFilter("soundfont (*.sf2;*.sf3)\0*.sf2;*.sf3\0All files (*.*)\0*.*\0\0");
259+ fd.setFilter(
260+#ifdef ENABLE_DLS
261+ "Supported files (*.dls;*.sf2;*.sf3)\0*.dls;*.sf2;*.sf3\0"
262+#else
263+ "Supported files (*.sf2;*.sf3)\0*.sf2;*.sf3\0"
264+#endif
265+ "Soundfont (*.sf2;*.sf3)\0*.sf2;*.sf3\0"
266+#ifdef ENABLE_DLS
267+ "DLS (*.dls)\0*.dls\0"
268+#endif
269+ "All files (*.*)\0*.*\0\0"
270+ );
251271 fd.setOwner(hDlg);
252272 if (fd.Execute()) {
253273 const int n = fd.getIndex();
@@ -276,6 +296,7 @@ LRESULT DlgMainProc_COMMAND(HWND hDlg, WPARAM wParam, LPARAM lParam)
276296 case IDM_OPT_APPEND_COMMENT:
277297 case IDM_OPT_APPEND_FSPACES:
278298 case IDM_OPT_KEEP_FULLPATH:
299+ case IDM_OPT_PREPEND_BASEDIR:
279300 hMenu = GetMenu(hDlg);
280301 mii.fMask = MIIM_STATE | MIIM_ID;
281302 GetMenuItemInfo(hMenu, LOWORD(wParam), FALSE, &mii);
@@ -297,6 +318,43 @@ LRESULT DlgMainProc_CLOSE(HWND hDlg, WPARAM wParam, LPARAM lParam)
297318 return TRUE;
298319 }
299320
321+LRESULT DlgMainProc_SIZE(HWND hDlg, WPARAM wParam, LPARAM lParam)
322+{
323+ if (wParam != SC_MINIMIZE) {
324+ SetWindowPos(
325+ GetDlgItem(hDlg, IDC_TREE1),
326+ NULL,
327+ 0,
328+ 0,
329+ GET_X_LPARAM(lParam),
330+ GET_Y_LPARAM(lParam) - 17,
331+ SWP_NOACTIVATE | SWP_NOZORDER
332+ );
333+
334+ SetWindowPos(
335+ GetDlgItem(hDlg, IDC_EDSFLABEL),
336+ NULL,
337+ 0,
338+ GET_Y_LPARAM(lParam) - 16,
339+ 99,
340+ 16,
341+ SWP_NOACTIVATE | SWP_NOZORDER
342+ );
343+
344+ SetWindowPos(
345+ GetDlgItem(hDlg, IDC_EDSFNAME),
346+ NULL,
347+ 100,
348+ GET_Y_LPARAM(lParam) - 16,
349+ GET_X_LPARAM(lParam) - 100,
350+ 16,
351+ SWP_NOACTIVATE | SWP_NOZORDER
352+ );
353+ }
354+
355+ return TRUE;
356+}
357+
300358 LRESULT CALLBACK DlgMainProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
301359 {
302360 #define SET_MYWINMSG(VN) case WM_ ## VN: return DlgMainProc_## VN(hDlg, wParam, lParam);
@@ -305,6 +363,7 @@ LRESULT CALLBACK DlgMainProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
305363 SET_MYWINMSG(DROPFILES);
306364 SET_MYWINMSG(COMMAND);
307365 SET_MYWINMSG(CLOSE);
366+ SET_MYWINMSG(SIZE);
308367 }
309368 #undef SET_MYWINMSG
310369 return FALSE;
--- a/tim_cui/tim_cui.vcproj
+++ b/tim_cui/tim_cui.vcproj
@@ -283,6 +283,10 @@
283283 >
284284 </File>
285285 <File
286+ RelativePath="..\interface\rtsyn_portmidi.c"
287+ >
288+ </File>
289+ <File
286290 RelativePath="..\interface\rtsyn_winmm.c"
287291 >
288292 </File>
--- a/tim_cui/tim_cui.vcxproj
+++ b/tim_cui/tim_cui.vcxproj
@@ -330,6 +330,7 @@
330330 <ClCompile Include="..\interface\portmidisyn_c.c" />
331331 <ClCompile Include="..\interface\rtsyn_common.c" />
332332 <ClCompile Include="..\interface\rtsyn_npipe.c" />
333+ <ClCompile Include="..\interface\rtsyn_portmidi.c" />
333334 <ClCompile Include="..\interface\rtsyn_winmm.c" />
334335 <ClCompile Include="..\interface\vt100.c" />
335336 <ClCompile Include="..\interface\vt100_c.c" />
--- a/timidity/common.c
+++ b/timidity/common.c
@@ -421,7 +421,7 @@ struct timidity_file *open_with_constmem(const char *mem, ptr_size_t memlen, int
421421 * This is meant to find and open files for reading, possibly piping
422422 * them through a decompressor.
423423 */
424-struct timidity_file *open_file(char *name, int decompress, int noise_mode)
424+struct timidity_file *open_file(const char *name, int decompress, int noise_mode)
425425 {
426426 struct timidity_file *tf;
427427 PathList *plp = pathlist;
@@ -496,7 +496,7 @@ struct timidity_file *open_file(char *name, int decompress, int noise_mode)
496496 * This is meant to find and open regular files for reading, possibly
497497 * piping them through a decompressor.
498498 */
499-struct timidity_file *open_file_r(char *name, int decompress, int noise_mode)
499+struct timidity_file *open_file_r(const char *name, int decompress, int noise_mode)
500500 {
501501 struct stat st;
502502 struct timidity_file *tf;
--- a/timidity/dls.cpp
+++ b/timidity/dls.cpp
@@ -47,6 +47,21 @@ extern "C"
4747 namespace TimDLS
4848 {
4949
50+void TrimRight(std::string& str)
51+{
52+ using namespace std::string_view_literals;
53+ std::size_t pos = str.find_last_not_of("\0 \t\r\n"sv);
54+
55+ if (pos == str.npos)
56+ {
57+ str.clear();
58+ }
59+ else
60+ {
61+ str.resize(pos + 1);
62+ }
63+}
64+
5065 struct TFFileCloser
5166 {
5267 void operator()(timidity_file* pFile) const
@@ -229,6 +244,25 @@ struct DLSCollection
229244 std::uint32_t WavePoolOffset; // offset of wave pool from the beginning of the DLS file
230245 };
231246
247+struct DLSProgram
248+{
249+ std::uint8_t ProgramNumber;
250+ std::string Name;
251+};
252+
253+struct DLSBank
254+{
255+ std::uint8_t BankNumber;
256+ std::vector<DLSProgram> Programs;
257+};
258+
259+struct DLSDrumset
260+{
261+ std::uint8_t DrumsetNumber;
262+ std::string Name;
263+ std::vector<std::uint8_t> Notes;
264+};
265+
232266 std::int32_t CalcRate(std::int32_t diff, double sec)
233267 {
234268 const std::int32_t envMax = 0x3FFFFFFF;
@@ -278,39 +312,63 @@ public:
278312 }
279313
280314 ParseRIFF(pFile.get());
315+ }
316+
317+ std::vector<DLSBank> GetBankList() const
318+ {
319+ std::vector<DLSBank> banks;
281320
282-#if 0
283- for (const DLSInstrument& i : m_DLS.Instruments)
321+ for (const TimDLS::DLSInstrument& i : m_DLS.Instruments)
284322 {
285- if (i.Bank == 128)
323+ if (i.Bank != 128)
286324 {
287- for (const DLSRegion& r : i.Regions)
325+ auto itBank = std::lower_bound(banks.begin(), banks.end(), i.Bank, [] (auto&& a, auto&& b) { return a.BankNumber < b; });
326+
327+ if (itBank == banks.end() || itBank->BankNumber != i.Bank)
288328 {
289- ctl->cmsg(
290- CMSG_INFO,
291- VERB_NORMAL,
292- "%d %%dls \"gm.dls\" 128 %d %d # %s",
293- r.SampleInfo->UnityNote,
294- i.ProgramNumber,
295- r.SampleInfo->UnityNote,
296- i.Name.c_str()
297- );
329+ itBank = banks.emplace(itBank);
330+ itBank->BankNumber = i.Bank;
298331 }
332+
333+ auto& program = itBank->Programs.emplace_back();
334+ program.ProgramNumber = i.ProgramNumber;
335+ program.Name = i.Name;
336+ TrimRight(program.Name);
299337 }
300- else
338+ }
339+
340+ for (DLSBank& b : banks)
341+ {
342+ std::sort(b.Programs.begin(), b.Programs.end(), [] (auto&& a, auto&& b) { return a.ProgramNumber < b.ProgramNumber; });
343+ }
344+
345+ return banks;
346+ }
347+
348+ std::vector<DLSDrumset> GetDrumsetList() const
349+ {
350+ std::vector<DLSDrumset> drumsets;
351+
352+ for (const TimDLS::DLSInstrument& i : m_DLS.Instruments)
353+ {
354+ if (i.Bank == 128)
301355 {
302- ctl->cmsg(
303- CMSG_INFO,
304- VERB_NORMAL,
305- "%d %%dls \"gm.dls\" %d %d # %s",
306- i.ProgramNumber,
307- i.Bank,
308- i.ProgramNumber,
309- i.Name.c_str()
310- );
356+ auto& drumset = drumsets.emplace_back();
357+ drumset.DrumsetNumber = i.ProgramNumber;
358+ drumset.Name = i.Name;
359+ TrimRight(drumset.Name);
360+
361+ for (const TimDLS::DLSRegion& r : i.Regions)
362+ {
363+ drumset.Notes.push_back(r.SampleInfo->UnityNote);
364+ }
365+
366+ std::sort(drumset.Notes.begin(), drumset.Notes.end());
311367 }
312368 }
313-#endif
369+
370+ std::sort(drumsets.begin(), drumsets.end(), [] (auto&& a, auto&& b) { return a.DrumsetNumber < b.DrumsetNumber; });
371+ return drumsets;
314372 }
315373
316374 std::unique_ptr<Instrument, InstrumentDeleter> BuildInstrument(std::uint8_t bank, std::int8_t programNumber, std::int8_t note)
@@ -430,8 +488,10 @@ public:
430488
431489 pSample->cutoff_freq = 20000;
432490 pSample->cutoff_low_limit = -1;
433- pSample->envelope_velf_bpo = 64;
434- pSample->modenv_velf_bpo = 64;
491+ pSample->envelope_velf_bpo = 0;
492+ pSample->modenv_velf_bpo = 0;
493+ pSample->envelope_keyf_bpo = 0;
494+ pSample->modenv_keyf_bpo = 0;
435495 pSample->key_to_fc_bpo = 60;
436496 pSample->scale_freq = 60;
437497 pSample->scale_factor = 1024;
@@ -472,12 +532,12 @@ public:
472532 case DLSConnectionBlock::DestinationKind::EG1AttackTime:
473533 if (b.Source == DLSConnectionBlock::SourceKind::None && b.Control == DLSConnectionBlock::SourceKind::None && b.Transform == DLSConnectionBlock::TransformKind::None)
474534 {
475- attackTime = TimeCentToSecond(b.Scale);
535+ attackTime = std::clamp(TimeCentToSecond(b.Scale), 0.0, 20.0);
476536 continue;
477537 }
478538 else if (b.Source == DLSConnectionBlock::SourceKind::KeyOnVelocity && b.Control == DLSConnectionBlock::SourceKind::None && b.Transform == DLSConnectionBlock::TransformKind::None)
479539 {
480- pSample->envelope_velf[0] = static_cast<int16>(b.Scale / 65536);
540+ pSample->envelope_velf[0] = static_cast<int16>(b.Scale / 128 / 65536);
481541 continue;
482542 }
483543 break;
@@ -485,13 +545,12 @@ public:
485545 case DLSConnectionBlock::DestinationKind::EG1DecayTime:
486546 if (b.Source == DLSConnectionBlock::SourceKind::None && b.Control == DLSConnectionBlock::SourceKind::None && b.Transform == DLSConnectionBlock::TransformKind::None)
487547 {
488- decayTime = TimeCentToSecond(b.Scale);
548+ decayTime = std::clamp(TimeCentToSecond(b.Scale), 0.0, 40.0);
489549 continue;
490550 }
491551 else if (b.Source == DLSConnectionBlock::SourceKind::KeyNumber && b.Control == DLSConnectionBlock::SourceKind::None && b.Transform == DLSConnectionBlock::TransformKind::None)
492552 {
493- // this is probably incorrect
494- pSample->envelope_keyf[1] = static_cast<int16>(b.Scale / 65536);
553+ pSample->envelope_keyf[1] = static_cast<int16>(b.Scale / 128 / 65536);
495554 continue;
496555 }
497556 break;
@@ -499,7 +558,7 @@ public:
499558 case DLSConnectionBlock::DestinationKind::EG1SustainLevel:
500559 if (b.Source == DLSConnectionBlock::SourceKind::None && b.Control == DLSConnectionBlock::SourceKind::None && b.Transform == DLSConnectionBlock::TransformKind::None)
501560 {
502- sustainLevel = std::lround(65533.0 * std::clamp(b.Scale, 0, 1000) / 1000.0);
561+ sustainLevel = std::clamp(b.Scale / 1000, 0, 65533);
503562 continue;
504563 }
505564 break;
@@ -507,7 +566,7 @@ public:
507566 case DLSConnectionBlock::DestinationKind::EG1ReleaseTime:
508567 if (b.Source == DLSConnectionBlock::SourceKind::None && b.Control == DLSConnectionBlock::SourceKind::None && b.Transform == DLSConnectionBlock::TransformKind::None)
509568 {
510- releaseTime = TimeCentToSecond(b.Scale);
569+ releaseTime = std::clamp(TimeCentToSecond(b.Scale), 0.0, 20.0);
511570 continue;
512571 }
513572 break;
@@ -551,6 +610,14 @@ public:
551610 }
552611 break;
553612
613+ case DLSConnectionBlock::DestinationKind::Pan:
614+ if (b.Source == DLSConnectionBlock::SourceKind::None && b.Control == DLSConnectionBlock::SourceKind::None && b.Transform == DLSConnectionBlock::TransformKind::None)
615+ {
616+ pSample->sample_pan = std::clamp(b.Scale / 65536.0 / 1000.0, -0.5, 0.5);
617+ continue;
618+ }
619+ break;
620+
554621 default:
555622 break;
556623 }
@@ -575,15 +642,17 @@ public:
575642 pSample->envelope_rate[1] = CalcRate(1, holdTime);
576643
577644 pSample->envelope_offset[2] = ToOffset(sustainLevel);
578- pSample->envelope_rate[2] = CalcRate(65534 - sustainLevel, std::clamp(decayTime, 0.0, 100.0));
645+ pSample->envelope_rate[2] = CalcRate(65534 - sustainLevel, decayTime);
579646
580647 pSample->envelope_offset[3] = 0;
581- pSample->envelope_rate[3] = CalcRate(sustainLevel, releaseTime);
582- pSample->envelope_offset[4] = pSample->envelope_offset[3];
648+ pSample->envelope_rate[3] = CalcRate(65535, releaseTime);
649+ pSample->envelope_offset[4] = 0;
583650 pSample->envelope_rate[4] = pSample->envelope_rate[3];
584- pSample->envelope_offset[5] = pSample->envelope_offset[3];
651+ pSample->envelope_offset[5] = 0;
585652 pSample->envelope_rate[5] = pSample->envelope_rate[3];
586653
654+ pSample->modes |= MODES_ENVELOPE;
655+
587656 filledSamples++;
588657
589658 if (filledSamples >= regionCount)
@@ -1669,3 +1738,86 @@ extern "C" void free_dls_file(Instrument *ip)
16691738 {
16701739 TimDLS::GlobalInstrumentCache.FreeInstrument(ip);
16711740 }
1741+
1742+DLSCollectionInfo *get_dls_instrument_list(const char *sample_file)
1743+{
1744+ try
1745+ {
1746+ std::string fileName = sample_file;
1747+ TimDLS::DLSParser dls(fileName);
1748+ dls.Parse();
1749+
1750+ auto banks = dls.GetBankList();
1751+ auto drumsets = dls.GetDrumsetList();
1752+
1753+ std::unique_ptr<DLSCollectionInfo, TimDLS::TimDeleter> pList(reinterpret_cast<DLSCollectionInfo*>(safe_calloc(sizeof(DLSCollectionInfo), 1)));
1754+
1755+ // move data from C++ to C
1756+ pList->banks = reinterpret_cast<DLSBankInfo*>(safe_malloc(sizeof(DLSBankInfo) * banks.size()));
1757+ pList->bank_count = static_cast<int>(banks.size());
1758+
1759+ for (std::size_t i = 0; i < banks.size(); i++)
1760+ {
1761+ auto& b = banks[i];
1762+
1763+ pList->banks[i].bank = b.BankNumber;
1764+ pList->banks[i].programs = reinterpret_cast<DLSProgramInfo*>(safe_malloc(sizeof(DLSProgramInfo) * b.Programs.size()));
1765+ pList->banks[i].program_count = static_cast<int>(b.Programs.size());
1766+
1767+ for (std::size_t j = 0; j < b.Programs.size(); j++)
1768+ {
1769+ pList->banks[i].programs[j].name = safe_strdup(b.Programs[j].Name.c_str());
1770+ pList->banks[i].programs[j].program = b.Programs[j].ProgramNumber;
1771+ }
1772+ }
1773+
1774+ pList->drumsets = reinterpret_cast<DLSDrumsetInfo*>(safe_malloc(sizeof(DLSDrumsetInfo) * drumsets.size()));
1775+ pList->drumset_count = static_cast<int>(drumsets.size());
1776+
1777+ for (std::size_t i = 0; i < drumsets.size(); i++)
1778+ {
1779+ auto& ds = drumsets[i];
1780+ pList->drumsets[i].name = safe_strdup(ds.Name.c_str());
1781+ pList->drumsets[i].program = ds.DrumsetNumber;
1782+ pList->drumsets[i].notes = reinterpret_cast<uint8*>(safe_malloc(sizeof(uint8) * ds.Notes.size()));
1783+ pList->drumsets[i].note_count = static_cast<int>(ds.Notes.size());
1784+
1785+ std::uninitialized_copy(ds.Notes.begin(), ds.Notes.end(), pList->drumsets[i].notes);
1786+ }
1787+
1788+ return pList.release();
1789+ }
1790+ catch (const std::exception&)
1791+ {
1792+ return nullptr;
1793+ }
1794+}
1795+
1796+void free_dls_instrument_list(DLSCollectionInfo *list)
1797+{
1798+ if (!list)
1799+ {
1800+ return;
1801+ }
1802+
1803+ for (int i = 0; i < list->bank_count; i++)
1804+ {
1805+ for (int j = 0; j < list->banks[i].program_count; j++)
1806+ {
1807+ safe_free(list->banks[i].programs[j].name);
1808+ }
1809+
1810+ safe_free(list->banks[i].programs);
1811+ }
1812+
1813+ for (int i = 0; i < list->drumset_count; i++)
1814+ {
1815+ safe_free(list->drumsets[i].name);
1816+ safe_free(list->drumsets[i].notes);
1817+ }
1818+
1819+ safe_free(list->banks);
1820+ safe_free(list->drumsets);
1821+
1822+ safe_free(list);
1823+}
--- a/timidity/dls.h
+++ b/timidity/dls.h
@@ -8,4 +8,32 @@ void free_dls(void);
88 Instrument *extract_dls_file(char *sample_file, uint8 font_bank, int8 font_preset, int8 font_keynote);
99 void free_dls_file(Instrument *ip);
1010
11+typedef struct {
12+ char *name;
13+ uint8 program;
14+} DLSProgramInfo;
15+
16+typedef struct {
17+ DLSProgramInfo *programs;
18+ int program_count;
19+ uint8 bank;
20+} DLSBankInfo;
21+
22+typedef struct {
23+ char *name;
24+ uint8 *notes;
25+ int note_count;
26+ uint8 program;
27+} DLSDrumsetInfo;
28+
29+typedef struct {
30+ DLSBankInfo *banks;
31+ DLSDrumsetInfo *drumsets;
32+ int bank_count;
33+ int drumset_count;
34+} DLSCollectionInfo;
35+
36+DLSCollectionInfo *get_dls_instrument_list(const char *sample_file);
37+void free_dls_instrument_list(DLSCollectionInfo *list);
38+
1139 #endif
--- a/timidity/instrum.c
+++ b/timidity/instrum.c
@@ -2250,7 +2250,7 @@ void free_instruments(int reload_default_inst)
22502250 if(bank->tone[j][elm] == NULL)
22512251 continue;
22522252 ip = bank->tone[j][elm]->instrument;
2253- if(ip && (ip->type == INST_SF2 || ip->type == INST_PCM || ip->type == INST_MMS || ip->type == INST_SCC || ip->type == INST_SFZ) &&
2253+ if(ip && (ip->type == INST_SF2 || ip->type == INST_PCM || ip->type == INST_MMS || ip->type == INST_SCC || ip->type == INST_SFZ || ip->type == INST_DLS) &&
22542254 (i == 0 || !tonebank[0]->tone[j][elm] || ip != tonebank[0]->tone[j][elm]->instrument) )
22552255 free_instrument(ip);
22562256 bank->tone[j][elm]->instrument = NULL;
@@ -2262,7 +2262,7 @@ void free_instruments(int reload_default_inst)
22622262 if(bank->tone[j][elm] == NULL)
22632263 continue;
22642264 ip = bank->tone[j][elm]->instrument;
2265- if(ip && (ip->type == INST_SF2 || ip->type == INST_PCM || ip->type == INST_MMS || ip->type == INST_SCC || ip->type == INST_SFZ) &&
2265+ if(ip && (ip->type == INST_SF2 || ip->type == INST_PCM || ip->type == INST_MMS || ip->type == INST_SCC || ip->type == INST_SFZ || ip->type == INST_DLS) &&
22662266 (i == 0 || !drumset[0]->tone[j][elm] || ip != drumset[0]->tone[j][elm]->instrument) )
22672267 free_instrument(ip);
22682268 bank->tone[j][elm]->instrument = NULL;
--- a/timidity/mfi.c
+++ b/timidity/mfi.c
@@ -232,7 +232,7 @@ static int read_mfi_information(int infoLength, int *mfiVersion, int *noteType,
232232 case BE_FCC(0x30333030 /*0300*/): *mfiVersion = 3; break;
233233 default:
234234 ctl->cmsg(CMSG_WARNING, VERB_NORMAL, "Unknown MFi version.");
235- return 1;
235+ //return 1;
236236 }
237237 ctl->cmsg(CMSG_TEXT, VERB_VERBOSE, "MFi Version: %d", *mfiVersion);
238238 /*
--- a/timidity/mix.c
+++ b/timidity/mix.c
@@ -531,7 +531,6 @@ void mix_voice(DATA_T *buf, int v, int32 c)
531531 recompute_resample_filter(v);
532532 }
533533 apply_envelope_to_amp(v);
534-#ifdef INT_SYNTH
535534 switch(vp->sample->inst_type){
536535 case INST_GUS:
537536 case INST_SF2:
@@ -553,24 +552,15 @@ void mix_voice(DATA_T *buf, int v, int32 c)
553552 resample_filter(v, sp, c);
554553 }
555554 break;
555+#ifdef INT_SYNTH
556556 case INST_MMS:
557557 compute_voice_mms(v, sp, c);
558558 break;
559559 case INST_SCC:
560560 compute_voice_scc(v, sp, c);
561561 break;
562- }
563-#else
564- if(opt_resample_over_sampling){
565- int32 c2 = c * opt_resample_over_sampling;
566- resample_voice(v, sp, c2);
567- resample_filter(v, sp, c2);
568- resample_down_sampling(sp, c);
569- }else{
570- resample_voice(v, sp, c);
571- resample_filter(v, sp, c);
572- }
573562 #endif
563+ }
574564 #ifdef VOICE_EFFECT
575565 voice_effect(v, sp, c);
576566 #endif
--- a/timidity/output.h
+++ b/timidity/output.h
@@ -245,7 +245,7 @@ extern double playmode_rate_us;
245245 extern void init_output(void);
246246 extern void change_output_volume(int32);
247247
248-#ifdef __W32__
248+#if defined(__W32__) && !defined(CFG_FOR_SF)
249249 extern CRITICAL_SECTION critSect;
250250 #endif
251251
--- a/timidity/playmidi.c
+++ b/timidity/playmidi.c
@@ -4129,7 +4129,8 @@ static void recompute_mod_envelope_follow(int v, int ch)
41294129 time_ms = calc_nrpn_param(time_ms, (double)add_param[EG_GUS_ATTACK] * env_attack_calc, nrpn_env_attack_mode);
41304130 if(time_ms <= 0.0)
41314131 vp->mod_env.rate[ENV0_ATTACK_STAGE] = ENV0_OFFSET_MAX;
4132- vp->mod_env.rate[ENV0_ATTACK_STAGE] = sub_ofs_div_cr / time_ms;
4132+ else
4133+ vp->mod_env.rate[ENV0_ATTACK_STAGE] = sub_ofs_div_cr / time_ms;
41334134 }
41344135 if(add_param[EG_GUS_DECAY]){
41354136 FLOAT_T sub_ofs_div_cr = fabs(vp->mod_env.offset[ENV0_ATTACK_STAGE] - vp->mod_env.offset[ENV0_HOLD_STAGE]) * div_playmode_rate * 1000.0;
--- a/timidity/playmidi.h
+++ b/timidity/playmidi.h
@@ -662,53 +662,53 @@ enum { // module_id
662662
663663 struct _ModuleList {
664664 int num;
665- char *name;
665+ const char *name;
666666 };
667667 static struct _ModuleList module_list[] = {
668- MODULE_TIMIDITY_DEFAULT, "TiMidity++ Default",
669- MODULE_SC55, "SC-55 CM-300 CM-500C",
670- MODULE_SC88, "SC-88",
671- MODULE_SC88PRO, "SC-88Pro",
672- MODULE_SC8850, "SC-8850 SC-8820 SC-D70",
673- MODULE_SD20, "SD-20",
674- MODULE_SD80, "SD-80",
675- MODULE_SD90, "SD-90",
676- MODULE_SD50, "SD-50",
677- MODULE_MU50, "MU-50",
678- MODULE_MU80, "MU-80",
679- MODULE_MU90, "MU-90",
680- MODULE_MU100, "MU-100",
681- MODULE_MU128, "MU-128",
682- MODULE_MU500, "MU-500",
683- MODULE_MU1000, "MU-1000",
684- MODULE_MU2000, "MU-2000",
685- MODULE_AG10, "AG-10",
686- MODULE_05RW, "05R/W",
687- MODULE_NX5R, "NX5R NS5R",
688- MODULE_MT32, "MT-32",
689- MODULE_CM32L, "CM-32L",
690- MODULE_CM32P, "CM-32P",
691- MODULE_CM64, "CM-64 (CM32L+CM32P)",
692- MODULE_CM500D, "CM-500 mode D",
693- MODULE_CM64_SN01, "CM64+SN01 P.Orgn+Harpsi",
694- MODULE_CM64_SN02, "CM64+SN02 Latin+FXPerc",
695- MODULE_CM64_SN03, "CM64+SN03 Ethic",
696- MODULE_CM64_SN04, "CM64+SN04 E.Grnd+Clavi",
697- MODULE_CM64_SN05, "CM64+SN05 Orch Strings",
698- MODULE_CM64_SN06, "CM64+SN06 Orch Winds",
699- MODULE_CM64_SN07, "CM64+SN07 Elec Guitar",
700- MODULE_CM64_SN08, "CM64+SN08 Synthesizer",
701- MODULE_CM64_SN09, "CM64+SN09 Guitar+KB",
702- MODULE_CM64_SN10, "CM64+SN10 Rock Drums",
703- MODULE_CM64_SN11, "CM64+SN11 Sound Effect",
704- MODULE_CM64_SN12, "CM64+SN12 Sax+Trombone",
705- MODULE_CM64_SN13, "CM64+SN13 Super Strings",
706- MODULE_CM64_SN14, "CM64+SN14 Super AcGuitar",
707- MODULE_CM64_SN15, "CM64+SN15 Super Brass",
708- MODULE_SBLIVE, "Sound Blaster Live!",
709- MODULE_SBAUDIGY, "Sound Blaster Audigy",
710- MODULE_TIMIDITY_SPECIAL1, "TiMidity++ Special 1",
711- MODULE_TIMIDITY_DEBUG, "TiMidity++ Debug",
668+ {MODULE_TIMIDITY_DEFAULT, "TiMidity++ Default"},
669+ {MODULE_SC55, "SC-55 CM-300 CM-500C"},
670+ {MODULE_SC88, "SC-88"},
671+ {MODULE_SC88PRO, "SC-88Pro"},
672+ {MODULE_SC8850, "SC-8850 SC-8820 SC-D70"},
673+ {MODULE_SD20, "SD-20"},
674+ {MODULE_SD80, "SD-80"},
675+ {MODULE_SD90, "SD-90"},
676+ {MODULE_SD50, "SD-50"},
677+ {MODULE_MU50, "MU-50"},
678+ {MODULE_MU80, "MU-80"},
679+ {MODULE_MU90, "MU-90"},
680+ {MODULE_MU100, "MU-100"},
681+ {MODULE_MU128, "MU-128"},
682+ {MODULE_MU500, "MU-500"},
683+ {MODULE_MU1000, "MU-1000"},
684+ {MODULE_MU2000, "MU-2000"},
685+ {MODULE_AG10, "AG-10"},
686+ {MODULE_05RW, "05R/W"},
687+ {MODULE_NX5R, "NX5R NS5R"},
688+ {MODULE_MT32, "MT-32"},
689+ {MODULE_CM32L, "CM-32L"},
690+ {MODULE_CM32P, "CM-32P"},
691+ {MODULE_CM64, "CM-64 (CM32L+CM32P)"},
692+ {MODULE_CM500D, "CM-500 mode D"},
693+ {MODULE_CM64_SN01, "CM64+SN01 P.Orgn+Harpsi"},
694+ {MODULE_CM64_SN02, "CM64+SN02 Latin+FXPerc"},
695+ {MODULE_CM64_SN03, "CM64+SN03 Ethic"},
696+ {MODULE_CM64_SN04, "CM64+SN04 E.Grnd+Clavi"},
697+ {MODULE_CM64_SN05, "CM64+SN05 Orch Strings"},
698+ {MODULE_CM64_SN06, "CM64+SN06 Orch Winds"},
699+ {MODULE_CM64_SN07, "CM64+SN07 Elec Guitar"},
700+ {MODULE_CM64_SN08, "CM64+SN08 Synthesizer"},
701+ {MODULE_CM64_SN09, "CM64+SN09 Guitar+KB"},
702+ {MODULE_CM64_SN10, "CM64+SN10 Rock Drums"},
703+ {MODULE_CM64_SN11, "CM64+SN11 Sound Effect"},
704+ {MODULE_CM64_SN12, "CM64+SN12 Sax+Trombone"},
705+ {MODULE_CM64_SN13, "CM64+SN13 Super Strings"},
706+ {MODULE_CM64_SN14, "CM64+SN14 Super AcGuitar"},
707+ {MODULE_CM64_SN15, "CM64+SN15 Super Brass"},
708+ {MODULE_SBLIVE, "Sound Blaster Live!"},
709+ {MODULE_SBAUDIGY, "Sound Blaster Audigy"},
710+ {MODULE_TIMIDITY_SPECIAL1, "TiMidity++ Special 1"},
711+ {MODULE_TIMIDITY_DEBUG, "TiMidity++ Debug"},
712712 };
713713 #define module_list_num (sizeof(module_list) / sizeof(struct _ModuleList))
714714
--- a/timidity/resample.c
+++ b/timidity/resample.c
@@ -33,7 +33,6 @@
3333 #include <strings.h>
3434 #endif
3535
36-#include "interface.h"
3736 #include "timidity.h"
3837 #include "common.h"
3938 #include "instrum.h"
@@ -4640,9 +4639,10 @@ static void lo_rs_loop(Voice *vp, DATA_T *dest, int32 count)
46404639 dest = resample_linear_multi(vp, dest, j, &i);
46414640 for(; i < count; i++) {
46424641 *dest++ = resample_linear_single(vp);
4643- if((resrc->offset += resrc->increment) >= resrc->loop_end)
4642+ resrc->offset += resrc->increment;
4643+ while(resrc->offset >= resrc->loop_end)
46444644 resrc->offset -= resrc->loop_end - resrc->loop_start;
4645- /* Hopefully the loop is longer than an increment. */
4645+ /* The loop may not be longer than an increment. */
46464646 }
46474647 }
46484648
@@ -4825,9 +4825,10 @@ static void lo_rs_loop_float(Voice *vp, DATA_T *dest, int32 count)
48254825 dest = resample_linear_float_multi(vp, dest, j, &i);
48264826 for(; i < count; i++) {
48274827 *dest++ = resample_linear_float_single(vp);
4828- if((resrc->offset += resrc->increment) >= resrc->loop_end)
4828+ resrc->offset += resrc->increment;
4829+ while(resrc->offset >= resrc->loop_end)
48294830 resrc->offset -= resrc->loop_end - resrc->loop_start;
4830- /* Hopefully the loop is longer than an increment. */
4831+ /* The loop may not be longer than an increment. */
48314832 }
48324833 }
48334834
@@ -5704,9 +5705,10 @@ static void lao_rs_loop(Voice *vp, DATA_T *dest, int32 count)
57045705 }
57055706 for(; i < count; i++) {
57065707 *dest++ = resample_lagrange_single(vp);
5707- if((resrc->offset += resrc->increment) >= resrc->loop_end)
5708+ resrc->offset += resrc->increment;
5709+ while(resrc->offset >= resrc->loop_end)
57085710 resrc->offset -= resrc->loop_end - resrc->loop_start;
5709- /* Hopefully the loop is longer than an increment. */
5711+ /* The loop may not be longer than an increment. */
57105712 }
57115713 }
57125714
@@ -6088,9 +6090,10 @@ static void lao_rs_loop_float(Voice *vp, DATA_T *dest, int32 count)
60886090 }
60896091 for(; i < count; i++) {
60906092 *dest++ = resample_lagrange_float_single(vp);
6091- if((resrc->offset += resrc->increment) >= resrc->loop_end)
6093+ resrc->offset += resrc->increment;
6094+ while(resrc->offset >= resrc->loop_end)
60926095 resrc->offset -= resrc->loop_end - resrc->loop_start;
6093- /* Hopefully the loop is longer than an increment. */
6096+ /* The loop may not be longer than an increment. */
60946097 }
60956098 }
60966099
--- a/timidity/sfz.cpp
+++ b/timidity/sfz.cpp
@@ -28,6 +28,7 @@ Instrument *extract_sample_file(char *sample_file);
2828 #include <cstring>
2929
3030 #include <algorithm>
31+#include <deque>
3132 #include <exception>
3233 #include <iterator>
3334 #include <memory>
@@ -795,7 +796,7 @@ private:
795796 };
796797
797798 std::vector<std::string> m_FileNames;
798- std::vector<TextBuffer> m_InBuffers;
799+ std::deque<TextBuffer> m_InBuffers;
799800 std::stack<InputStackItem, std::vector<InputStackItem>> m_InputStack;
800801 TextBuffer m_OutBuffer;
801802 std::unordered_map<std::string, TextBuffer::View> m_DefinedMacros;
@@ -810,6 +811,8 @@ enum class OpCodeKind
810811 AmpEG_Hold,
811812 AmpEG_Release,
812813 AmpEG_Sustain,
814+ AmpKeyCenter,
815+ AmpKeyTrack,
813816 AmpVelTrack,
814817 DefaultPath,
815818 HiKey,
@@ -821,8 +824,10 @@ enum class OpCodeKind
821824 LoVelocity,
822825 Offset,
823826 Key,
827+ Pan,
824828 PitchKeyCenter,
825829 Sample,
830+ Transpose,
826831 Trigger,
827832 Tune,
828833 Volume
@@ -951,6 +956,7 @@ public:
951956 {
952957 switch (opVal.OpCode)
953958 {
959+ case OpCodeKind::AmpKeyCenter:
954960 case OpCodeKind::HiKey:
955961 case OpCodeKind::LoKey:
956962 case OpCodeKind::PitchKeyCenter:
@@ -975,12 +981,15 @@ public:
975981 case OpCodeKind::AmpEG_Hold:
976982 case OpCodeKind::AmpEG_Release:
977983 case OpCodeKind::AmpEG_Sustain:
984+ case OpCodeKind::AmpKeyTrack:
978985 case OpCodeKind::AmpVelTrack:
979986 case OpCodeKind::HiVelocity:
980987 case OpCodeKind::LoopEnd:
981988 case OpCodeKind::LoopStart:
982989 case OpCodeKind::LoVelocity:
983990 case OpCodeKind::Offset:
991+ case OpCodeKind::Pan:
992+ case OpCodeKind::Transpose:
984993 case OpCodeKind::Tune:
985994 case OpCodeKind::Volume:
986995 try
@@ -1111,19 +1120,23 @@ private:
11111120 {"ampeg_hold"sv, OpCodeKind::AmpEG_Hold},
11121121 {"ampeg_release"sv, OpCodeKind::AmpEG_Release},
11131122 {"ampeg_sustain"sv, OpCodeKind::AmpEG_Sustain},
1123+ {"amp_keycenter"sv, OpCodeKind::AmpKeyCenter},
1124+ {"amp_keytrack"sv, OpCodeKind::AmpKeyTrack},
11141125 {"amp_veltrack"sv, OpCodeKind::AmpVelTrack},
11151126 {"default_path"sv, OpCodeKind::DefaultPath},
11161127 {"hikey"sv, OpCodeKind::HiKey},
11171128 {"hivel"sv, OpCodeKind::HiVelocity},
1129+ {"key"sv, OpCodeKind::Key},
11181130 {"lokey"sv, OpCodeKind::LoKey},
11191131 {"loop_end"sv, OpCodeKind::LoopEnd},
11201132 {"loop_mode"sv, OpCodeKind::LoopMode},
11211133 {"loop_start"sv, OpCodeKind::LoopStart},
11221134 {"lovel"sv, OpCodeKind::LoVelocity},
11231135 {"offset"sv, OpCodeKind::Offset},
1124- {"key"sv, OpCodeKind::Key},
1136+ {"pan"sv, OpCodeKind::Pan},
11251137 {"pitch_keycenter"sv, OpCodeKind::PitchKeyCenter},
11261138 {"sample"sv, OpCodeKind::Sample},
1139+ {"transpose"sv, OpCodeKind::Transpose},
11271140 {"trigger"sv, OpCodeKind::Trigger},
11281141 {"tune"sv, OpCodeKind::Tune},
11291142 {"volume"sv, OpCodeKind::Volume}
@@ -1503,6 +1516,7 @@ private:
15031516
15041517 case LoopModeKind::LoopContinuous:
15051518 s.modes |= MODES_LOOPING | MODES_SUSTAIN;
1519+ s.data_length = s.loop_end;
15061520 break;
15071521
15081522 case LoopModeKind::LoopSustain:
@@ -1511,40 +1525,45 @@ private:
15111525 }
15121526
15131527 s.volume = std::pow(10.0, flatSection.GetAs<double>(OpCodeKind::Volume).value_or(0.0) / 10.0);
1514- s.tune = std::pow(2.0, std::clamp(flatSection.GetAs<double>(OpCodeKind::Tune).value_or(0.0), -100.0, 100.0) / 1200.0);
1528+ s.tune = std::pow(
1529+ 2.0,
1530+ std::clamp(flatSection.GetAs<double>(OpCodeKind::Transpose).value_or(0.0), -127.0, 127.0) / 12.0
1531+ + std::clamp(flatSection.GetAs<double>(OpCodeKind::Tune).value_or(0.0), -100.0, 100.0) / 1200.0
1532+ );
1533+
1534+ s.sample_pan = std::clamp(flatSection.GetAs<double>(OpCodeKind::Pan).value_or(0.0), -100.0, 100.0) / 200.0;
15151535
1516- s.envelope_delay = std::lround(std::clamp(flatSection.GetAs<double>(OpCodeKind::AmpEG_Delay).value_or(0.0), 0.0, 100.0) * ::play_mode->rate);
1536+ s.envelope_keyf_bpo = static_cast<int8>(std::clamp(flatSection.GetAs<std::int32_t>(OpCodeKind::AmpKeyCenter).value_or(60), -127, 127));
1537+ s.envelope_velf_bpo = 0;
1538+ s.modenv_velf_bpo = 0;
1539+
1540+ s.envelope_delay = std::lround(std::clamp(flatSection.GetAs<double>(OpCodeKind::AmpEG_Delay).value_or(0.0), 0.0, 100.0) * s.sample_rate);
15171541
15181542 TriggerKind trigger = flatSection.GetAs<TriggerKind>(OpCodeKind::Trigger).value_or(TriggerKind::Attack);
15191543
15201544 if (trigger == TriggerKind::Release)
15211545 {
1522- // HACK: don't play the sample if trigger=release
15231546 // FIXME: modify playmidi.c to implement this correctly
15241547
1525- auto loc = flatSection.GetLocationForOpCode(OpCodeKind::Trigger);
1526- ctl->cmsg(
1527- CMSG_WARNING,
1528- VERB_VERBOSE,
1529- "%s(%u): 'trigger=release' is not implemented yet",
1530- std::string(m_Parser.GetPreprocessor().GetFileNameFromID(loc.FileID)).c_str(),
1531- loc.Line
1532- );
1533-
1534- s.envelope_offset[0] = ToOffset(65535);
1535- s.envelope_rate[0] = CalcRate(65535, 0.0);
1536- s.envelope_offset[1] = ToOffset(65534);
1548+ s.envelope_offset[0] = ToOffset(3);
1549+ s.envelope_rate[0] = CalcRate(1, 0.0);
1550+ s.envelope_offset[1] = ToOffset(2);
15371551 s.envelope_rate[1] = CalcRate(1, 0.0);
1552+ s.envelope_offset[2] = ToOffset(1);
1553+ s.envelope_rate[2] = CalcRate(1, 0.0);
15381554
1539- s.envelope_offset[2] = ToOffset(0);
1540- s.envelope_rate[2] = CalcRate(65534, 0.0);
1555+ s.envelope_offset[3] = ToOffset(65535);
1556+ s.envelope_rate[3] = CalcRate(65535, std::clamp(flatSection.GetAs<double>(OpCodeKind::AmpEG_Attack).value_or(0.0), 0.0, 100.0));
1557+ s.envelope_offset[4] = ToOffset(65534);
1558+ s.envelope_rate[4] = CalcRate(1, std::clamp(flatSection.GetAs<double>(OpCodeKind::AmpEG_Hold).value_or(0.0), 0.0, 100.0));
15411559
1542- s.envelope_offset[3] = 0;
1543- s.envelope_rate[3] = CalcRate(0, 0.0);
1544- s.envelope_offset[4] = s.envelope_offset[3];
1545- s.envelope_rate[4] = s.envelope_rate[3];
1546- s.envelope_offset[5] = s.envelope_offset[3];
1547- s.envelope_rate[5] = s.envelope_rate[3];
1560+ std::int32_t sustainLevel = std::lround(65533.0 * std::clamp(flatSection.GetAs<double>(OpCodeKind::AmpEG_Sustain).value_or(100.0), 0.0, 100.0) / 100.0);
1561+ s.envelope_offset[5] = ToOffset(sustainLevel);
1562+ s.envelope_rate[5] = CalcRate(65534 - sustainLevel, std::clamp(flatSection.GetAs<double>(OpCodeKind::AmpEG_Decay).value_or(0.0), 0.0, 100.0));
1563+
1564+ s.modes |= MODES_LOOPING | MODES_SUSTAIN | MODES_RELEASE;
1565+ s.loop_start = 0;
1566+ s.loop_end = std::clamp<splen_t>(s.loop_start + (1 << FRACTION_BITS), 0, s.data_length);
15481567 }
15491568 else
15501569 {
@@ -1573,17 +1592,22 @@ private:
15731592
15741593 double releaseTime = std::clamp(flatSection.GetAs<double>(OpCodeKind::AmpEG_Release).value_or(0.0), 0.0, 100.0);
15751594 s.envelope_offset[3] = 0;
1576- s.envelope_rate[3] = CalcRate(sustainLevel, releaseTime);
1595+ s.envelope_rate[3] = CalcRate(65535, releaseTime);
15771596 s.envelope_offset[4] = s.envelope_offset[3];
15781597 s.envelope_rate[4] = s.envelope_rate[3];
15791598 s.envelope_offset[5] = s.envelope_offset[3];
15801599 s.envelope_rate[5] = s.envelope_rate[3];
15811600 }
15821601
1602+ if (auto ampKeyTrack = flatSection.GetAs<double>(OpCodeKind::AmpKeyTrack))
1603+ {
1604+ std::fill(std::begin(s.envelope_keyf), std::end(s.envelope_keyf), std::clamp(ampKeyTrack.value(), -96.0, 12.0) * 0.1 * std::log2(10.0));
1605+ }
1606+
15831607 if (auto ampVelTrack = flatSection.GetAs<double>(OpCodeKind::AmpVelTrack))
15841608 {
15851609 // convert percent to rate
1586- std::fill(std::begin(s.envelope_velf), std::end(s.envelope_velf), std::clamp(ampVelTrack.value() * 0.01, -1.0, 1.0));
1610+ std::fill(std::begin(s.envelope_velf), std::end(s.envelope_velf), std::clamp(ampVelTrack.value() * 0.01, -1.0, 1.0) * 1200.0 / 127.0);
15871611 }
15881612 }
15891613
@@ -1623,11 +1647,11 @@ private:
16231647 switch (i.Header)
16241648 {
16251649 case HeaderKind::Control:
1626- controlOpCodes.insert(controlOpCodes.end(), i.OpCodes.begin(), i.OpCodes.end());
1650+ controlOpCodes = i.OpCodes;
16271651 break;
16281652
16291653 case HeaderKind::Global:
1630- globalOpCodes.insert(globalOpCodes.end(), i.OpCodes.begin(), i.OpCodes.end());
1654+ globalOpCodes = i.OpCodes;
16311655 break;
16321656
16331657 case HeaderKind::Group:
@@ -1686,12 +1710,10 @@ private:
16861710
16871711 struct InstrumentCacheEntry
16881712 {
1689- InstrumentCacheEntry(std::string_view filePath, std::unique_ptr<Instrument, InstrumentDeleter> pInstrument)
1690- : FilePath(filePath), pInstrument(std::move(pInstrument))
1713+ InstrumentCacheEntry(std::unique_ptr<Instrument, InstrumentDeleter> pInstrument) : pInstrument(std::move(pInstrument))
16911714 {
16921715 }
16931716
1694- std::string FilePath;
16951717 std::unique_ptr<Instrument, InstrumentDeleter> pInstrument;
16961718 std::vector<Instrument*> RefInstruments;
16971719 };
@@ -1701,14 +1723,7 @@ class InstrumentCache
17011723 public:
17021724 Instrument* LoadSFZ(std::string filePath)
17031725 {
1704- auto it = std::find_if(
1705- m_Instruments.begin(),
1706- m_Instruments.end(),
1707- [&filePath] (auto&& x)
1708- {
1709- return x.FilePath == filePath;
1710- }
1711- );
1726+ auto it = m_Instruments.find(filePath);
17121727
17131728 if (it == m_Instruments.end())
17141729 {
@@ -1719,7 +1734,7 @@ public:
17191734 TimSFZ::Parser parser(pp);
17201735 parser.Parse();
17211736 TimSFZ::InstrumentBuilder builder(parser, filePath);
1722- m_Instruments.emplace_back(filePath, builder.BuildInstrument());
1737+ it = m_Instruments.emplace(filePath, builder.BuildInstrument()).first;
17231738 }
17241739 catch (const std::exception& e)
17251740 {
@@ -1732,12 +1747,12 @@ public:
17321747 }
17331748
17341749 std::unique_ptr<Instrument, InstrumentDeleter> pInstRef(reinterpret_cast<Instrument*>(safe_calloc(sizeof(Instrument), 1)));
1735- it->RefInstruments.push_back(pInstRef.get());
1736- pInstRef->type = it->pInstrument->type;
1737- pInstRef->instname = safe_strdup(it->pInstrument->instname);
1738- pInstRef->samples = it->pInstrument->samples;
1739- pInstRef->sample = reinterpret_cast<Sample*>(safe_calloc(sizeof(Sample), it->pInstrument->samples));
1740- std::copy_n(it->pInstrument->sample, it->pInstrument->samples, pInstRef->sample);
1750+ it->second.RefInstruments.push_back(pInstRef.get());
1751+ pInstRef->type = it->second.pInstrument->type;
1752+ pInstRef->instname = safe_strdup(it->second.pInstrument->instname);
1753+ pInstRef->samples = it->second.pInstrument->samples;
1754+ pInstRef->sample = reinterpret_cast<Sample*>(safe_calloc(sizeof(Sample), it->second.pInstrument->samples));
1755+ std::copy_n(it->second.pInstrument->sample, it->second.pInstrument->samples, pInstRef->sample);
17411756 std::for_each(pInstRef->sample, pInstRef->sample + pInstRef->samples, [] (auto&& x) { x.data_alloced = false; });
17421757
17431758 return pInstRef.release();
@@ -1753,16 +1768,16 @@ public:
17531768 m_Instruments.end(),
17541769 [pInstrument] (auto&& x)
17551770 {
1756- auto it = std::find(x.RefInstruments.begin(), x.RefInstruments.end(), pInstrument);
1757- return it != x.RefInstruments.end();
1771+ auto it = std::find(x.second.RefInstruments.begin(), x.second.RefInstruments.end(), pInstrument);
1772+ return it != x.second.RefInstruments.end();
17581773 }
17591774 );
17601775
17611776 if (it != m_Instruments.end())
17621777 {
1763- it->RefInstruments.erase(std::find(it->RefInstruments.begin(), it->RefInstruments.end(), pInstrument));
1778+ it->second.RefInstruments.erase(std::find(it->second.RefInstruments.begin(), it->second.RefInstruments.end(), pInstrument));
17641779
1765- if (it->RefInstruments.empty())
1780+ if (it->second.RefInstruments.empty())
17661781 {
17671782 m_Instruments.erase(it);
17681783 }
@@ -1775,7 +1790,7 @@ public:
17751790 }
17761791
17771792 private:
1778- std::vector<InstrumentCacheEntry> m_Instruments;
1793+ std::unordered_map<std::string, InstrumentCacheEntry> m_Instruments;
17791794 };
17801795
17811796 InstrumentCache GlobalInstrumentCache;
--- a/timidity/sndfont.c
+++ b/timidity/sndfont.c
@@ -470,13 +470,17 @@ static void init_sf(SFInsts *rec)
470470 int bank = sfinfo.preset[i].bank;
471471 int preset = sfinfo.preset[i].preset;
472472
473- if (bank == 128)
473+ if (bank == 128 && 0 <= preset && preset < 128 + MAP_BANK_COUNT)
474474 /* FIXME: why not allow exclusion of drumsets? */
475475 alloc_instrument_bank(1, preset);
476- else {
476+ else if (0 <= bank && bank < 128 + MAP_BANK_COUNT) {
477477 if (is_excluded(rec, bank, preset, -1))
478478 continue;
479479 alloc_instrument_bank(0, bank);
480+ } else {
481+ ctl->cmsg(CMSG_ERROR, VERB_VERBOSE, "%s: bank/preset is out of range [bank = %d, preset = %d]",
482+ FILENAME_REDUCED(rec->fname), bank, preset);
483+ continue;
480484 }
481485 load_font(&sfinfo, i);
482486 }
--- a/timidity/thread_mix.c
+++ b/timidity/thread_mix.c
@@ -429,7 +429,6 @@ void mix_voice_thread(DATA_T *buf, int v, int32 c, int thread)
429429 recompute_resample_filter(v);
430430 }
431431 apply_envelope_to_amp(v);
432-#ifdef INT_SYNTH
433432 switch(vp->sample->inst_type){
434433 case INST_GUS:
435434 case INST_SF2:
@@ -451,24 +450,15 @@ void mix_voice_thread(DATA_T *buf, int v, int32 c, int thread)
451450 resample_filter(v, sp, c);
452451 }
453452 break;
453+#ifdef INT_SYNTH
454454 case INST_MMS:
455455 compute_voice_mms_thread(v, sp, c, thread);
456456 break;
457457 case INST_SCC:
458458 compute_voice_scc_thread(v, sp, c, thread);
459459 break;
460- }
461-#else
462- if(opt_resample_over_sampling){
463- int32 c2 = c * opt_resample_over_sampling;
464- resample_voice(v, sp, c2);
465- resample_filter(v, sp, c2);
466- resample_down_sampling(sp, c);
467- }else{
468- resample_voice(v, sp, c);
469- resample_filter(v, sp, c);
470- }
471460 #endif
461+ }
472462 #ifdef VOICE_EFFECT
473463 voice_effect(v, sp, c);
474464 #endif
--- a/timidity/timidity.c
+++ b/timidity/timidity.c
@@ -5776,7 +5776,7 @@ static int parse_opt_h(const char *arg)
57765776 #endif
57775777 {
57785778 static char *help_list[] = {
5779-"TiMidity++ %s (C) 1999-2004 Masanao Izumo <iz@onicos.co.jp>",
5779+"TiMidity++ %s (C) 1999-2018 Masanao Izumo <iz@onicos.co.jp>",
57805780 "The original version (C) 1995 Tuukka Toivonen <tt@cgs.fi>",
57815781 "TiMidity is free software and comes with ABSOLUTELY NO WARRANTY.",
57825782 "",
@@ -6258,64 +6258,64 @@ static int parse_opt_h(const char *arg)
62586258 fprintf(fp, "%s", h);
62596259 } else
62606260 fputs(h, fp);
6261- fputs(NLS, fp);
6262- }
6263- fputs(NLS, fp);
6264- fputs("Effect options (-EF, --ext=F option):" NLS
6265-" -EFdelay=d Disable delay effect (default)" NLS
6266-" -EFdelay=D Enable delay effect" NLS
6267-" -EFchorus=d Disable MIDI chorus effect control" NLS
6268-" -EFchorus=n Enable Normal MIDI chorus effect control" NLS
6269-" [,level] `level' is optional to specify chorus level [0..127]" NLS
6270-" (default)" NLS
6271-" -EFchorus=s Surround sound, chorus detuned to a lesser degree" NLS
6272-" [,level] `level' is optional to specify chorus level [0..127]" NLS
6273-" -EFreverb=d Disable MIDI reverb effect control" NLS
6261+ fputs("\n", fp);
6262+ }
6263+ fputs("\n", fp);
6264+ fputs("Effect options (-EF, --ext=F option):" "\n"
6265+" -EFdelay=d Disable delay effect (default)" "\n"
6266+" -EFdelay=D Enable delay effect" "\n"
6267+" -EFchorus=d Disable MIDI chorus effect control" "\n"
6268+" -EFchorus=n Enable Normal MIDI chorus effect control" "\n"
6269+" [,level] `level' is optional to specify chorus level [0..127]" "\n"
6270+" (default)" "\n"
6271+" -EFchorus=s Surround sound, chorus detuned to a lesser degree" "\n"
6272+" [,level] `level' is optional to specify chorus level [0..127]" "\n"
6273+" -EFreverb=d Disable MIDI reverb effect control" "\n"
62746274 #if !defined(REVERB_CONTROL_ALLOW) && !defined(FREEVERB_CONTROL_ALLOW)
6275-" (default)" NLS
6275+" (default)" "\n"
62766276 #endif
6277-" -EFreverb=n Enable Normal MIDI reverb effect control" NLS
6278-" [,level] `level' is optional to specify reverb level [1..127]" NLS
6277+" -EFreverb=n Enable Normal MIDI reverb effect control" "\n"
6278+" [,level] `level' is optional to specify reverb level [1..127]" "\n"
62796279 #if defined(REVERB_CONTROL_ALLOW)
6280-" (default)" NLS
6280+" (default)" "\n"
62816281 #endif
6282-" -EFreverb=g Global reverb effect" NLS
6283-" [,level] `level' is optional to specify reverb level [1..127]" NLS
6284-" -EFreverb=f Enable Freeverb MIDI reverb effect control" NLS
6285-" [,level] `level' is optional to specify reverb level [1..127]" NLS
6282+" -EFreverb=g Global reverb effect" "\n"
6283+" [,level] `level' is optional to specify reverb level [1..127]" "\n"
6284+" -EFreverb=f Enable Freeverb MIDI reverb effect control" "\n"
6285+" [,level] `level' is optional to specify reverb level [1..127]" "\n"
62866286 #if !defined(REVERB_CONTROL_ALLOW) && defined(FREEVERB_CONTROL_ALLOW)
6287-" (default)" NLS
6287+" (default)" "\n"
62886288 #endif
6289-" -EFreverb=G Global Freeverb effect" NLS
6290-" [,level] `level' is optional to specify reverb level [1..127]" NLS
6291-" -EFvlpf=d Disable voice LPF" NLS
6289+" -EFreverb=G Global Freeverb effect" "\n"
6290+" [,level] `level' is optional to specify reverb level [1..127]" "\n"
6291+" -EFvlpf=d Disable voice LPF" "\n"
62926292 #if !defined(VOICE_MOOG_LPF_ALLOW) && !defined(VOICE_CHAMBERLIN_LPF_ALLOW)
6293-" (default)" NLS
6293+" (default)" "\n"
62946294 #endif
6295-" -EFvlpf=c Enable Chamberlin resonant LPF (12dB/oct)" NLS
6295+" -EFvlpf=c Enable Chamberlin resonant LPF (12dB/oct)" "\n"
62966296 #if defined(VOICE_CHAMBERLIN_LPF_ALLOW)
6297-" (default)" NLS
6297+" (default)" "\n"
62986298 #endif
6299-" -EFvlpf=m Enable Moog resonant lowpass VCF (24dB/oct)" NLS
6299+" -EFvlpf=m Enable Moog resonant lowpass VCF (24dB/oct)" "\n"
63006300 #if defined(VOICE_MOOG_LPF_ALLOW) && !defined(VOICE_CHAMBERLIN_LPF_ALLOW)
6301-" (default)" NLS
6302-#endif
6303-" -EFvlpf=b Enable ButterworthFilter resonant lowpass (butterworth)" NLS
6304-" -EFvlpf=i Enable Resonant IIR lowpass VCF (12dB/oct)-2" NLS
6305-" -EFvlpf=a Enable amSynth resonant lowpass VCF (24dB/oct)-2" NLS
6306-" -EFvlpf=o Enable 1 pole 6db/oct resonant lowpass VCF (6dB/oct)" NLS
6307-" -EFvlpf=e Enable resonant 3 pole lowpass VCF (18dB/oct)" NLS
6308-" -EFvlpf=t Enable two first order lowpass VCF " NLS
6309-" -EFvlpf=h Enable HPF ButterworthFilter VCF (butterworth)" NLS
6310-" -EFvlpf=B Enable BPF ButterworthFilter VCF (butterworth)" NLS
6311-" -EFns=n Enable the n'th degree (type) noise shaping filter" NLS
6312-" n:[0..4] (for 8-bit linear encoding, default is 4)" NLS
6313-" n:[0..4] (for 16-bit linear encoding, default is 4)" NLS
6314-" n:[0] (for 24-bit linear encoding, default is 0)" NLS
6315-" n:[0] (for 32-bit linear encoding, default is 0)" NLS
6316-" n:[0] (for 64-bit linear encoding, default is 0)" NLS
6317-" n:[0] (for float 32-bit linear encoding, default is 0)" NLS
6318-" n:[0] (for float 64-bit linear encoding, default is 0)" NLS, fp);
6301+" (default)" "\n"
6302+#endif
6303+" -EFvlpf=b Enable ButterworthFilter resonant lowpass (butterworth)" "\n"
6304+" -EFvlpf=i Enable Resonant IIR lowpass VCF (12dB/oct)-2" "\n"
6305+" -EFvlpf=a Enable amSynth resonant lowpass VCF (24dB/oct)-2" "\n"
6306+" -EFvlpf=o Enable 1 pole 6db/oct resonant lowpass VCF (6dB/oct)" "\n"
6307+" -EFvlpf=e Enable resonant 3 pole lowpass VCF (18dB/oct)" "\n"
6308+" -EFvlpf=t Enable two first order lowpass VCF " "\n"
6309+" -EFvlpf=h Enable HPF ButterworthFilter VCF (butterworth)" "\n"
6310+" -EFvlpf=B Enable BPF ButterworthFilter VCF (butterworth)" "\n"
6311+" -EFns=n Enable the n'th degree (type) noise shaping filter" "\n"
6312+" n:[0..4] (for 8-bit linear encoding, default is 4)" "\n"
6313+" n:[0..4] (for 16-bit linear encoding, default is 4)" "\n"
6314+" n:[0] (for 24-bit linear encoding, default is 0)" "\n"
6315+" n:[0] (for 32-bit linear encoding, default is 0)" "\n"
6316+" n:[0] (for 64-bit linear encoding, default is 0)" "\n"
6317+" n:[0] (for float 32-bit linear encoding, default is 0)" "\n"
6318+" n:[0] (for float 64-bit linear encoding, default is 0)" "\n", fp);
63196319 #ifndef FIXED_RESAMPLATION
63206320 #ifdef HAVE_STRINGIZE
63216321 #define tim_str_internal(x) #x
@@ -6326,147 +6326,147 @@ static int parse_opt_h(const char *arg)
63266326 fputs(" -EFresamp=d Disable resamplation", fp);
63276327 if (! strcmp(tim_str(DEFAULT_RESAMPLATION), "resample_none"))
63286328 fputs(" (default)", fp);
6329- fputs(NLS, fp);
6329+ fputs("\n", fp);
63306330 fputs(" -EFresamp=l Enable Linear resample algorithm", fp);
63316331 if (! strcmp(tim_str(DEFAULT_RESAMPLATION), "resample_linear"))
63326332 fputs(" (default)", fp);
6333- fputs(NLS, fp);
6333+ fputs("\n", fp);
63346334 fputs(" -EFresamp=c Enable C-spline resample algorithm", fp);
63356335 if (! strcmp(tim_str(DEFAULT_RESAMPLATION), "resample_cspline"))
63366336 fputs(" (default)", fp);
6337- fputs(NLS, fp);
6337+ fputs("\n", fp);
63386338 fputs(" -EFresamp=L Enable Lagrange resample algorithm", fp);
63396339 if (! strcmp(tim_str(DEFAULT_RESAMPLATION), "resample_lagrange"))
63406340 fputs(" (default)", fp);
6341- fputs(NLS, fp);
6341+ fputs("\n", fp);
63426342 fputs(" -EFresamp=n Enable Newton resample algorithm", fp);
63436343 if (! strcmp(tim_str(DEFAULT_RESAMPLATION), "resample_newton"))
63446344 fputs(" (default)", fp);
6345- fputs(NLS, fp);
6345+ fputs("\n", fp);
63466346 fputs(" -EFresamp=g Enable Gauss-like resample algorithm", fp);
63476347 if (! strcmp(tim_str(DEFAULT_RESAMPLATION), "resample_gauss"))
63486348 fputs(" (default)", fp);
63496349 ///r
6350- fputs(NLS, fp);
6350+ fputs("\n", fp);
63516351 fputs(" -EFresamp=s Enable Sharp resample algorithm", fp);
63526352 if (! strcmp(tim_str(DEFAULT_RESAMPLATION), "resample_sharp"))
63536353 fputs(" (default)", fp);
6354- fputs(NLS, fp);
6354+ fputs("\n", fp);
63556355 fputs(" -EFresamp=p Enable LinearP resample algorithm", fp);
63566356 if (! strcmp(tim_str(DEFAULT_RESAMPLATION), "resample_linear_p"))
63576357 fputs(" (default)", fp);
6358- fputs(NLS
6359-" -EFresamp affects the behavior of -N option" NLS, fp);
6360-#endif
6361- fputs(NLS, fp);
6362- fputs("Alternative TiMidity sequencer extensional mode long options:" NLS
6363-" --[no-]mod-wheel" NLS
6364-" --[no-]portamento" NLS
6365-" --[no-]vibrato" NLS
6366-" --[no-]ch-pressure" NLS
6367-" --[no-]mod-envelope" NLS
6368-" --[no-]trace-text-meta" NLS
6369-" --[no-]overlap-voice" NLS
6358+ fputs("\n"
6359+" -EFresamp affects the behavior of -N option" "\n", fp);
6360+#endif
6361+ fputs("\n", fp);
6362+ fputs("Alternative TiMidity sequencer extensional mode long options:" "\n"
6363+" --[no-]mod-wheel" "\n"
6364+" --[no-]portamento" "\n"
6365+" --[no-]vibrato" "\n"
6366+" --[no-]ch-pressure" "\n"
6367+" --[no-]mod-envelope" "\n"
6368+" --[no-]trace-text-meta" "\n"
6369+" --[no-]overlap-voice" "\n"
63706370 ///r
6371-" --overlap-voice-count=n" NLS
6372-" --[no-]temper-control" NLS
6373-" --default-mid=<HH>" NLS
6374-" --system-mid=<HH>" NLS
6375-" --default-bank=n" NLS
6376-" --force-bank=n" NLS
6377-" --default-program=n/m" NLS
6378-" --force-program=n/m" NLS
6379-" --delay=(d|D)" NLS
6380-" --chorus=(d|n|s|w|W|b|B|t|T|h|H|e|E)[,level]" NLS
6381-" --reverb=(d|n|g|f|G)[,level]" NLS
6382-" --reverb=(f|G)[,level[,scaleroom[,offsetroom[,predelay]]]]" NLS
6383-" --voice-lpf=(d|c|m|b|i|a|o|e|t|h|B)" NLS
6384-" --noise-shaping=n" NLS, fp);
6371+" --overlap-voice-count=n" "\n"
6372+" --[no-]temper-control" "\n"
6373+" --default-mid=<HH>" "\n"
6374+" --system-mid=<HH>" "\n"
6375+" --default-bank=n" "\n"
6376+" --force-bank=n" "\n"
6377+" --default-program=n/m" "\n"
6378+" --force-program=n/m" "\n"
6379+" --delay=(d|D)" "\n"
6380+" --chorus=(d|n|s|w|W|b|B|t|T|h|H|e|E)[,level]" "\n"
6381+" --reverb=(d|n|g|f|G)[,level]" "\n"
6382+" --reverb=(f|G)[,level[,scaleroom[,offsetroom[,predelay]]]]" "\n"
6383+" --voice-lpf=(d|c|m|b|i|a|o|e|t|h|B)" "\n"
6384+" --noise-shaping=n" "\n", fp);
63856385 #ifndef FIXED_RESAMPLATION
6386- fputs(" --resample=(d|l|c|L|n|g|s|p)" NLS, fp);
6386+ fputs(" --resample=(d|l|c|L|n|g|s|p)" "\n", fp);
63876387 #endif
6388- fputs(NLS, fp);
6389- fputs("Available interfaces (-i, --interface option):" NLS, fp);
6388+ fputs("\n", fp);
6389+ fputs("Available interfaces (-i, --interface option):" "\n", fp);
63906390 for (cmpp = ctl_list; (cmp = *cmpp) != NULL; cmpp++)
6391- fprintf(fp, " -i%c %s" NLS,
6391+ fprintf(fp, " -i%c %s" "\n",
63926392 cmp->id_character, cmp->id_name);
63936393 #ifdef IA_DYNAMIC
6394- fprintf(fp, "Supported dynamic load interfaces (%s):" NLS,
6394+ fprintf(fp, "Supported dynamic load interfaces (%s):" "\n",
63956395 dynamic_lib_root);
63966396 memset(mark, 0, sizeof(mark));
63976397 for (cmpp = ctl_list; (cmp = *cmpp) != NULL; cmpp++)
63986398 mark[(int) cmp->id_character] = 1;
63996399 list_dyna_interface(fp, dynamic_lib_root, mark);
64006400 #endif /* IA_DYNAMIC */
6401- fputs(NLS, fp);
6402- fputs("Interface options (append to -i? option):" NLS
6403-" `v' more verbose (cumulative)" NLS
6404-" `q' quieter (cumulative)" NLS
6405-" `t' trace playing" NLS
6406-" `l' loop playing (some interface ignore this option)" NLS
6407-" `r' randomize file list arguments before playing" NLS
6408-" `s' sorting file list arguments before playing" NLS, fp);
6401+ fputs("\n", fp);
6402+ fputs("Interface options (append to -i? option):" "\n"
6403+" `v' more verbose (cumulative)" "\n"
6404+" `q' quieter (cumulative)" "\n"
6405+" `t' trace playing" "\n"
6406+" `l' loop playing (some interface ignore this option)" "\n"
6407+" `r' randomize file list arguments before playing" "\n"
6408+" `s' sorting file list arguments before playing" "\n", fp);
64096409 #ifdef IA_ALSASEQ
64106410 fputs(" `D' daemonize TiMidity++ in background "
6411- "(for alsaseq only)" NLS, fp);
6412-#endif
6413- fputs(NLS, fp);
6414- fputs("Alternative interface long options:" NLS
6415-" --verbose=n" NLS
6416-" --quiet=n" NLS
6417-" --[no-]trace" NLS
6418-" --[no-]loop" NLS
6419-" --[no-]random" NLS
6420-" --[no-]sort" NLS, fp);
6411+ "(for alsaseq only)" "\n", fp);
6412+#endif
6413+ fputs("\n", fp);
6414+ fputs("Alternative interface long options:" "\n"
6415+" --verbose=n" "\n"
6416+" --quiet=n" "\n"
6417+" --[no-]trace" "\n"
6418+" --[no-]loop" "\n"
6419+" --[no-]random" "\n"
6420+" --[no-]sort" "\n", fp);
64216421 #ifdef IA_ALSASEQ
6422- fputs(" --[no-]background" NLS, fp);
6422+ fputs(" --[no-]background" "\n", fp);
64236423 #endif
6424- fputs(NLS, fp);
6425- fputs("Available output modes (-O, --output-mode option):" NLS, fp);
6424+ fputs("\n", fp);
6425+ fputs("Available output modes (-O, --output-mode option):" "\n", fp);
64266426 for (pmpp = play_mode_list; (pmp = *pmpp) != NULL; pmpp++)
6427- fprintf(fp, " -O%c %s" NLS,
6427+ fprintf(fp, " -O%c %s" "\n",
64286428 pmp->id_character, pmp->id_name);
6429- fputs(NLS, fp);
6430- fputs("Output format options (append to -O? option):" NLS
6431-" `S' stereo" NLS
6432-" `M' monophonic" NLS
6433-" `s' signed output" NLS
6434-" `u' unsigned output" NLS
6435-" `1' 16-bit sample width" NLS
6436-" `2' 24-bit sample width" NLS
6437-" `3' 32-bit sample width" NLS
6438-" `6' 64-bit sample width" NLS
6439-" `8' 8-bit sample width" NLS
6440-" `f' float 32-bit sample width" NLS
6441-" `D' float 64-bit sample width" NLS
6442-" `l' linear encoding" NLS
6443-" `U' U-Law encoding" NLS
6444-" `A' A-Law encoding" NLS
6445-" `x' byte-swapped output" NLS, fp);
6446- fputs(NLS, fp);
6447- fputs("Alternative output format long options:" NLS
6448-" --output-stereo" NLS
6449-" --output-mono" NLS
6450-" --output-signed" NLS
6451-" --output-unsigned" NLS
6452-" --output-16bit" NLS
6453-" --output-24bit" NLS
6454-" --output-32bit" NLS
6455-" --output-64bit" NLS
6456-" --output-8bit" NLS
6457-" --output-f32bit" NLS
6458-" --output-float32bit" NLS
6459-" --output-f64bit" NLS
6460-" --output-float64bit" NLS
6461-" --output-linear" NLS
6462-" --output-ulaw" NLS
6463-" --output-alaw" NLS
6464-" --[no-]output-swab" NLS, fp);
6465- fputs(NLS, fp);
6466- fputs("Available WRD interfaces (-W, --wrd option):" NLS, fp);
6429+ fputs("\n", fp);
6430+ fputs("Output format options (append to -O? option):" "\n"
6431+" `S' stereo" "\n"
6432+" `M' monophonic" "\n"
6433+" `s' signed output" "\n"
6434+" `u' unsigned output" "\n"
6435+" `1' 16-bit sample width" "\n"
6436+" `2' 24-bit sample width" "\n"
6437+" `3' 32-bit sample width" "\n"
6438+" `6' 64-bit sample width" "\n"
6439+" `8' 8-bit sample width" "\n"
6440+" `f' float 32-bit sample width" "\n"
6441+" `D' float 64-bit sample width" "\n"
6442+" `l' linear encoding" "\n"
6443+" `U' U-Law encoding" "\n"
6444+" `A' A-Law encoding" "\n"
6445+" `x' byte-swapped output" "\n", fp);
6446+ fputs("\n", fp);
6447+ fputs("Alternative output format long options:" "\n"
6448+" --output-stereo" "\n"
6449+" --output-mono" "\n"
6450+" --output-signed" "\n"
6451+" --output-unsigned" "\n"
6452+" --output-16bit" "\n"
6453+" --output-24bit" "\n"
6454+" --output-32bit" "\n"
6455+" --output-64bit" "\n"
6456+" --output-8bit" "\n"
6457+" --output-f32bit" "\n"
6458+" --output-float32bit" "\n"
6459+" --output-f64bit" "\n"
6460+" --output-float64bit" "\n"
6461+" --output-linear" "\n"
6462+" --output-ulaw" "\n"
6463+" --output-alaw" "\n"
6464+" --[no-]output-swab" "\n", fp);
6465+ fputs("\n", fp);
6466+ fputs("Available WRD interfaces (-W, --wrd option):" "\n", fp);
64676467 for (wlpp = wrdt_list; (wlp = *wlpp) != NULL; wlpp++)
6468- fprintf(fp, " -W%c %s" NLS, wlp->id, wlp->name);
6469- fputs(NLS, fp);
6468+ fprintf(fp, " -W%c %s" "\n", wlp->id, wlp->name);
6469+ fputs("\n", fp);
64706470 close_pager(fp);
64716471 exit(EXIT_SUCCESS);
64726472 return 0; // dummy call
Show on old repository browser