OSDN Git Service

Import unkotim227 unkotim227
authorStarg <starg@users.osdn.me>
Thu, 25 Jul 2019 07:49:14 +0000 (16:49 +0900)
committerStarg <starg@users.osdn.me>
Thu, 25 Jul 2019 07:49:14 +0000 (16:49 +0900)
31 files changed:
interface/portmidisyn_c.c
interface/rtsyn_common.c
interface/vt100.c
interface/vt100.h
interface/vt100_c.c
interface/w32g_c.c
interface/w32g_i.c
interface/w32g_pref.c
interface/w32g_pref.h
pdcurses/pdcurses.vcxproj
sf_view_gui/CMakeLists.txt
sf_view_gui/mysndfont.c
sf_view_gui/resource.h
sf_view_gui/sfview_dlg.rc
sf_view_gui/sfview_main.cpp
tim_cui/tim_cui.vcproj
tim_cui/tim_cui.vcxproj
timidity/common.c
timidity/dls.cpp
timidity/dls.h
timidity/instrum.c
timidity/mfi.c
timidity/mix.c
timidity/output.h
timidity/playmidi.c
timidity/playmidi.h
timidity/resample.c
timidity/sfz.cpp
timidity/sndfont.c
timidity/thread_mix.c
timidity/timidity.c

index 8793808..88d934f 100755 (executable)
@@ -96,8 +96,8 @@ extern int seq_quit;
 
 static int ctl_open(int using_stdin, int using_stdout);
 static void ctl_close(void);
-static int ctl_read(int32 *valp);
-static int cmsg(int type, int verbosity_level, char *fmt, ...);
+static int ctl_read(ptr_size_t *valp);
+static int cmsg(int type, int verbosity_level, const char *fmt, ...);
 static void ctl_event(CtlEvent *e);
 static int ctl_pass_playing_list(int n, char *args[]);
 
@@ -135,27 +135,29 @@ static FILE *outfp;
 
 static int ctl_open(int using_stdin, int using_stdout)
 {
-       ctl.opened = 1;
-       ctl.flags &= ~(CTLF_LIST_RANDOM|CTLF_LIST_SORT);
-       if (using_stdout)
-               outfp = stderr;
-       else
-               outfp = stdout;
-       return 0;
+    rtsyn_pm_setup();
+
+    ctl.opened = 1;
+    ctl.flags &= ~(CTLF_LIST_RANDOM | CTLF_LIST_SORT);
+    if (using_stdout)
+        outfp = stderr;
+    else
+        outfp = stdout;
+    return 0;
 }
 
 static void ctl_close(void)
 {
-  fflush(outfp);
-  if(seq_quit==0){
-       rtsyn_synth_stop();
-       rtsyn_close();
-       seq_quit=~0;
-  }    
-  ctl.opened=0;
+    fflush(outfp);
+    if (seq_quit == 0) {
+        rtsyn_synth_stop();
+        rtsyn_close();
+        seq_quit = ~0;
+    }
+    ctl.opened = 0;
 }
 
-static int ctl_read(int32 *valp)
+static int ctl_read(ptr_size_t *valp)
 {
     return RC_NONE;
 }
@@ -164,50 +166,47 @@ static int ctl_read(int32 *valp)
 extern void PutsConsoleWnd(const char *str);
 extern int ConsoleWndFlag;
 #endif
-static int cmsg(int type, int verbosity_level, char *fmt, ...)
+static int cmsg(int type, int verbosity_level, const char *fmt, ...)
 {
 #ifndef IA_W32G_SYN
+    va_list ap;
 
-       va_list ap;
-
-  if ((type==CMSG_TEXT || type==CMSG_INFO || type==CMSG_WARNING) &&
-      ctl.verbosity<verbosity_level)
-    return 0;
-  va_start(ap, fmt);
-  if(type == CMSG_WARNING || type == CMSG_ERROR || type == CMSG_FATAL)
-      dumb_error_count++;
-  if (!ctl.opened)
-    {
-      vfprintf(stderr, fmt, ap);
-      fputs(NLS, stderr);
+    if ((type == CMSG_TEXT || type == CMSG_INFO || type == CMSG_WARNING) &&
+            ctl.verbosity < verbosity_level)
+        return 0;
+    va_start(ap, fmt);
+    if (type == CMSG_WARNING || type == CMSG_ERROR || type == CMSG_FATAL)
+        dumb_error_count++;
+    if (!ctl.opened) {
+        vfprintf(stderr, fmt, ap);
+        fputs(NLS, stderr);
     }
-  else
-    {
-      vfprintf(outfp, fmt, ap);
-      fputs(NLS, outfp);
-      fflush(outfp);
+    else {
+        vfprintf(outfp, fmt, ap);
+        fputs(NLS, outfp);
+        fflush(outfp);
     }
-  va_end(ap);
-
-#else
-       if ( !ConsoleWndFlag ) return 0;
-       {
-    char buffer[1024];
-    va_list ap;
-    va_start(ap, fmt);
-    vsnprintf(buffer, sizeof(buffer), fmt, ap);
     va_end(ap);
+#else
+    if (!ConsoleWndFlag) return 0;
 
-    if((type==CMSG_TEXT || type==CMSG_INFO || type==CMSG_WARNING) &&
-       ctl.verbosity<verbosity_level) 
-       return 0;
-//    if(type == CMSG_FATAL)
-//     w32g_msg_box(buffer, "TiMidity Error", MB_OK);
-    PutsConsoleWnd(buffer);
-    PutsConsoleWnd("\n");
-    return 0;
-       }
-#endif
+    {
+        char buffer[1024];
+        va_list ap;
+        va_start(ap, fmt);
+        vsnprintf(buffer, sizeof(buffer), fmt, ap);
+        va_end(ap);
+
+        if ((type == CMSG_TEXT || type == CMSG_INFO || type == CMSG_WARNING) &&
+                ctl.verbosity < verbosity_level)
+            return 0;
+//      if (type == CMSG_FATAL)
+//          w32g_msg_box(buffer, "TiMidity Error", MB_OK);
+        PutsConsoleWnd(buffer);
+        PutsConsoleWnd("\n");
+        return 0;
+    }
+#endif /* !IA_W32G_SYN */
 
     return 0;
 }
@@ -218,206 +217,221 @@ static void ctl_event(CtlEvent *e)
 
 static void doit(void);
 
-#ifdef IA_W32G_SYN
-extern void w32g_syn_doit(void);
-extern int w32g_syn_ctl_pass_playing_list(int n_, char *args_[]);
-
-
-static int ctl_pass_playing_list(int n, char *args[])
-{
-       return w32g_syn_ctl_pass_playing_list ( n, args );
-}
-#endif
-
 #ifndef IA_W32G_SYN
 static int ctl_pass_playing_list(int n, char *args[])
 #else
 // 0: OK, 2: Require to reset.
-static int ctl_pass_playing_list2(int n, char *args[])
+int ctl_pass_playing_list2(int n, char *args[])
 #endif
 {
-       int i, j,devnum,devok;
-       unsigned int port=0 ;
-       int started;
-       char cbuf[80];
+    int i, j, devnum, devok;
+    unsigned int port = 0;
+    int started;
+    char cbuf[80];
 #if defined(__W32__) && defined(FORCE_TIME_PERIOD)
-       TIMECAPS tcaps;
+    TIMECAPS tcaps;
 #endif /* __W32__ && FORCE_TIME_PERIOD */
 
-rtsyn_get_port_list();
+    rtsyn_get_port_list();
 
 #ifndef IA_W32G_SYN
-       if(n > MAX_PORT ){
-               printf( "Usage: timidity -iW [Midi interface No s]\n");
-               return 1;
-       }
+    if (n > MAX_PORT) {
+        ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
+                 "Usage: timidity -i%c [Midi interface No s]" NLS, ctl.id_character);
+        return 1;
+    }
 #endif
 
-       if(n>0){
-               port=0;
-               while(port<n && n!=0){
-                       if( (portID[port] = atoi(args[port]))==0 ){
-                               n=0;
-                       }else{
-                               devok=0;
-                               for(i=0;i<rtsyn_nportlist;i++){
-                                       sscanf( rtsyn_portlist[i],"%d:%s",&devnum,cbuf);
-                                       if(devnum==portID[port]) devok=1;
-                               }
-                               if(devok==0){
-                                       n=0;
+    if (rtsyn_nportlist == 0) {
+        ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
+                 "Opening Device drivers:" "MIDI IN device is not found" NLS);
+        return 2;
+    }
+
+    if (n > 0) {
+        port = 0;
+        while (port < n && n != 0) {
+            if ((portID[port] = atoi(args[port])) == 0) {
+                n = 0;
+            } else {
+                devok = 0;
+                for (i = 0; i < rtsyn_nportlist; i++) {
+                    sscanf(rtsyn_portlist[i], "%d:%s", &devnum, cbuf);
+                    if (devnum == portID[port]) devok = 1;
+                }
+                if (devok == 0) {
+                    n = 0;
 #ifdef IA_W32G_SYN
-                                       {
-                                               char buff[1024];
-                                               sprintf ( buff, "MIDI IN Device ID %d is not available. So set a proper ID for the MIDI port %d and restart.", portID[port], port );
-                                               MessageBox ( NULL, buff, "Error", MB_OK );
-                                               return 2;
-                                       }
+                    {
+                        char buff[1024];
+                        sprintf(buff, "MIDI IN Device ID %d is not available. So set a proper ID for the MIDI port %d and restart.", portID[port], port);
+                        MessageBoxA(NULL, buff, "Error", MB_OK);
+                        return 2;
+                    }
 #endif
-                               }
-                       }
-               port++;
-               }
-       }
-       if(n==0){
-               rtsyn_portnumber=0;
-       }else{
-               rtsyn_portnumber=port;
-       }
+                }
+            }
+            port++;
+        }
+    }
+    if (n == 0) {
+        rtsyn_portnumber = 0;
+    } else {
+        rtsyn_portnumber = port;
+    }
 
 #if !defined(IA_W32G_SYN) && !defined(USE_GTK_GUI)
-       if(n==0){
-               char cbuf[80];
-               printf("Whow many ports do you use?(max %d)\n",MAX_PORT);
-               do{
-                       if (0==scanf("%u",&rtsyn_portnumber)) scanf("%s",cbuf);
-               }while(rtsyn_portnumber == 0 ||rtsyn_portnumber > MAX_PORT);
-               printf("\n");
-               printf("Opening Device drivers:");
-               printf("Available Midi Input devices:\n");
-
-               for(i=0;i<rtsyn_nportlist;i++){
-                       printf("%s\n",rtsyn_portlist[i]);
-               }
-               for(port=0;port<rtsyn_portnumber;port++){
-                       printf("Keyin Input Device Number of port%d\n",port+1);
-                       do{
-                               devok=0;
-                               if (0==scanf("%u",&portID[port])) scanf("%s",cbuf);
-                               for(i=0;i<rtsyn_nportlist;i++){
-                                       sscanf( rtsyn_portlist[i],"%d:%s",&devnum,cbuf);
-                                       if(devnum==portID[port]) devok=1;
-                               }
-                       }while(devok==0);
-                       printf("\n");                   
-               }
-       }
+    if (n == 0) {
+        char cbuf[MAX_RTSYN_PORTLIST_LEN + 8], fmt[64];
+        ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
+                 "Whow many ports do you use?(max %d)" NLS, MAX_PORT);
+        do {
+            snprintf(fmt, sizeof(fmt), "%%.%ds", MAX_RTSYN_PORTLIST_LEN - 1);
+            if (0 == scanf("%u", &rtsyn_portnumber)) { scanf(fmt, cbuf); }
+        } while (intr == 0 &&
+                 (rtsyn_portnumber == 0 || rtsyn_portnumber > MAX_PORT));
+        ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
+                 "\nOpening Device drivers:" "Available Midi Input devices:" "%d" NLS, rtsyn_nportlist);
+
+        ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
+                 "NUM:NAME");
+        for (i = 0; i < rtsyn_nportlist; i++) {
+            ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
+                     "%s", rtsyn_portlist[i]);
+        }
+        ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
+                 "");
+
+        for (port = 0; port < rtsyn_portnumber; port++) {
+            ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
+                     "Keyin Input Device Number of port%d", port + 1);
+            do {
+                devok = 0;
+                snprintf(fmt, sizeof(fmt), "%%.%ds", MAX_RTSYN_PORTLIST_LEN - 1);
+                if (0 == scanf("%u", &portID[port])) { scanf(fmt, cbuf); }
+                for (i = 0; intr == 0 && i < rtsyn_nportlist; i++) {
+                    snprintf(fmt, sizeof(fmt), "%%d:%%.%ds", MAX_RTSYN_PORTLIST_LEN - 1);
+                    sscanf(rtsyn_portlist[i], fmt, &devnum, cbuf);
+                    if (devnum == portID[port]) devok = 1;
+                }
+            } while (devok == 0);
+            ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
+                     "");
+        }
+    }
 #endif
 
-       for(port=0;port<rtsyn_portnumber;port++){
-               portID[port]=portID[port]-1;
-       }
-
+    for (port = 0; port < rtsyn_portnumber; port++) {
+        portID[port] = portID[port] - 1;
+    }
 
 #if !defined(IA_W32G_SYN) && !defined(USE_GTK_GUI)
-       printf("TiMidity starting in PortMIDI Synthesizer mode\n");
-       printf("Usage: timidity -iP [Midi interface No]\n");
-       printf("\n");
-       printf("N (Normal mode) M(GM mode) S(GS mode) X(XG mode) \n");
-       printf("(Only in Normal mode, Mode can be changed by MIDI data)\n");
-       printf("m(GM reset) s(GS reset) x(XG reset)\n");
-       printf("\n");
-       printf("Press 'q' key to stop\n");
+    ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
+             "TiMidity starting in PortMIDI Synthesizer mode");
+    ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
+             "Usage: timidity -i%c [Midi interface No]" NLS, ctl.id_character);
+    ctl.cmsg(CMSG_WARNING, VERB_NORMAL, "c(Reset)");
+    ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
+             "N(Normal mode) M(GM mode) S(GS mode) X(XG mode) G(GM2 mode) D(SD mode) K(KG mode) J(CM mode)");
+    ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
+             "(Only in Normal mode, Mode can be changed by MIDI data)");
+    ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
+             "m(GM reset) s(GS reset) x(XG reset) g(GM2 reset) d(SD reset) k(KG reset) j(CM reset)" NLS);
+    ctl.cmsg(CMSG_WARNING, VERB_NORMAL,
+             "Press 'q' key to stop");
 #endif
 
-       rtsyn_init();
+    rtsyn_init();
 
-#ifdef USE_GTK_GUI
-       twgtk_main();
-#else 
 #if defined(__W32__) && defined(FORCE_TIME_PERIOD)
-       if (timeGetDevCaps(&tcaps, sizeof(TIMECAPS)) != TIMERR_NOERROR)
-               tcaps.wPeriodMin = 10;
-       timeBeginPeriod(tcaps.wPeriodMin);
+    if (timeGetDevCaps(&tcaps, sizeof(TIMECAPS)) != TIMERR_NOERROR)
+        tcaps.wPeriodMin = 10;
+    timeBeginPeriod(tcaps.wPeriodMin);
 #endif /* __W32__ && FORCE_TIME_PERIOD */
+
+#ifdef USE_GTK_GUI
+    twgtk_main();
+#else
 #ifdef IA_W32G_SYN
-       if(0!=rtsyn_synth_start()){
-               seq_quit=0;
-               while(seq_quit==0) {
-                       w32g_syn_doit();
-               }
-               rtsyn_synth_stop();
-       }
+    if (0 != rtsyn_synth_start()) {
+        seq_quit = 0;
+        while (seq_quit == 0) {
+            w32g_syn_doit();
+        }
+        rtsyn_synth_stop();
+    }
 #else
-       if(0!=rtsyn_synth_start()){
-               seq_quit=0;
-               while(seq_quit==0) {
-                       doit();
-               }
-               rtsyn_synth_stop();
-       }
+    if (0 != rtsyn_synth_start()) {
+        seq_quit = 0;
+        while (seq_quit == 0) {
+            doit();
+        }
+        rtsyn_synth_stop();
+    }
 #endif /* IA_W32G_SYN */
+#endif /* USE_GTK_GUI */
+
 #if defined(__W32__) && defined(FORCE_TIME_PERIOD)
-       timeEndPeriod(tcaps.wPeriodMin);
+    timeEndPeriod(tcaps.wPeriodMin);
 #endif /* __W32__ && FORCE_TIME_PERIOD */
-#endif /* USE_GTK_GUI */
-       rtsyn_close();
+    rtsyn_close();
 
-       return 0;
+    return 0;
 }
 
 
 #ifndef IA_W32G_SYN
 
-
 #ifndef __W32__
-static void init_keybord(void){
-       tcgetattr(0,&initial_settings);
-       tcgetattr(0,&new_settings);
-       new_settings.c_lflag &= ~ICANON;
-       new_settings.c_lflag &= ~ECHO;
-       new_settings.c_lflag &= ~ISIG;
-       new_settings.c_cc[VMIN] = 1;
-       new_settings.c_cc[VTIME] = 0;
-       tcsetattr(0, TCSANOW, &new_settings);
+static void init_keybord(void)
+{
+    tcgetattr(0, &initial_settings);
+    tcgetattr(0, &new_settings);
+    new_settings.c_lflag &= ~ICANON;
+    new_settings.c_lflag &= ~ECHO;
+    new_settings.c_lflag &= ~ISIG;
+    new_settings.c_cc[VMIN] = 1;
+    new_settings.c_cc[VTIME] = 0;
+    tcsetattr(0, TCSANOW, &new_settings);
 }
 
-static void close_keybord(void){
-       tcsetattr(0, TCSANOW, &initial_settings);
+static void close_keybord(void)
+{
+    tcsetattr(0, TCSANOW, &initial_settings);
 }
 
-static int kbhit(void){
-       char ch;
-       int nread;
-       
-       if(peek_character != -1)
-               return 1;
-       new_settings.c_cc[VMIN]=0;
-       tcsetattr(0,TCSANOW, &new_settings);
-       nread = read(0, &ch, 1);
-       new_settings.c_cc[VMIN]=1;
-       tcsetattr(0,TCSANOW, &new_settings);
-       
-       if(nread == 1) {
-               peek_character = ch;
-               return 1;
-       }
-       return 0;
+static int kbhit(void)
+{
+    char ch;
+    int nread;
+
+    if (peek_character != -1)
+        return 1;
+    new_settings.c_cc[VMIN] = 0;
+    tcsetattr(0, TCSANOW, &new_settings);
+    nread = read(0, &ch, 1);
+    new_settings.c_cc[VMIN] = 1;
+    tcsetattr(0, TCSANOW, &new_settings);
+
+    if (nread == 1) {
+        peek_character = ch;
+        return 1;
+    }
+    return 0;
 }
 
-
-static char readch(void){
-       char ch;
-       if(peek_character != -1){
-               ch = peek_character;
-               peek_character = -1;
-               return ch;
-       }
-       read(0,&ch,1);
-       return ch;
+static char readch(void)
+{
+    char ch;
+    if (peek_character != -1) {
+        ch = peek_character;
+        peek_character = -1;
+        return ch;
+    }
+    read(0, &ch, 1);
+    return ch;
 }
-#endif         
-
+#endif /* !__W32__ */
 
 static void doit(void)
 {
index d8cbc42..005adc2 100644 (file)
@@ -109,7 +109,7 @@ static double active_sensing_time = 0;
 
 /*
 #define EX_RESET_NO 7
-static char sysex_resets[EX_RESET_NO][11]={
+static uint8 sysex_resets[EX_RESET_NO][11]={
                '\xf0','\x7e','\x7f','\x09','\x00','\xf7','\x00','\x00','\x00','\x00','\x00',
                '\xf0','\x7e','\x7f','\x09','\x01','\xf7','\x00','\x00','\x00','\x00','\x00',
                '\xf0','\x7e','\x7f','\x09','\x03','\xf7','\x00','\x00','\x00','\x00','\x00',
@@ -120,7 +120,7 @@ static char sysex_resets[EX_RESET_NO][11]={
 */
 /*
 #define EX_RESET_NO 9
-static char sysex_resets[EX_RESET_NO][11]={
+static uint8 sysex_resets[EX_RESET_NO][11]={
        '\xf0','\x7e','\x7f','\x09','\x00','\xf7','\x00','\x00','\x00','\x00','\x00', //gm off
        '\xf0','\x7e','\x7f','\x09','\x01','\xf7','\x00','\x00','\x00','\x00','\x00', //gm1
        '\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)
 #if 0
                if ((dwParam1 & 0x000000ff) == 0xf1)
                        //MIDI Time Code Qtr. Frame (not need)
-                       printf("MIDI Time Code Qtr\n");
+                       ctl->cmsg(CMSG_INFO, VERB_DEBUG_SILLY, "MIDI Time Code Qtr");
                if ((dwParam1 & 0x000000ff) == 0xf3)
                        //Song Select(Song #) (not need)
 #endif
@@ -629,19 +629,19 @@ int rtsyn_play_one_data (int port, uint32 dwParam1, double event_time)
 #if 0
                if ((dwParam1 & 0x000000ff) == 0xf8)
                        //Timing Clock (not need)
-                       printf("Timing Clock\n");
+                       ctl->cmsg(CMSG_INFO, VERB_DEBUG_SILLY, "Timing Clock");
                if ((dwParam1&0x000000ff)==0xfa)
-                       //Start
+                       {}//Start
                if ((dwParam1 & 0x000000ff) == 0xfb)
-                       //Continue
+                       {}//Continue
                if ((dwParam1 & 0x000000ff) == 0xfc) {
                        //Stop
-                       printf("Stop\n");
+                       ctl->cmsg(CMSG_INFO, VERB_DEBUG_SILLY, "Stop");
                }
 #endif
                if ((dwParam1 & 0x000000ff) == 0xfe) {
                        //Active Sensing
-//                     printf("Active Sensing\n");
+//                     ctl->cmsg(CMSG_INFO, VERB_DEBUG_SILLY, "Active Sensing");
                        active_sensing_flag = ~0;
                        active_sensing_time = get_current_calender_time();
                }
@@ -650,12 +650,12 @@ int rtsyn_play_one_data (int port, uint32 dwParam1, double event_time)
                        if(rtsyn_sample_time_mode == 1){
                                rtsyn_tmr_reset();
                        }else{
-                               //printf("System Reset\n");
+                               //ctl->cmsg(CMSG_INFO, VERB_DEBUG_SILLY, "System Reset");
                        }
                }
                break;
        default:
-//             printf("Unsup/ed event %d\n", aevp->type);
+//             ctl->cmsg(CMSG_INFO, VERB_DEBUG_SILLY, "Unsupported event %d", aevp->type);
                break;
        }
        if (ev.type != ME_NONE) {
@@ -669,7 +669,7 @@ int rtsyn_play_one_data (int port, uint32 dwParam1, double event_time)
 }
 
 
-void rtsyn_play_one_sysex (uint8 *sysexbuffer, int exlen, double event_time )
+void rtsyn_play_one_sysex(uint8 *sysexbuffer, int exlen, double event_time )
 {
     int i, j, chk, ne;
     MidiEvent ev;
index 15aa764..716bed6 100644 (file)
@@ -47,7 +47,8 @@ d0|vt100|vt100-am|vt100am|Digital VT100:\
 
 void vt100_init_screen(void)
 {
-    vt100_reset_attr();
+       fputs("\033[?1049h", stdout);
+       vt100_reset_attr();
     fputs("\033[H\033[J", stdout);
 }
 
@@ -59,7 +60,13 @@ void vt100_refresh(void)
 
 void vt100_clrtoeol(void)
 {
-    fputs("\033[K", stdout);
+       fputs("\033[K", stdout);
+}
+
+void vt100_free_screen(void)
+{
+       fputs("\033[?1049l", stdout);
+       fputs("\033[H\033[J", stdout);
 }
 
 void vt100_move(int row, int col)
@@ -91,6 +98,7 @@ void vt100_reset_attr(void)
 void vt100_init_screen(void) { }
 void vt100_refresh(void) { fflush(stdout); }
 void vt100_clrtoeol(void) { }
+void vt100_free_screen(void) { }
 void vt100_move(int row, int col) { }
 void vt100_set_attr(int attr) { }
 void vt100_reset_attr(void) { }
index 999b557..3130ac6 100644 (file)
@@ -32,6 +32,7 @@
 extern void vt100_init_screen(void);
 extern void vt100_refresh(void);
 extern void vt100_clrtoeol(void);
+extern void vt100_free_screen(void);
 extern void vt100_move(int row, int col);
 extern void vt100_set_attr(int attr);
 extern void vt100_reset_attr(void);
index 97061dd..7bae8fb 100644 (file)
 #include <stdarg.h>
 #include <ctype.h>
 #include <sys/types.h>
-#ifndef NO_STRING_H
-#include <string.h>
-#else
-#include <strings.h>
-#endif
 
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
@@ -130,7 +125,7 @@ static void ctl_reset(void);
 static int ctl_open(int using_stdin, int using_stdout);
 static void ctl_close(void);
 static int ctl_read(ptr_size_t *valp);
-static int32 ctl_write(const uint8 *valp, int32 size);
+static int32 ctl_write(const uint8 *valp, size_t size);
 static int cmsg(int type, int verbosity_level, const char *fmt, ...);
 static void ctl_event(CtlEvent *e);
 
@@ -615,6 +610,7 @@ static void ctl_close(void)
     {
         ctl.opened = 0;
         vt100_move(24, 0);
+        vt100_free_screen();
         vt100_refresh();
     }
 
index 520409f..dcfa38b 100644 (file)
@@ -68,7 +68,7 @@ extern void MPanelReset(void);
 extern void MPanelUpdate(void);
 extern void MPanelUpdateAll(void);
 extern void MPanelPaint(void);
-extern int is_directory(char *path);
+extern int is_directory(const char *path);
 extern int directory_form(char *buffer);
 extern int TracerWndDrawSkip;
 
index c9a128c..aa7ee9b 100644 (file)
@@ -268,15 +268,13 @@ long SetValue(int32 value, int32 min, int32 max)
   return v;
 }
 
-int w32gSecondTiMidity(int opt, int argc, char **argv);
+int w32gSecondTiMidity(int opt, int argc, char **argv, int nfiles, char **files);
 int w32gSecondTiMidityExit(void);
 int SecondMode = 1;
 
 void FirstLoadIniFile(void);
 
-#if (defined(IA_W32GUI) || defined(IA_W32G_SYN)) && \
-    (!defined(__GNUC__) || /* _MSC_VER, _BORLANDC_, __WATCOMC__ */ \
-        (defined(__GNUC__) && defined(SUPPORT_WINMAIN)))
+#if (defined(__W32G__) && !defined(TWSYNG32)) && !defined(WIN32GCC)
 extern void CmdLineToArgv(LPSTR lpCmdLine, int *argc, CHAR ***argv);
 extern int win_main(int argc, char **argv); /* timidity.c */
 int WINAPI
@@ -291,7 +289,7 @@ LPSTR lpCmdLine, int nCmdShow)
        static int first = 0;
 
        Sleep(100); // Restart\82Å\91O\83v\83\8d\83Z\83X\82Ì\8fI\97¹\91Ò\8b@
-#ifdef _CRTDBG_MAP_ALLOC
+#ifdef TIMIDITY_LEAK_CHECK
        _CrtSetDbgFlag(CRTDEBUGFLAGS);
 #endif
        CmdLineToArgv(lpCmdLine,&argc,&argv);
@@ -334,7 +332,7 @@ LPSTR lpCmdLine, int nCmdShow)
        return errcode;
 #endif
 }
-#endif /* __W32G__ && SUPPORT_WINMAIN */
+#endif /* (__W32G__ && !TWSYNG32) && !WIN32GCC */
 
 // ***************************************************************************
 // System Function
@@ -5118,23 +5116,25 @@ static char *DlgFileOpen(HWND hwnd, const char *title, const char *filter, const
 static void DlgMidiFileOpen(HWND hwnd)
 {
     char *dir, *file;
-    const char *filter;
-    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"
-               "midi file\0*.mid;*.midi;*.smf;*.rmi\0"
-               "rcp file\0*.rcp;*.r36;*.g18;*.g36\0"
-               "mod file\0*.mod;*.xm;*.s3m;*.it;*.669;*.amf;*.dsm;*.far;*.gdm;*.imf;*.med;*.mtm;*.stm;*.stx;*.ult;*.uni\0"
-               "archive file\0*.lzh;*.zip;*.gz\0"
-               "playlist file\0*.pls;*.m3u;*.asx\0"
-               "all files\0*.*\0"
-               "\0\0";
-    const char *filter_jp = "Timidity \83T\83|\81[\83g\8dÏ\82Ý\83t\83@\83C\83\8b\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"
-               "SMF/RMID (*.mid;*.midi;*.smf;*.rmi)\0*.mid;*.midi;*.smf;*.rmi\0"
-               "RCP (*.rcp;*.r36;*.g18;*.g36)\0*.rcp;*.r36;*.g18;*.g36\0"
-               "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"
-               "\88³\8fk\8dÏ\82Ý\83A\81[\83J\83C\83u (*.lzh;*.zip;*.gz)\0*.lzh;*.zip;*.gz\0"
-               "\83v\83\8c\83C\83\8a\83X\83g\83t\83@\83C\83\8b (*.pls;*.m3u;*.asx)\0*.pls;*.m3u;*.asx\0"
-               "\82·\82×\82Ä\82Ì\83t\83@\83C\83\8b (*.*)\0*.*\0"
-               "\0\0";
+    const char *filter,
+        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"
+            "midi file\0*.mid;*.midi;*.smf;*.rmi\0"
+            "rcp file\0*.rcp;*.r36;*.g18;*.g36\0"
+            "mfi file\0*.mld\0"
+            "mod file\0*.mod;*.xm;*.s3m;*.it;*.669;*.amf;*.dsm;*.far;*.gdm;*.imf;*.med;*.mtm;*.stm;*.stx;*.ult;*.uni\0"
+            "archive file\0*.lzh;*.zip;*.gz\0"
+            "playlist file\0*.pls;*.m3u;*.asx\0"
+            "all files\0*.*\0"
+            "\0\0",
+        filter_jp[] = "Timidity \83T\83|\81[\83g\8dÏ\82Ý\83t\83@\83C\83\8b\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"
+            "SMF/RMID (*.mid;*.midi;*.smf;*.rmi)\0*.mid;*.midi;*.smf;*.rmi\0"
+            "RCP (*.rcp;*.r36;*.g18;*.g36)\0*.rcp;*.r36;*.g18;*.g36\0"
+            "MFi (*.mld)\0*.mld\0"
+            "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"
+            "\88³\8fk\8dÏ\82Ý\83A\81[\83J\83C\83u (*.lzh;*.zip;*.gz)\0*.lzh;*.zip;*.gz\0"
+            "\83v\83\8c\83C\83\8a\83X\83g\83t\83@\83C\83\8b (*.pls;*.m3u;*.asx)\0*.pls;*.m3u;*.asx\0"
+            "\82·\82×\82Ä\82Ì\83t\83@\83C\83\8b (*.*)\0*.*\0"
+            "\0\0";
 
     if ( PlayerLanguage == LANGUAGE_JAPANESE ) 
                filter = filter_jp;
index 893b34a..7d75057 100644 (file)
@@ -278,6 +278,11 @@ static int w32_reset_exe_directory(void)
 #endif
 #endif
 
+#define MAX_CFG_HISTORY  10
+
+static void LoadCfgHistoryINI(HWND hwnd, int cb_id);
+static void SaveCfgHistoryINI(HWND hwnd, int cb_id);
+static void AddCurrentTextToCfgHistory(HWND hwnd, int cb_id);
 
 extern int waveConfigDialog(void);
 #ifdef AU_W32
@@ -392,8 +397,8 @@ static pref_page_t pref_pages_en[] = {
        { 3, TEXT("Output"), (HWND)NULL, IDD_PREF_TIMIDITY3_EN, (DLGPROC) PrefTiMidity3DialogProc, 0 },
        { 4, TEXT("sf_ini1"), (HWND)NULL, IDD_PREF_SFINI1_EN, (DLGPROC) PrefSFINI1DialogProc, 0 },
        { 5, TEXT("sf_ini2"), (HWND)NULL, IDD_PREF_SFINI2_EN, (DLGPROC) PrefSFINI2DialogProc, 0 },
-       { 6, TEXT("Custom1"), (HWND)NULL, IDD_PREF_CUSTOM1, (DLGPROC) PrefCustom1DialogProc, 0 },
-       { 7, TEXT("Custom2"), (HWND)NULL, IDD_PREF_CUSTOM2, (DLGPROC) PrefCustom2DialogProc, 0 },
+       { 6, TEXT("Custom1"), (HWND)NULL, IDD_PREF_CUSTOM1_EN, (DLGPROC) PrefCustom1DialogProc, 0 },
+       { 7, TEXT("Custom2"), (HWND)NULL, IDD_PREF_CUSTOM2_EN, (DLGPROC) PrefCustom2DialogProc, 0 },
        { 8, TEXT("InternalSynth"), (HWND)NULL, IDD_PREF_INT_SYNTH_EN, (DLGPROC) PrefIntSynthDialogProc, 0 },
 #else
        { 0, TEXT("Player"), (HWND)NULL, IDD_PREF_PLAYER_EN, (DLGPROC) PrefPlayerDialogProc, 0 },
@@ -402,8 +407,8 @@ static pref_page_t pref_pages_en[] = {
        { 3, TEXT("Output"), (HWND)NULL, IDD_PREF_TIMIDITY3_EN, (DLGPROC) PrefTiMidity3DialogProc, 0 },
        { 4, TEXT("sf_ini1"), (HWND)NULL, IDD_PREF_SFINI1_EN, (DLGPROC) PrefSFINI1DialogProc, 0 },
        { 5, TEXT("sf_ini2"), (HWND)NULL, IDD_PREF_SFINI2_EN, (DLGPROC) PrefSFINI2DialogProc, 0 },
-       { 6, TEXT("custom1"), (HWND)NULL, IDD_PREF_CUSTOM1, (DLGPROC) PrefCustom1DialogProc, 0 },
-       { 7, TEXT("custom2"), (HWND)NULL, IDD_PREF_CUSTOM2, (DLGPROC) PrefCustom2DialogProc, 0 },
+       { 6, TEXT("custom1"), (HWND)NULL, IDD_PREF_CUSTOM1_EN, (DLGPROC) PrefCustom1DialogProc, 0 },
+       { 7, TEXT("custom2"), (HWND)NULL, IDD_PREF_CUSTOM2_EN, (DLGPROC) PrefCustom2DialogProc, 0 },
        { 8, TEXT("InternalSynth"), (HWND)NULL, IDD_PREF_INT_SYNTH_EN, (DLGPROC) PrefIntSynthDialogProc, 0 },
 #endif
 };
@@ -553,7 +558,10 @@ static void PrefWndDelayLoad(void)
 
 void PrefWndCreate(HWND hwnd, UINT cid)
 {
-    UINT page = cid ? PrefSearchPageFromCID(cid) : PrefInitialPage;
+       UINT page;
+
+    CurrentPlayerLanguage = PlayerLanguage;
+    page = cid ? PrefSearchPageFromCID(cid) : PrefInitialPage;
 
     VOLATILE_TOUCH(PrefWndDoing);
     if (PrefWndDoing)
@@ -562,7 +570,6 @@ void PrefWndCreate(HWND hwnd, UINT cid)
     PrefWndSetOK = 1;
 
     PrefInitialPage = page;
-    CurrentPlayerLanguage = PlayerLanguage;
 #if defined(KBTIM_SETUP) || defined(WINDRV_SETUP)
        switch(CurrentPlayerLanguage) {
                case LANGUAGE_JAPANESE:
@@ -1354,16 +1361,18 @@ PrefPlayerDialogProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam)
         DI_DISABLE(IDC_CHECKBOX_LOOP_CC2);
         DI_DISABLE(IDC_EDIT_LOOP_REPEAT);
 #endif
-
+               
         if (!sp_temp->ConfigFile[0]) {
             strcpy(sp_temp->ConfigFile, ConfigFile);
         }
-        EB_SETTEXTA(IDC_EDIT_CONFIG_FILE, sp_temp->ConfigFile);
-        tmp = SendDlgItemMessage(hwnd, IDC_EDIT_CONFIG_FILE, WM_GETTEXTLENGTH, 0, 0); // A/W
-        SendDlgItemMessage(hwnd, IDC_EDIT_CONFIG_FILE, EM_SETSEL, (WPARAM) tmp, (LPARAM) tmp); // A/W
+        EB_SETTEXTA(IDC_COMBO_CONFIG_FILE, sp_temp->ConfigFile);
+        tmp = SendDlgItemMessage(hwnd, IDC_COMBO_CONFIG_FILE, WM_GETTEXTLENGTH, 0, 0); // A/W
+        SendDlgItemMessage(hwnd, IDC_COMBO_CONFIG_FILE, CB_SETEDITSEL, 0, MAKELPARAM(tmp, tmp)); // A/W
         safe_free(CurrentConfigFile);
         CurrentConfigFile = safe_strdup(sp_temp->ConfigFile);
 
+               LoadCfgHistoryINI(hwnd, IDC_COMBO_CONFIG_FILE);
+
         switch (CurrentPlayerLanguage) {
         case LANGUAGE_ENGLISH:
             CheckRadioButton(hwnd, IDC_RADIOBUTTON_JAPANESE, IDC_RADIOBUTTON_ENGLISH,
@@ -1467,13 +1476,15 @@ PrefPlayerDialogProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam)
         case IDC_BUTTON_CONFIG_FILE: {
             char filename[FILEPATH_MAX];
             filename[0] = '\0';
-            EB_GETTEXTA(IDC_EDIT_CONFIG_FILE, filename, FILEPATH_MAX - 1);
+            EB_GETTEXTA(IDC_COMBO_CONFIG_FILE, filename, FILEPATH_MAX - 1);
             if (!DlgOpenConfigFile(filename, hwnd))
                 if (filename[0] != '\0') {
-                    EB_SETTEXTA(IDC_EDIT_CONFIG_FILE, filename);
-                    tmp = SendDlgItemMessage(hwnd, IDC_EDIT_CONFIG_FILE, WM_GETTEXTLENGTH, 0, 0); // A/W
-                    SendDlgItemMessage(hwnd, IDC_EDIT_CONFIG_FILE, EM_SETSEL, (WPARAM) tmp, (LPARAM) tmp); // A/W
-                }
+                    EB_SETTEXTA(IDC_COMBO_CONFIG_FILE, filename);
+                    tmp = SendDlgItemMessage(hwnd, IDC_COMBO_CONFIG_FILE, WM_GETTEXTLENGTH, 0, 0); // A/W
+                    SendDlgItemMessage(hwnd, IDC_COMBO_CONFIG_FILE, CB_SETEDITSEL, 0, MAKELPARAM(tmp, tmp)); // A/W
+                                       AddCurrentTextToCfgHistory(hwnd, IDC_COMBO_CONFIG_FILE);
+                                       SaveCfgHistoryINI(hwnd, IDC_COMBO_CONFIG_FILE);
+                               }
             break; }
 
         case IDC_BUTTON_CFG_EDIT: {
@@ -1488,7 +1499,7 @@ PrefPlayerDialogProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam)
             }
 
             filename[0] = '\0';
-            EB_GETTEXTA(IDC_EDIT_CONFIG_FILE, filename, FILEPATH_MAX - 1);
+            EB_GETTEXTA(IDC_COMBO_CONFIG_FILE, filename, FILEPATH_MAX - 1);
 
             w32_reset_exe_directory();
 
@@ -1553,8 +1564,10 @@ PrefPlayerDialogProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam)
 
         if (initflag)
             break;
-
-        EB_GETTEXTA(IDC_EDIT_CONFIG_FILE, sp_temp->ConfigFile, FILEPATH_MAX - 1);
+               
+        EB_GETTEXTA(IDC_COMBO_CONFIG_FILE, sp_temp->ConfigFile, FILEPATH_MAX - 1);
+               AddCurrentTextToCfgHistory(hwnd, IDC_COMBO_CONFIG_FILE);
+               SaveCfgHistoryINI(hwnd, IDC_COMBO_CONFIG_FILE);
 
         if (CH_GET(IDC_RADIOBUTTON_ENGLISH))
             sp_temp->PlayerLanguage = LANGUAGE_ENGLISH;
@@ -1731,17 +1744,18 @@ PrefSyn1DialogProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam)
        switch (uMess){
     case WM_INITDIALOG:
         if (hFixedPointFont != NULL)
-            SendDlgItemMessage(hwnd, IDC_EDIT_CONFIG_FILE, WM_SETFONT, (WPARAM) hFixedPointFont, MAKELPARAM(TRUE, 0));
+            SendDlgItemMessage(hwnd, IDC_COMBO_CONFIG_FILE, WM_SETFONT, (WPARAM) hFixedPointFont, MAKELPARAM(TRUE, 0));
 
 
         if (!sp_temp->ConfigFile[0]) {
             strcpy(sp_temp->ConfigFile, ConfigFile);
         }
-        EB_SETTEXTA(IDC_EDIT_CONFIG_FILE, sp_temp->ConfigFile);
-        tmp = SendDlgItemMessage(hwnd, IDC_EDIT_CONFIG_FILE, WM_GETTEXTLENGTH, 0, 0); // A/W
-        SendDlgItemMessage(hwnd, IDC_EDIT_CONFIG_FILE, EM_SETSEL, (WPARAM) tmp, (LPARAM) tmp); // A/W
+        EB_SETTEXTA(IDC_COMBO_CONFIG_FILE, sp_temp->ConfigFile);
+        tmp = SendDlgItemMessage(hwnd, IDC_COMBO_CONFIG_FILE, WM_GETTEXTLENGTH, 0, 0); // A/W
+        SendDlgItemMessage(hwnd, IDC_COMBO_CONFIG_FILE, CB_SETEDITSEL, 0, MAKELPARAM(tmp, tmp)); // A/W
         safe_free(CurrentConfigFile);
         CurrentConfigFile = safe_strdup(sp_temp->ConfigFile);
+               LoadCfgHistoryINI(hwnd, IDC_COMBO_CONFIG_FILE);
 
 #if defined(WINDRV_SETUP)
         DI_DISABLE(IDC_BUTTON_CFG_RELOAD);
@@ -1892,13 +1906,15 @@ PrefSyn1DialogProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam)
         case IDC_BUTTON_CONFIG_FILE: {
             char filename[FILEPATH_MAX];
             filename[0] = '\0';
-            EB_GETTEXTA(IDC_EDIT_CONFIG_FILE, filename, FILEPATH_MAX - 1);
+            EB_GETTEXTA(IDC_COMBO_CONFIG_FILE, filename, FILEPATH_MAX - 1);
             if (!DlgOpenConfigFile(filename, hwnd))
                 if (filename[0] != '\0') {
-                    EB_SETTEXTA(IDC_EDIT_CONFIG_FILE, filename); // A
-                    tmp = SendDlgItemMessage(hwnd, IDC_EDIT_CONFIG_FILE, WM_GETTEXTLENGTH, 0, 0); // A/W
-                    SendDlgItemMessage(hwnd, IDC_EDIT_CONFIG_FILE, EM_SETSEL, (WPARAM) tmp, (LPARAM) tmp); // A/W
-                }
+                    EB_SETTEXTA(IDC_COMBO_CONFIG_FILE, filename); // A
+                    tmp = SendDlgItemMessage(hwnd, IDC_COMBO_CONFIG_FILE, WM_GETTEXTLENGTH, 0, 0); // A/W
+                    SendDlgItemMessage(hwnd, IDC_COMBO_CONFIG_FILE, CB_SETEDITSEL, 0, MAKELPARAM(tmp, tmp)); // A/W
+                                       AddCurrentTextToCfgHistory(hwnd, IDC_COMBO_CONFIG_FILE);
+                                       SaveCfgHistoryINI(hwnd, IDC_COMBO_CONFIG_FILE);
+                               }
             break; }
         case IDC_BUTTON_CFG_EDIT: {
             char filename[FILEPATH_MAX];
@@ -1912,7 +1928,7 @@ PrefSyn1DialogProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam)
             }
 
             filename[0] = '\0';
-            EB_GETTEXTA(IDC_EDIT_CONFIG_FILE, filename, FILEPATH_MAX - 1);
+            EB_GETTEXTA(IDC_COMBO_CONFIG_FILE, filename, FILEPATH_MAX - 1);
 
             w32_reset_exe_directory();
 
@@ -1956,8 +1972,11 @@ PrefSyn1DialogProc(HWND hwnd, UINT uMess, WPARAM wParam, LPARAM lParam)
     case WM_MYSAVE:
         if (initflag)
             break;
+               
+        EB_GETTEXTA(IDC_COMBO_CONFIG_FILE, sp_temp->ConfigFile, FILEPATH_MAX - 1);
+               AddCurrentTextToCfgHistory(hwnd, IDC_COMBO_CONFIG_FILE);
+               SaveCfgHistoryINI(hwnd, IDC_COMBO_CONFIG_FILE);
 
-        EB_GETTEXTA(IDC_EDIT_CONFIG_FILE, sp_temp->ConfigFile, FILEPATH_MAX - 1);
         if (CH_GET(IDC_RADIOBUTTON_ENGLISH)) {
             sp_temp->PlayerLanguage = LANGUAGE_ENGLISH;
         } else if (CH_GET(IDC_RADIOBUTTON_JAPANESE)) {
@@ -5883,12 +5902,12 @@ static int DlgOpenConfigFile(char *Filename, HWND hwnd)
             dir[FILEPATH_MAX];
     int i, res;
     const char *filter,
-           filter_en[] = "All Supported file (*.cfg;*.config;*.sf2;*.sf3)\0*.cfg;*.config;*.sf2;*.sf3\0"
+           filter_en[] = "All Supported files (*.cfg;*.config;*.sf2;*.sf3)\0*.cfg;*.config;*.sf2;*.sf3\0"
                 "SoundFont file (*.sf2)\0*.sf2;*.sf3\0"
                 "Config file (*.cfg;*.config)\0*.cfg;*.config\0"
                 "All files (*.*)\0*.*\0"
                 "\0\0",
-           filter_jp[] = "\82·\82×\82Ä\82Ì\91Î\89\9e\83t\83@\83C\83\8b (*.cfg;*.config;*.sf2;*.sf2)\0*.cfg;*.config;*.sf2;*.sf3\0"
+           filter_jp[] = "\82·\82×\82Ä\82Ì\91Î\89\9e\83t\83@\83C\83\8b (*.cfg;*.config;*.sf2;*.sf3)\0*.cfg;*.config;*.sf2;*.sf3\0"
                 "SoundFont \83t\83@\83C\83\8b (*.sf2)\0*.sf2;*.sf3\0"
                 "Config \83t\83@\83C\83\8b (*.cfg;*.config)\0*.cfg;*.config\0"
                 "\82·\82×\82Ä\82Ì\83t\83@\83C\83\8b (*.*)\0*.*\0"
@@ -6097,6 +6116,76 @@ int w32g_gogo_id3_tag_dialog(void)
        return 0;
 }
 
+static void LoadCfgHistoryINI(HWND hwnd, int cb_id)
+{
+       TCHAR buffer1[FILEPATH_MAX + 1] = {0};
+       TCHAR buffer2[FILEPATH_MAX + 1] = {0};
+       LPCTSTR inifile = timidity_history_inifile;
+       int count = GetPrivateProfileInt(_T("cfg"), _T("count"), 0, inifile);
+       int i;
+
+       // remove old items
+       for (i = SendDlgItemMessage(hwnd, cb_id, CB_GETCOUNT, 0, 0) - 1; i >= 0; i--) {
+               SendDlgItemMessage(hwnd, cb_id, CB_DELETESTRING, i, 0);
+       }
+
+       if (count > MAX_CFG_HISTORY)
+               count = MAX_CFG_HISTORY;
+
+       for (i = 0; i < count; i++) {
+               _sntprintf(buffer1, FILEPATH_MAX, _T("item%02d"), i);
+               GetPrivateProfileString(_T("cfg"), buffer1, _T(""), buffer2, FILEPATH_MAX, inifile);
+
+               if (buffer2[0] != _T('\0')) {
+                       CB_INSSTR(cb_id, buffer2);
+               }
+       }
+}
+
+static void SaveCfgHistoryINI(HWND hwnd, int cb_id)
+{
+       TCHAR buffer1[FILEPATH_MAX + 1] = {0};
+       TCHAR buffer2[FILEPATH_MAX + 1] = {0};
+       LPCTSTR inifile = timidity_history_inifile;
+       int count = SendDlgItemMessage(hwnd, cb_id, CB_GETCOUNT, 0, 0);
+       int i;
+       DWORD e;
+
+       _sntprintf(buffer1, FILEPATH_MAX, _T("%d"), count);
+       SetLastError(0);
+       WritePrivateProfileString(_T("cfg"), _T("count"), buffer1, inifile);
+
+       e = GetLastError();
+
+       for (i = 0; i < count; i++) {
+               _sntprintf(buffer1, FILEPATH_MAX, _T("item%02d"), i);
+
+               if (SendDlgItemMessage(hwnd, cb_id, CB_GETLBTEXTLEN, i, 0) < FILEPATH_MAX) {
+                       SendDlgItemMessage(hwnd, cb_id, CB_GETLBTEXT, i, (LPARAM)buffer2);
+                       WritePrivateProfileString(_T("cfg"), buffer1, buffer2, inifile);
+               }
+       }
+
+       WritePrivateProfileString(NULL, NULL, NULL, inifile);   // flush
+}
+
+static void AddCurrentTextToCfgHistory(HWND hwnd, int cb_id)
+{
+       TCHAR buffer[FILEPATH_MAX + 1] = {0};
+       int index;
+
+       EB_GETTEXT(cb_id, buffer, FILEPATH_MAX);
+
+       index = SendDlgItemMessage(hwnd, cb_id, CB_FINDSTRINGEXACT, -1, (LPARAM)buffer);
+
+       if (index != CB_ERR)
+               SendDlgItemMessage(hwnd, cb_id, CB_DELETESTRING, index, 0);
+
+       SendDlgItemMessage(hwnd, cb_id, CB_INSERTSTRING, 0, buffer);
+       SendDlgItemMessage(hwnd, cb_id, CB_DELETESTRING, MAX_CFG_HISTORY, 0);
+       EB_SETTEXT(cb_id, buffer);
+}
+
 
 //
 //
@@ -8218,13 +8307,6 @@ static const TCHAR *cb_info_IDC_COMBO_PA_WASAPI_STREAM_CATEGORY[] = {
     TEXT("Media"),
 };
 
-#define cb_num_IDC_COMBO_PA_WASAPI_STREAM_OPTION 3
-static const TCHAR *cb_info_IDC_COMBO_PA_WASAPI_STREAM_OPTION[] = {
-    TEXT("None"),
-    TEXT("Raw"),
-    TEXT("MatchFormat"),
-};
-
 
 LRESULT WINAPI portaudioConfigDialogProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
 {
@@ -8267,21 +8349,20 @@ LRESULT WINAPI portaudioConfigDialogProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM
                                DI_DISABLE(IDC_COMBO_PA_WASAPI_STREAM_CATEGORY);
                        }
                        // WASAPI StreamOption
-                       if(winver >= 6) // win10
-                               max = cb_num_IDC_COMBO_PA_WASAPI_STREAM_OPTION;
-                       else if(winver >= 4) // win8.1
-                               max = 2;
-                       else
-                               max = 1;
-                       for (i = 0; i < max; i++)
-                               CB_INSSTR(IDC_COMBO_PA_WASAPI_STREAM_OPTION, cb_info_IDC_COMBO_PA_WASAPI_STREAM_OPTION[i]);
-                       if(winver >= 6){ // win10
-                               CB_SET(IDC_COMBO_PA_WASAPI_STREAM_OPTION, (st_temp->pa_wasapi_stream_option));
-                       }else if(winver >= 4){ // win8.1
-                               CB_SET(IDC_COMBO_PA_WASAPI_STREAM_OPTION, (st_temp->pa_wasapi_stream_option >= 2 ? 0 : st_temp->pa_wasapi_stream_option));
-                       }else{
-                               CB_SET(IDC_COMBO_PA_WASAPI_STREAM_OPTION, 0);
-                               DI_DISABLE(IDC_COMBO_PA_WASAPI_STREAM_OPTION);
+                       if (winver >= 6) { // win10
+                               SendDlgItemMessage(hwnd, IDC_CHECKBOX_PA_WASAPI_STREAM_OPTIONS_RAW, BM_SETCHECK, (st_temp->pa_wasapi_stream_option & 1) ? BST_CHECKED : BST_UNCHECKED, 0);
+                               SendDlgItemMessage(hwnd, IDC_CHECKBOX_PA_WASAPI_STREAM_OPTIONS_MATCH_FORMAT, BM_SETCHECK, (st_temp->pa_wasapi_stream_option & 2) ? BST_CHECKED : BST_UNCHECKED, 0);
+                               SendDlgItemMessage(hwnd, IDC_CHECKBOX_PA_WASAPI_STREAM_OPTIONS_AMBISONICS, BM_SETCHECK, (st_temp->pa_wasapi_stream_option & 4) ? BST_CHECKED : BST_UNCHECKED, 0);
+                       }
+                       else if (winver >= 4) { // win8.1
+                               SendDlgItemMessage(hwnd, IDC_CHECKBOX_PA_WASAPI_STREAM_OPTIONS_RAW, BM_SETCHECK, (st_temp->pa_wasapi_stream_option & 1) ? BST_CHECKED : BST_UNCHECKED, 0);
+                               DI_DISABLE(IDC_CHECKBOX_PA_WASAPI_STREAM_OPTIONS_MATCH_FORMAT);
+                               DI_DISABLE(IDC_CHECKBOX_PA_WASAPI_STREAM_OPTIONS_AMBISONICS);
+                       }
+                       else {
+                               DI_DISABLE(IDC_CHECKBOX_PA_WASAPI_STREAM_OPTIONS_RAW);
+                               DI_DISABLE(IDC_CHECKBOX_PA_WASAPI_STREAM_OPTIONS_MATCH_FORMAT);
+                               DI_DISABLE(IDC_CHECKBOX_PA_WASAPI_STREAM_OPTIONS_AMBISONICS);
                        }
 
 
@@ -8449,7 +8530,13 @@ LRESULT WINAPI portaudioConfigDialogProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM
                                // WASAPI StreamCategory
                                st_temp->pa_wasapi_stream_category = CB_GET(IDC_COMBO_PA_WASAPI_STREAM_CATEGORY);
                                // WASAPI StreamOption
-                               st_temp->pa_wasapi_stream_option = CB_GET(IDC_COMBO_PA_WASAPI_STREAM_OPTION);
+                               st_temp->pa_wasapi_stream_option = 0;
+                               if (SendDlgItemMessage(hwnd, IDC_CHECKBOX_PA_WASAPI_STREAM_OPTIONS_RAW, BM_GETCHECK, 0, 0))
+                                       st_temp->pa_wasapi_stream_option |= 1;
+                               if (SendDlgItemMessage(hwnd, IDC_CHECKBOX_PA_WASAPI_STREAM_OPTIONS_MATCH_FORMAT, BM_GETCHECK, 0, 0))
+                                       st_temp->pa_wasapi_stream_option |= 2;
+                               if (SendDlgItemMessage(hwnd, IDC_CHECKBOX_PA_WASAPI_STREAM_OPTIONS_AMBISONICS, BM_GETCHECK, 0, 0))
+                                       st_temp->pa_wasapi_stream_option |= 4;
 
                                EndDialog(hwnd,TRUE);
                                break;
index 999939d..ba55297 100644 (file)
@@ -1,6 +1,6 @@
 /*
     TiMidity++ -- MIDI to WAVE converter and player
-    Copyright (C) 1999-2018 Masanao Izumo <iz@onicos.co.jp>
+    Copyright (C) 1999-2002 Masanao Izumo <mo@goice.co.jp>
     Copyright (C) 1995 Tuukka Toivonen <tt@cgs.fi>
 
     This program is free software; you can redistribute it and/or modify
 #define __W32G2_PREF_H__
 
 
-extern void tmdy_free_config(void);
-extern void timidity_start_initialize(void);
+extern void    tmdy_free_config(void);
+extern void    timidity_start_initialize(void);
 extern int read_config_file(char *name, int self, int allow_missing_file);
 
 extern volatile int PrefWndDoing;
 void PrefWndCreate(HWND hwnd, UINT cid);
 
-
 typedef struct wave_ConfigDialogInfo_t {
-        char optIDC_EDIT_RIFFWAVE_UPDATE_STEP[1024 + 1];
-        int optIDC_CHECKBOX_RIFFWAVE_EXTENSIBLE;
+       char optIDC_EDIT_RIFFWAVE_UPDATE_STEP[1024 + 1];
+       int optIDC_CHECKBOX_RIFFWAVE_EXTENSIBLE;
 } wave_ConfigDialogInfo_t;
 
 extern int wave_ConfigDialogInfoInit(void);
@@ -40,49 +39,50 @@ extern int wave_ConfigDialogInfoApply(void);
 extern int wave_ConfigDialogInfoSaveINI(void);
 extern int wave_ConfigDialogInfoLoadINI(void);
 
+extern int waveConfigDialog(void);
 
 #ifdef AU_GOGO
 
 // \83_\83C\83A\83\8d\83O\82Ì\8fî\95ñ\82ð\82Ù\82Æ\82ñ\82Ç\82»\82Ì\82Ü\82Ü\95Û\91\82·\82é\81B
 // \83R\83\93\83{\83{\83b\83N\83X\82É\82Â\82¢\82Ä\82Í Index \82Í\96³\88Ó\96¡\82È\82Ì\82Å\92l\82ð\95Û\91\82·\82é\81B
 typedef struct gogo_ConfigDialogInfo_t_ {
-        int optIDC_CHECK_DEFAULT;
-        int optIDC_CHECK_COMMANDLINE_OPTS;
-        char optIDC_EDIT_COMMANDLINE_OPTION[1024+1];
-        int optIDC_CHECK_OUTPUT_FORMAT;
-        int optIDC_COMBO_OUTPUT_FORMAT;
-        int optIDC_CHECK_MPEG1AUDIOBITRATE;
-        int optIDC_COMBO_MPEG1_AUDIO_BITRATE;
-        int optIDC_CHECK_MPEG2AUDIOBITRATE;
-        int optIDC_COMBO_MPEG2_AUDIO_BITRATE;
-        int optIDC_CHECK_ENHANCED_LOW_PASS_FILTER;
-        char optIDC_EDIT_LPF_PARA1[4+1];
-        char optIDC_EDIT_LPF_PARA2[4+1];
-        int optIDC_CHECK_ENCODE_MODE;
-        int optIDC_COMBO_ENCODE_MODE;
-        int optIDC_CHECK_EMPHASIS_TYPE;
-        int optIDC_COMBO_EMPHASIS_TYPE;
-        int optIDC_CHECK_OUTFREQ;
-        char optIDC_EDIT_OUTFREQ[6+1];
-        int optIDC_CHECK_MSTHRESHOLD;
-        char optIDC_EDIT_MSTHRESHOLD_THRESHOLD[4+1];
-        char optIDC_EDIT_MSTHRESHOLD_MSPOWER[4+1];
-        int optIDC_CHECK_USE_CPU_OPTS;
-        int optIDC_CHECK_CPUMMX;
-        int optIDC_CHECK_CPUSSE;
-        int optIDC_CHECK_CPU3DNOW;
-        int optIDC_CHECK_CPUE3DNOW;
-        int optIDC_CHECK_CPUCMOV;
-        int optIDC_CHECK_CPUEMMX;
-        int optIDC_CHECK_CPUSSE2;
-        int optIDC_CHECK_VBR;
-        int optIDC_COMBO_VBR;
-        int optIDC_CHECK_VBR_BITRATE;
-        int optIDC_COMBO_VBR_BITRATE_LOW;
-        int optIDC_COMBO_VBR_BITRATE_HIGH;
-        int optIDC_CHECK_USEPSY;
-        int optIDC_CHECK_VERIFY;
-        int optIDC_CHECK_16KHZ_LOW_PASS_FILTER;
+       int optIDC_CHECK_DEFAULT;
+       int optIDC_CHECK_COMMANDLINE_OPTS;
+       char optIDC_EDIT_COMMANDLINE_OPTION[1024+1];
+       int optIDC_CHECK_OUTPUT_FORMAT;
+       int optIDC_COMBO_OUTPUT_FORMAT;
+       int optIDC_CHECK_MPEG1AUDIOBITRATE;
+       int optIDC_COMBO_MPEG1_AUDIO_BITRATE;
+       int optIDC_CHECK_MPEG2AUDIOBITRATE;
+       int optIDC_COMBO_MPEG2_AUDIO_BITRATE;
+       int optIDC_CHECK_ENHANCED_LOW_PASS_FILTER;
+       char optIDC_EDIT_LPF_PARA1[4+1];
+       char optIDC_EDIT_LPF_PARA2[4+1];
+       int optIDC_CHECK_ENCODE_MODE;
+       int optIDC_COMBO_ENCODE_MODE;
+       int optIDC_CHECK_EMPHASIS_TYPE;
+       int optIDC_COMBO_EMPHASIS_TYPE;
+       int optIDC_CHECK_OUTFREQ;
+       char optIDC_EDIT_OUTFREQ[6+1];
+       int optIDC_CHECK_MSTHRESHOLD;
+       char optIDC_EDIT_MSTHRESHOLD_THRESHOLD[4+1];
+       char optIDC_EDIT_MSTHRESHOLD_MSPOWER[4+1];
+       int optIDC_CHECK_USE_CPU_OPTS;
+       int optIDC_CHECK_CPUMMX;
+       int optIDC_CHECK_CPUSSE;
+       int optIDC_CHECK_CPU3DNOW;
+       int optIDC_CHECK_CPUE3DNOW;
+       int optIDC_CHECK_CPUCMOV;
+       int optIDC_CHECK_CPUEMMX;
+       int optIDC_CHECK_CPUSSE2;
+       int optIDC_CHECK_VBR;
+       int optIDC_COMBO_VBR;
+       int optIDC_CHECK_VBR_BITRATE;
+       int optIDC_COMBO_VBR_BITRATE_LOW;
+       int optIDC_COMBO_VBR_BITRATE_HIGH;
+       int optIDC_CHECK_USEPSY;
+       int optIDC_CHECK_VERIFY;
+       int optIDC_CHECK_16KHZ_LOW_PASS_FILTER;
 } gogo_ConfigDialogInfo_t;
 
 extern volatile gogo_ConfigDialogInfo_t gogo_ConfigDialogInfo;
@@ -98,12 +98,12 @@ extern int gogo_ConfigDialogInfoLoadINI(void);
 #ifdef AU_VORBIS
 
 typedef struct vorbis_ConfigDialogInfo_t_ {
-        int optIDC_CHECK_DEFAULT;
-        int optIDC_COMBO_MODE;
-        int optIDC_CHECK_USE_TAG;
-        char optIDC_EDIT1[256];
-        char optIDC_EDIT2[256];
-        char optIDC_EDIT3[256];
+       int optIDC_CHECK_DEFAULT;
+       int optIDC_COMBO_MODE;
+       int optIDC_CHECK_USE_TAG;
+       char optIDC_EDIT1[256];
+       char optIDC_EDIT2[256];
+       char optIDC_EDIT3[256];
 } vorbis_ConfigDialogInfo_t;
 
 extern int vorbis_ConfigDialogInfoInit(void);
@@ -117,7 +117,7 @@ extern int vorbis_ConfigDialogInfoLoadINI(void);
 #ifdef AU_LAME
 
 typedef struct lame_ConfigDialogInfo_t_ {
-        int optIDC_LAME_CBPRESET;
+       int optIDC_LAME_CBPRESET;
 } lame_ConfigDialogInfo_t;
 
 extern int lame_encode_preset;
@@ -133,8 +133,8 @@ extern int lame_ConfigDialogInfoLoadINI(void);
 #ifdef AU_FLAC
 
 typedef struct flac_ConfigDialogInfo_t_ {
-        int optIDC_COMBO_ENCODE_MODE;
-        int optIDC_CHECKBOX_OGGFLAC_CONTAINER;
+       int optIDC_COMBO_ENCODE_MODE;
+       int optIDC_CHECKBOX_OGGFLAC_CONTAINER;
 } flac_ConfigDialogInfo_t;
 
 extern int flac_ConfigDialogInfoInit(void);
@@ -148,6 +148,7 @@ extern int flac_ConfigDialogInfoLoadINI(void);
 #ifdef AU_OPUS
 
 typedef struct opus_ConfigDialogInfo_t_ {
+       char unused;
 } opus_ConfigDialogInfo_t;
 
 extern int opus_ConfigDialogInfoInit(void);
@@ -161,6 +162,7 @@ extern int opus_ConfigDialogInfoLoadINI(void);
 #ifdef AU_SPEEX
 
 typedef struct speex_ConfigDialogInfo_t_ {
+       char unused;
 } speex_ConfigDialogInfo_t;
 
 extern int speex_ConfigDialogInfoInit(void);
index a2ca564..2b8d1d2 100644 (file)
       <ExceptionHandling>
       </ExceptionHandling>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
-      <StructMemberAlignment>8Bytes</StructMemberAlignment>
+      <StructMemberAlignment>16Bytes</StructMemberAlignment>
       <BufferSecurityCheck>false</BufferSecurityCheck>
       <FunctionLevelLinking>true</FunctionLevelLinking>
       <PrecompiledHeaderFile>..\config.h</PrecompiledHeaderFile>
index cd04b04..030510a 100644 (file)
@@ -2,6 +2,7 @@
 add_definitions(
     -DCFG_FOR_SF
     -DSF2VIEWER_GUI
+       -DENABLE_DLS
 )
 
 add_executable(
@@ -10,55 +11,20 @@ add_executable(
     mysndfont.c
     OpenDlg.cpp
     sfview_main.cpp
-    ../interface/dumb_c.c
-    ../timidity/common.c
-    ../timidity/controls.c
-    ../timidity/envelope.c
-    ../timidity/filter.c
-    ../timidity/freq.c
-    ../timidity/instrum.c
-    ../timidity/int_synth.c
-    ../timidity/mt19937ar.c
+    ../timidity/dls.cpp
     ../timidity/myini.c
-    ../timidity/quantity.c
-    ../timidity/resample.c
-    ../timidity/sbkconv.c
-    ../timidity/sffile.c
-    ../timidity/sfitem.c
-    ../timidity/smplfile.c
-    ../timidity/tables.c
-    ../timidity/version.c
 
     OpenDlg.h
     resource.h
-    ../libarc/arc.h
-    ../timidity/common.h
-    ../timidity/controls.h
-    ../timidity/envelope.h
-    ../timidity/filter.h
-    ../timidity/instrum.h
-    ../timidity/int_synth.h
-    ../timidity/mt19937ar.h
+    ../timidity/dls.h
     ../timidity/myini.h
-    ../timidity/output.h
-    ../timidity/playmidi.h
-    ../timidity/quantity.h
-    ../timidity/readmidi.h
-    ../timidity/resample.h
-    ../timidity/sffile.h
-    ../timidity/sfitem.h
-    ../timidity/sflayer.h
-    ../timidity/tables.h
-    ../timidity/timidity.h
-    ../timidity/wrd.h
-    ../utils/mblock.h
-    ../utils/support.h
 
     sfview_dlg.rc
 
+    $<TARGET_OBJECTS:timidity_cfgforsf>
     $<TARGET_OBJECTS:libarc>
     $<TARGET_OBJECTS:utils>
 )
 
 add_dependencies(sfviewer UpdateTim41Version)
-target_link_libraries(sfviewer comctl32 shlwapi winmm ws2_32)
+target_link_libraries(sfviewer comctl32 shlwapi ws2_32)
index 7c4088f..3951ebe 100644 (file)
@@ -5,8 +5,14 @@
 #pragma warning(disable:4133)
 #pragma warning(disable:4028)
 #define main _dummy_main
+#include <windows.h>
 #include "sndfont.c"
 #include "myini.h"
+
+#ifdef ENABLE_DLS
+#include "dls.h"
+#endif
+
 #pragma warning(pop)
 
 void sfgui_str_free(void **p)
@@ -21,8 +27,23 @@ void sfgui_str_free(void **p)
 #include <shlwapi.h>
 #include "resource.h"
 
-void InsertInst(int bank, int preset, const char *str, const char *sfname);
-void InsertDrum(int bank, int preset, int note, const char *str, const char *sfname);
+void InsertInst(BOOL dls, int bank, int preset, const char *str, const char *sfname);
+void InsertDrum(BOOL dls, int bank, int preset, int note, const char *str, const char *sfname);
+
+BOOL IsDLSFile(LPCSTR filename)
+{
+       struct timidity_file *tf = open_file(filename, 1, OF_NORMAL);
+       char buf[12];
+       BOOL isDLS = FALSE;
+
+       if (tf_read(buf, 1, 12, tf) == 12 && memcmp(&buf[0], "RIFF", 4) == 0 && memcmp(&buf[8], "DLS ", 4) == 0) {
+               isDLS = TRUE;
+       }
+
+       close_file(tf);
+       return isDLS;
+}
+
 void CreateSoundFontTree(HWND hDlg, LPCSTR x_sf_filename_)
 {
        HWND hTree = GetDlgItem(hDlg, IDC_TREE1);
@@ -38,10 +59,6 @@ void CreateSoundFontTree(HWND hDlg, LPCSTR x_sf_filename_)
 
        //TreeView_DeleteAllItems(hTree);
 
-       if (_stricmp(PathFindExtension(x_sf_filename_), ".sf2")) {
-               return;
-       }
-
        for (x_bank = 0; x_bank <= 127; x_bank++) {
                for (x_preset = 0; x_preset <= 127; x_preset++) {
                        x_cfg_info.m_str[x_bank][x_preset] = NULL;
@@ -99,126 +116,190 @@ void CreateSoundFontTree(HWND hDlg, LPCSTR x_sf_filename_)
        init_bend_coarse();
        initialize_resampler_coeffs();
        control_ratio = play_mode->rate / CONTROLS_PER_SECOND;
-    sf = new_soundfont(x_sf_file_name);
-    sf->next = NULL;
-    sf->def_order = 2;
-    sfrecs = sf;
-       x_cfg_info_init();
-       init_sf(sf);
-       if (x_sort) {
-       for (x_bank = 0; x_bank <= 127; x_bank++) {
-               flag = 0;
-
-               for (x_preset = 0; x_preset <= 127; x_preset++) {
-                       if (x_cfg_info.m_bank[x_bank][x_preset] >= 0 && x_cfg_info.m_preset[x_bank][x_preset] >= 0) {
-                               flag = 1;
-                       }
-               }
-               if (!flag)
-                       continue;
-               if (!initial) {
-                       initial = 1;
-               }
 
-               // insert bank
-               tv.hInsertAfter = TVI_LAST;
-               tv.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
-               tv.hParent = hBank;
-               sprintf(str_, "Bank %03d", x_bank);
-               tv.item.pszText = str_;
-               tv.item.iImage = 0;
-               tv.item.iSelectedImage = 1;
-               hBankSub = TreeView_InsertItem(hTree, &tv);
+       if (IsDLSFile(x_sf_filename_)) {
+#ifdef ENABLE_DLS
+               DLSCollectionInfo *list = get_dls_instrument_list(x_sf_filename_);
+               if (list) {
+                       for (int i = 0; i < list->bank_count; i++) {
+                               DLSBankInfo *b = &list->banks[i];
 
-               for (x_preset = 0; x_preset <= 127; x_preset++) {
-                       if (x_cfg_info.m_bank[x_bank][x_preset] >= 0 && x_cfg_info.m_preset[x_bank][x_preset] >= 0) {
-
-                               // insert bank
                                tv.hInsertAfter = TVI_LAST;
                                tv.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
-                               tv.hParent = hBankSub;
+                               tv.hParent = hBank;
+                               sprintf(str_, "Bank %03u", b->bank);
+                               tv.item.pszText = str_;
+                               tv.item.iImage = 0;
+                               tv.item.iSelectedImage = 1;
+                               hBankSub = TreeView_InsertItem(hTree, &tv);
+
+                               for (int j = 0; j < b->program_count; j++) {
+                                       DLSProgramInfo *p = &b->programs[j];
+
+                                       tv.hInsertAfter = TVI_LAST;
+                                       tv.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
+                                       tv.hParent = hBankSub;
+                                       sprintf(str_, "%03u:%03u %s", b->bank, p->program, p->name);
+                                       tv.item.pszText = str_;
+                                       tv.item.iImage = 2;
+                                       tv.item.iSelectedImage = 3;
+                                       TreeView_InsertItem(hTree, &tv);
+
+                                       InsertInst(TRUE, b->bank, p->program, p->name, x_sf_filename_);
+                               }
+                       }
 
-                               pname_ =sf_preset_name[x_bank][x_preset];
-//                             if (x_cfg_info.m_rom[x_bank][x_preset])
-//                                     sprintf(str_, "%03d:%03d[ROM] %s\0\0", x_bank, x_preset, pname_);
-//                             else
-                               sprintf(str_, "%03d:%03d %s\0\0", x_bank, x_preset, pname_);
+                       for (int i = 0; i < list->drumset_count; i++) {
+                               DLSDrumsetInfo *d = &list->drumsets[i];
 
+                               tv.hInsertAfter = TVI_LAST;
+                               tv.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
+                               tv.hParent = hDrum;
+                               sprintf(str_, "Drumset %03u (%s)", d->program, d->name);
                                tv.item.pszText = str_;
-                               tv.item.cchTextMax = strlen(str_);
-                               tv.item.iImage = 2;
-                               tv.item.iSelectedImage = 3;
-                               TreeView_InsertItem(hTree, &tv);
-
-                               InsertInst(x_bank, x_preset, pname_, x_sf_filename_);
+                               tv.item.iImage = 0;
+                               tv.item.iSelectedImage = 1;
+                               hDrumSub = TreeView_InsertItem(hTree, &tv);
+
+                               for (int j = 0; j < d->note_count; j++) {
+                                       tv.hInsertAfter = TVI_LAST;
+                                       tv.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
+                                       tv.hParent = hDrumSub;
+                                       sprintf(str_, "%03u:%03u", d->program, d->notes[j]);
+                                       tv.item.pszText = str_;
+                                       tv.item.iImage = 2;
+                                       tv.item.iSelectedImage = 3;
+                                       TreeView_InsertItem(hTree, &tv);
+
+                                       InsertDrum(TRUE, 128, d->program, d->notes[j], "", x_sf_filename_);
+                               }
                        }
 
+                       free_dls_instrument_list(list);
                }
-       }
-       for (x_preset = 0; x_preset <= 127; x_preset++) {
-               flag = 0;
-               for (x_keynote = 0; x_keynote <= 127; x_keynote++) {
-                       if (x_cfg_info.d_preset[x_preset][x_keynote] >= 0 && x_cfg_info.d_keynote[x_preset][x_keynote] >= 0) {
-                               flag = 1;
-                       }
-               }
-               if (!flag)
-                       continue;
-               if (!initial) {
-                       initial = 1;
-//                     fprintf(x_out, "drumset %d\n", x_preset);
-               } else {
-//                     fprintf(x_out, "\ndrumset %d\n", x_preset);
-               }
-
-               // insert bank
-               tv.hInsertAfter = TVI_LAST;
-               tv.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
-               tv.hParent = hDrum;
-               sprintf(str_, "Drumset %03d (%s)", x_preset, sf_preset_name[128][x_preset]);
-               tv.item.pszText = str_;
-               tv.item.iImage = 0;
-               tv.item.iSelectedImage = 1;
-               hDrumSub = TreeView_InsertItem(hTree, &tv);
-
-               for (x_keynote = 0; x_keynote <= 127; x_keynote++) {
-                       if (x_cfg_info.d_preset[x_preset][x_keynote] >= 0 && x_cfg_info.d_keynote[x_preset][x_keynote] >= 0) {
+#endif
+       } else {
+               sf = new_soundfont(x_sf_file_name);
+               sf->next = NULL;
+               sf->def_order = 2;
+               sfrecs = sf;
+               x_cfg_info_init();
+               init_sf(sf);
+               if (x_sort) {
+                       for (x_bank = 0; x_bank <= 127; x_bank++) {
+                               flag = 0;
+
+                               for (x_preset = 0; x_preset <= 127; x_preset++) {
+                                       if (x_cfg_info.m_bank[x_bank][x_preset] >= 0 && x_cfg_info.m_preset[x_bank][x_preset] >= 0) {
+                                               flag = 1;
+                                       }
+                               }
+                               if (!flag)
+                                       continue;
+                               if (!initial) {
+                                       initial = 1;
+                               }
 
                                // insert bank
                                tv.hInsertAfter = TVI_LAST;
                                tv.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
-                               tv.hParent = hDrumSub;
-
-                               pname_b_ = strtok(x_cfg_info.d_str[x_preset][x_keynote], "#");
-                               if (pname_b_) {
-                                       if ((pname_ = strstr(pname_b_, ":")) == NULL)
-                                               pname_ = pname_b_;
-                                       else pname_ = "";
-                               } else pname_ = "";
-
-//                             if (x_cfg_info.d_rom[x_preset][x_keynote])
-//                                     sprintf(str_, "Bank%03d Note%03d[ROM] %s\0\0", x_preset, x_keynote, pname_);
-//                             else
-                               sprintf(str_, "%03d:%03d %s\0\0", x_preset, x_keynote, pname_);
+                               tv.hParent = hBank;
+                               sprintf(str_, "Bank %03d", x_bank);
+                               tv.item.pszText = str_;
+                               tv.item.iImage = 0;
+                               tv.item.iSelectedImage = 1;
+                               hBankSub = TreeView_InsertItem(hTree, &tv);
+
+                               for (x_preset = 0; x_preset <= 127; x_preset++) {
+                                       if (x_cfg_info.m_bank[x_bank][x_preset] >= 0 && x_cfg_info.m_preset[x_bank][x_preset] >= 0) {
+
+                                               // insert bank
+                                               tv.hInsertAfter = TVI_LAST;
+                                               tv.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
+                                               tv.hParent = hBankSub;
+
+                                               pname_ =sf_preset_name[x_bank][x_preset];
+                                               //                              if (x_cfg_info.m_rom[x_bank][x_preset])
+                                               //                                      sprintf(str_, "%03d:%03d[ROM] %s\0\0", x_bank, x_preset, pname_);
+                                               //                              else
+                                               sprintf(str_, "%03d:%03d %s\0\0", x_bank, x_preset, pname_);
+
+                                               tv.item.pszText = str_;
+                                               tv.item.cchTextMax = strlen(str_);
+                                               tv.item.iImage = 2;
+                                               tv.item.iSelectedImage = 3;
+                                               TreeView_InsertItem(hTree, &tv);
+
+                                               InsertInst(FALSE, x_bank, x_preset, pname_, x_sf_filename_);
+                                       }
+
+                               }
+                       }
+                       for (x_preset = 0; x_preset <= 127; x_preset++) {
+                               flag = 0;
+                               for (x_keynote = 0; x_keynote <= 127; x_keynote++) {
+                                       if (x_cfg_info.d_preset[x_preset][x_keynote] >= 0 && x_cfg_info.d_keynote[x_preset][x_keynote] >= 0) {
+                                               flag = 1;
+                                       }
+                               }
+                               if (!flag)
+                                       continue;
+                               if (!initial) {
+                                       initial = 1;
+                                       //                      fprintf(x_out, "drumset %d\n", x_preset);
+                               } else {
+                                       //                      fprintf(x_out, "\ndrumset %d\n", x_preset);
+                               }
 
+                               // insert bank
+                               tv.hInsertAfter = TVI_LAST;
+                               tv.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
+                               tv.hParent = hDrum;
+                               sprintf(str_, "Drumset %03d (%s)", x_preset, sf_preset_name[128][x_preset]);
                                tv.item.pszText = str_;
-                               tv.item.cchTextMax = strlen(str_);
-                               tv.item.iImage = 2;
-                               tv.item.iSelectedImage = 3;
-                               TreeView_InsertItem(hTree, &tv);
-                               InsertDrum(128, x_preset, x_keynote, pname_, x_sf_filename_);
+                               tv.item.iImage = 0;
+                               tv.item.iSelectedImage = 1;
+                               hDrumSub = TreeView_InsertItem(hTree, &tv);
+
+                               for (x_keynote = 0; x_keynote <= 127; x_keynote++) {
+                                       if (x_cfg_info.d_preset[x_preset][x_keynote] >= 0 && x_cfg_info.d_keynote[x_preset][x_keynote] >= 0) {
+
+                                               // insert bank
+                                               tv.hInsertAfter = TVI_LAST;
+                                               tv.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
+                                               tv.hParent = hDrumSub;
+
+                                               pname_b_ = strtok(x_cfg_info.d_str[x_preset][x_keynote], "#");
+                                               if (pname_b_) {
+                                                       if ((pname_ = strstr(pname_b_, ":")) == NULL)
+                                                               pname_ = pname_b_;
+                                                       else pname_ = "";
+                                               } else pname_ = "";
+
+                                               //                              if (x_cfg_info.d_rom[x_preset][x_keynote])
+                                               //                                      sprintf(str_, "Bank%03d Note%03d[ROM] %s\0\0", x_preset, x_keynote, pname_);
+                                               //                              else
+                                               sprintf(str_, "%03d:%03d %s\0\0", x_preset, x_keynote, pname_);
+
+                                               tv.item.pszText = str_;
+                                               tv.item.cchTextMax = strlen(str_);
+                                               tv.item.iImage = 2;
+                                               tv.item.iSelectedImage = 3;
+                                               TreeView_InsertItem(hTree, &tv);
+                                               InsertDrum(FALSE, 128, x_preset, x_keynote, pname_, x_sf_filename_);
+                                       }
+                               }
                        }
                }
-       }
-       }
 
-       for (x_bank = 0; x_bank <= 127; x_bank++) {
-               for (x_preset = 0; x_preset <= 127; x_preset++) {
-                       sfgui_str_free(&x_cfg_info.m_str[x_bank][x_preset]);
-                       sfgui_str_free(&x_cfg_info.d_str[x_bank][x_preset]);
+               for (x_bank = 0; x_bank <= 127; x_bank++) {
+                       for (x_preset = 0; x_preset <= 127; x_preset++) {
+                               sfgui_str_free(&x_cfg_info.m_str[x_bank][x_preset]);
+                               sfgui_str_free(&x_cfg_info.d_str[x_bank][x_preset]);
+                       }
                }
+               end_soundfont(sf);
        }
-       end_soundfont(sf);
 
        TreeView_Expand(hTree, hSF2, TVE_EXPAND);
        TreeView_Expand(hTree, hBank, TVE_EXPAND);
index cd973e2..dae4ce8 100644 (file)
@@ -8,8 +8,8 @@
 #define IDB_BITMAP1                     104
 #define IDB_TREEICON                    104
 #define IDC_TREE1                       1001
-#define IDC_EDIT1                       1002
 #define IDC_EDSFNAME                    1002
+#define IDC_EDSFLABEL                   1003
 #define ID_FILE_OPENSOUNDFONT           40001
 #define ID_FILE_QUIT                    40002
 #define ID_FILE_SAVETIMIDITYCONFIGFILE  40003
 #define IDM_OPT_APPEND_COMMENT          40010
 #define IDM_OPT_APPEND_FSPACES          40011
 #define IDM_OPT_KEEP_FULLPATH           40012
+#define IDM_OPT_PREPEND_BASEDIR         40013
 
 // Next default values for new objects
 // 
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_NEXT_RESOURCE_VALUE        105
-#define _APS_NEXT_COMMAND_VALUE         40013
-#define _APS_NEXT_CONTROL_VALUE         1003
+#define _APS_NEXT_COMMAND_VALUE         40014
+#define _APS_NEXT_CONTROL_VALUE         1004
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif
index 8e7f62b..e6088fb 100644 (file)
@@ -23,11 +23,12 @@ BEGIN
                MENUITEM "Append first spaces(&P)", IDM_OPT_APPEND_FSPACES
                MENUITEM SEPARATOR
                MENUITEM "Keep original full-path(&K)", IDM_OPT_KEEP_FULLPATH
+               MENUITEM "Prepend ""dir ${basedir}""(&D)", IDM_OPT_PREPEND_BASEDIR
        END
 END
 
 101 DIALOGEX 0, 0, 255, 195
-STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU
+STYLE WS_OVERLAPPEDWINDOW
 EXSTYLE WS_EX_ACCEPTFILES
 CAPTION "Soundfont Viewer 1.01"
 MENU IDR_MENU1
@@ -35,7 +36,7 @@ LANGUAGE LANG_JAPANESE, 0x1
 FONT 9, "MS UI Gothic", FW_NORMAL, 0, 128
 BEGIN
        CONTROL         "", IDC_TREE1, WC_TREEVIEW, WS_TABSTOP | WS_HSCROLL | WS_BORDER | TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT, 0, 0, 255, 182
-       LTEXT           "Soundfont Path", -1, 0, 183, 56, 12, SS_LEFT
+       LTEXT           "Soundfont Path", IDC_EDSFLABEL, 0, 183, 56, 12, SS_LEFT
        EDITTEXT        IDC_EDSFNAME, 57, 183, 198, 12, NOT WS_BORDER | ES_AUTOHSCROLL | ES_READONLY
 END
 
index d32a77f..d987939 100644 (file)
@@ -3,6 +3,7 @@
 #define _CRT_SECURE_NO_WARNINGS
 #pragma warning(disable:4530) // \83A\83\93\83\8f\83C\83\93\83\83Z\83}\83\93\83e\83B\83N\83X\82ª\96³\8cø
 #include <windows.h>
+#include <windowsx.h>
 #include <commctrl.h>
 #include "resource.h"
 #pragma comment(lib, "shlwapi.lib")
@@ -17,6 +18,7 @@ extern "C" {
 #include <string>
 struct sfvSFInst
 {
+       BOOL dls;
        unsigned char bank;
        unsigned char preset;
        std::string str;
@@ -25,6 +27,7 @@ struct sfvSFInst
 std::map< int, std::map< int, sfvSFInst > > g_sfInst;
 struct sfvSFDrum
 {
+       BOOL dls;
        unsigned char bank;
        unsigned char preset;
        unsigned char note;
@@ -33,12 +36,13 @@ struct sfvSFDrum
 };
 std::map< int, std::map< int, sfvSFDrum > > g_sfDrum;
 
-extern "C" void InsertInst(int bank, int preset, char *str, const char *sfname)
+extern "C" void InsertInst(BOOL dls, int bank, int preset, char *str, const char *sfname)
 {
        std::map< int, std::map< int, sfvSFInst > >::iterator it = g_sfInst.find(bank);
        if (it != g_sfInst.end()) {
 
                sfvSFInst newdata;
+        newdata.dls = dls;
                newdata.bank            = bank;
                newdata.preset          = preset;
                newdata.str             = sfname;
@@ -52,16 +56,17 @@ extern "C" void InsertInst(int bank, int preset, char *str, const char *sfname)
                }
        } else {
                g_sfInst.insert(std::make_pair(bank, std::map< int, sfvSFInst >()));
-               InsertInst(bank, preset, str, sfname);
+               InsertInst(dls, bank, preset, str, sfname);
        }
 }
 
-extern "C" void InsertDrum(int bank, int preset, int note, const char *str, const char *sfname)
+extern "C" void InsertDrum(BOOL dls, int bank, int preset, int note, const char *str, const char *sfname)
 {
        std::map< int, std::map< int, sfvSFDrum > >::iterator it = g_sfDrum.find(preset);
        if (it != g_sfDrum.end()) {
 
                sfvSFDrum newdata;
+        newdata.dls = dls;
                newdata.bank            = bank;
                newdata.preset          = preset;
                newdata.note            = note;
@@ -76,19 +81,21 @@ extern "C" void InsertDrum(int bank, int preset, int note, const char *str, cons
                }
        } else {
                g_sfDrum.insert(std::make_pair(preset, std::map< int, sfvSFDrum >()));
-               InsertDrum(bank, preset, note, str, sfname);
+               InsertDrum(dls, bank, preset, note, str, sfname);
        }
 }
 
-void SFView_ExportConfigFile(char *outFileName, int outListEnable, int outComment, int outSpace, int keepFullPath)
+void SFView_ExportConfigFile(char *outFileName, int outListEnable, int outComment, int outSpace, int keepFullPath, int prependBaseDir)
 {
        FILE *fp = fopen(outFileName, "w");
+       if (!outListEnable && prependBaseDir)
+               fprintf(fp, "\ndir \"${basedir}\"\n");
        for (std::map< int, std::map< int, sfvSFInst > >::iterator it =  g_sfInst.begin(); it != g_sfInst.end(); ++it) {
-               if (outListEnable)
-                       fprintf(fp, "bank %d\n", (*it).first);
-               else
-                       fprintf(fp, "bank %d\n", (*it).first);
+               if (!outListEnable)
+                       fprintf(fp, "\n");
+               fprintf(fp, "bank %d\n", (*it).first);
                for (std::map< int, sfvSFInst >::iterator itc = (*it).second.begin(); itc != (*it).second.end(); ++itc) {
+                       BOOL dls = (*itc).second.dls;
                        const char *file = (*itc).second.str.c_str();
                        const int program = (*itc).first;
                        const int bank = (*itc).second.bank;
@@ -102,22 +109,22 @@ void SFView_ExportConfigFile(char *outFileName, int outListEnable, int outCommen
                                fprintf(fp, "%03d:%03d %s (%s)\n", bank, preset, comment, file);
                        else {
                                if (strstr(file, " "))
-                                       fprintf(fp, "%d %%font \"%s\" %d %d", program, file, bank, preset);
+                                       fprintf(fp, "%d %s \"%s\" %d %d", program, (dls ? "%dls" : "%font"), file, bank, preset);
                                else
-                                       fprintf(fp, "%d %%font %s %d %d", program, file, bank, preset);
-                               if (outComment)
-                                       fprintf(fp, " # %s ", comment);
+                                       fprintf(fp, "%d %s %s %d %d", program, (dls ? "%dls" : "%font"), file, bank, preset);
+                               if (outComment && comment && strlen(comment))
+                                       fprintf(fp, " # %s", comment);
                                fprintf(fp, "\n");
                        }
                }
        }
 
        for (std::map< int, std::map< int, sfvSFDrum > >::iterator it =  g_sfDrum.begin(); it != g_sfDrum.end(); ++it) {
-               if (outListEnable)
-                       fprintf(fp, "drumset %d\n", (*it).first);
-               else
-                       fprintf(fp, "drumset %d\n", (*it).first);
+               if (!outListEnable)
+                       fprintf(fp, "\n");
+               fprintf(fp, "drumset %d\n", (*it).first);
                for (std::map< int, sfvSFDrum >::iterator itc = (*it).second.begin(); itc != (*it).second.end(); ++itc) {
+                       BOOL dls = (*itc).second.dls;
                        const char *file = (*itc).second.str.c_str();
                        const int program = (*itc).first;
                        const int bank = (*itc).second.bank;
@@ -132,11 +139,11 @@ void SFView_ExportConfigFile(char *outFileName, int outListEnable, int outCommen
                                fprintf(fp, "%03d:%03d %s (%s)\n", preset, note, comment, file);
                        else {
                                if (strstr(file, " "))
-                                       fprintf(fp, "%d %%font \"%s\" %d %d %d", program, file, bank, preset, note);
+                                       fprintf(fp, "%d %s \"%s\" %d %d %d", program, (dls ? "%dls" : "%font"), file, bank, preset, note);
                                else
-                                       fprintf(fp, "%d %%font %s %d %d %d", program, file, bank, preset, note);
-                               if (outComment)
-                                       fprintf(fp, " # %s ", comment);
+                                       fprintf(fp, "%d %s %s %d %d %d", program, (dls ? "%dls" : "%font"), file, bank, preset, note);
+                               if (outComment && comment && strlen(comment))
+                                       fprintf(fp, " # %s", comment);
                                fprintf(fp, "\n");
                        }
                }
@@ -152,8 +159,8 @@ void ExportFile(HWND hDlg, bool bExportList)
 {
        MENUITEMINFO mii = { sizeof(MENUITEMINFO) };
        HMENU hMenu = GetMenu(hDlg);
-       CONST UINT menuIDs[] = { IDM_OPT_APPEND_COMMENT, IDM_OPT_APPEND_FSPACES, IDM_OPT_KEEP_FULLPATH };
-       BOOL states[] = { FALSE, FALSE, FALSE };
+       CONST UINT menuIDs[] = { IDM_OPT_APPEND_COMMENT, IDM_OPT_APPEND_FSPACES, IDM_OPT_KEEP_FULLPATH, IDM_OPT_PREPEND_BASEDIR};
+       BOOL states[] = { FALSE, FALSE, FALSE, FALSE };
        CMyFileDialog fd;
        fd.setSaveDlgDefaultSetting();
        fd.setTitle("Export filename ..");
@@ -172,13 +179,15 @@ void ExportFile(HWND hDlg, bool bExportList)
                fd.setDefaultExt("cfg");
                fd.setFilter("TiMidity++ Config File (*.cfg)\0*.cfg\0\0");
        }
-       if (fd.Execute()) {
-               SFView_ExportConfigFile((char*)fd.getFile(0),
-                                       (int)bExportList,
-                                       (int)states[0],
-                                       (int)states[1],
-                                       (int)states[2]);
-       }
+    if (fd.Execute()) {
+        SFView_ExportConfigFile((char*)fd.getFile(0),
+            (int)bExportList,
+            (int)states[0],
+            (int)states[1],
+            (int)states[2],
+            (int)states[3]
+        );
+    }
 }
 
 HIMAGELIST g_hil = NULL;
@@ -188,8 +197,8 @@ LRESULT DlgMainProc_INITDIALOG(HWND hDlg, WPARAM wParam, LPARAM lParam)
 {
        MENUITEMINFO mii = { sizeof(MENUITEMINFO) };
        HMENU hMenu = GetMenu(hDlg);
-       CONST UINT menuIDs[] = { IDM_OPT_APPEND_COMMENT, IDM_OPT_APPEND_FSPACES, IDM_OPT_KEEP_FULLPATH };
-       CONST UINT states[] = { MFS_UNCHECKED, MFS_UNCHECKED, MFS_CHECKED };
+       CONST UINT menuIDs[] = { IDM_OPT_APPEND_COMMENT, IDM_OPT_APPEND_FSPACES, IDM_OPT_KEEP_FULLPATH, IDM_OPT_PREPEND_BASEDIR};
+       CONST UINT states[] = { MFS_CHECKED, MFS_UNCHECKED, MFS_UNCHECKED, MFS_CHECKED };
 
        if (__argc == 2) {
                ResetSoundFontTree(hDlg);
@@ -247,7 +256,18 @@ LRESULT DlgMainProc_COMMAND(HWND hDlg, WPARAM wParam, LPARAM lParam)
                CMyFileDialog fd;
                fd.setOpenDlgDefaultSetting();
                fd.setTitle("open soundfont");
-               fd.setFilter("soundfont (*.sf2;*.sf3)\0*.sf2;*.sf3\0All files (*.*)\0*.*\0\0");
+               fd.setFilter(
+#ifdef ENABLE_DLS
+            "Supported files (*.dls;*.sf2;*.sf3)\0*.dls;*.sf2;*.sf3\0"
+#else
+            "Supported files (*.sf2;*.sf3)\0*.sf2;*.sf3\0"
+#endif
+            "Soundfont (*.sf2;*.sf3)\0*.sf2;*.sf3\0"
+#ifdef ENABLE_DLS
+            "DLS (*.dls)\0*.dls\0"
+#endif
+            "All files (*.*)\0*.*\0\0"
+        );
                fd.setOwner(hDlg);
                if (fd.Execute()) {
                        const int n = fd.getIndex();
@@ -276,6 +296,7 @@ LRESULT DlgMainProc_COMMAND(HWND hDlg, WPARAM wParam, LPARAM lParam)
        case IDM_OPT_APPEND_COMMENT:
        case IDM_OPT_APPEND_FSPACES:
        case IDM_OPT_KEEP_FULLPATH:
+    case IDM_OPT_PREPEND_BASEDIR:
                hMenu = GetMenu(hDlg);
                mii.fMask = MIIM_STATE | MIIM_ID;
                GetMenuItemInfo(hMenu, LOWORD(wParam), FALSE, &mii);
@@ -297,6 +318,43 @@ LRESULT DlgMainProc_CLOSE(HWND hDlg, WPARAM wParam, LPARAM lParam)
        return TRUE;
 }
 
+LRESULT DlgMainProc_SIZE(HWND hDlg, WPARAM wParam, LPARAM lParam)
+{
+    if (wParam != SC_MINIMIZE) {
+        SetWindowPos(
+            GetDlgItem(hDlg, IDC_TREE1),
+            NULL,
+            0,
+            0,
+            GET_X_LPARAM(lParam),
+            GET_Y_LPARAM(lParam) - 17,
+            SWP_NOACTIVATE | SWP_NOZORDER
+        );
+
+        SetWindowPos(
+            GetDlgItem(hDlg, IDC_EDSFLABEL),
+            NULL,
+            0,
+            GET_Y_LPARAM(lParam) - 16,
+            99,
+            16,
+            SWP_NOACTIVATE | SWP_NOZORDER
+        );
+
+        SetWindowPos(
+            GetDlgItem(hDlg, IDC_EDSFNAME),
+            NULL,
+            100,
+            GET_Y_LPARAM(lParam) - 16,
+            GET_X_LPARAM(lParam) - 100,
+            16,
+            SWP_NOACTIVATE | SWP_NOZORDER
+        );
+    }
+
+    return TRUE;
+}
+
 LRESULT CALLBACK DlgMainProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 {
 #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)
                SET_MYWINMSG(DROPFILES);
                SET_MYWINMSG(COMMAND);
                SET_MYWINMSG(CLOSE);
+               SET_MYWINMSG(SIZE);
        }
 #undef  SET_MYWINMSG
        return FALSE;
index 9024bac..fbbff4d 100644 (file)
                                >
                        </File>
                        <File
+                               RelativePath="..\interface\rtsyn_portmidi.c"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\interface\rtsyn_winmm.c"
                                >
                        </File>
index dee5e34..c24cd35 100644 (file)
     <ClCompile Include="..\interface\portmidisyn_c.c" />
     <ClCompile Include="..\interface\rtsyn_common.c" />
     <ClCompile Include="..\interface\rtsyn_npipe.c" />
+    <ClCompile Include="..\interface\rtsyn_portmidi.c" />
     <ClCompile Include="..\interface\rtsyn_winmm.c" />
     <ClCompile Include="..\interface\vt100.c" />
     <ClCompile Include="..\interface\vt100_c.c" />
index 4997a67..857eba0 100644 (file)
@@ -421,7 +421,7 @@ struct timidity_file *open_with_constmem(const char *mem, ptr_size_t memlen, int
  * This is meant to find and open files for reading, possibly piping
  * them through a decompressor.
  */
-struct timidity_file *open_file(char *name, int decompress, int noise_mode)
+struct timidity_file *open_file(const char *name, int decompress, int noise_mode)
 {
        struct timidity_file *tf;
        PathList *plp = pathlist;
@@ -496,7 +496,7 @@ struct timidity_file *open_file(char *name, int decompress, int noise_mode)
  * This is meant to find and open regular files for reading, possibly
  * piping them through a decompressor.
  */
-struct timidity_file *open_file_r(char *name, int decompress, int noise_mode)
+struct timidity_file *open_file_r(const char *name, int decompress, int noise_mode)
 {
        struct stat st;
        struct timidity_file *tf;
index c35eae4..eb4a284 100644 (file)
@@ -47,6 +47,21 @@ extern "C"
 namespace TimDLS
 {
 
+void TrimRight(std::string& str)
+{
+    using namespace std::string_view_literals;
+    std::size_t pos = str.find_last_not_of("\0 \t\r\n"sv);
+
+    if (pos == str.npos)
+    {
+        str.clear();
+    }
+    else
+    {
+        str.resize(pos + 1);
+    }
+}
+
 struct TFFileCloser
 {
     void operator()(timidity_file* pFile) const
@@ -229,6 +244,25 @@ struct DLSCollection
     std::uint32_t WavePoolOffset; // offset of wave pool from the beginning of the DLS file
 };
 
+struct DLSProgram
+{
+    std::uint8_t ProgramNumber;
+    std::string Name;
+};
+
+struct DLSBank
+{
+    std::uint8_t BankNumber;
+    std::vector<DLSProgram> Programs;
+};
+
+struct DLSDrumset
+{
+    std::uint8_t DrumsetNumber;
+    std::string Name;
+    std::vector<std::uint8_t> Notes;
+};
+
 std::int32_t CalcRate(std::int32_t diff, double sec)
 {
     const std::int32_t envMax = 0x3FFFFFFF;
@@ -278,39 +312,63 @@ public:
         }
 
         ParseRIFF(pFile.get());
+    }
+
+    std::vector<DLSBank> GetBankList() const
+    {
+        std::vector<DLSBank> banks;
 
-#if 0
-        for (const DLSInstrument& i : m_DLS.Instruments)
+        for (const TimDLS::DLSInstrument& i : m_DLS.Instruments)
         {
-            if (i.Bank == 128)
+            if (i.Bank != 128)
             {
-                for (const DLSRegion& r : i.Regions)
+                auto itBank = std::lower_bound(banks.begin(), banks.end(), i.Bank, [] (auto&& a, auto&& b) { return a.BankNumber < b; });
+
+                if (itBank == banks.end() || itBank->BankNumber != i.Bank)
                 {
-                    ctl->cmsg(
-                        CMSG_INFO,
-                        VERB_NORMAL,
-                        "%d %%dls \"gm.dls\" 128 %d %d # %s",
-                        r.SampleInfo->UnityNote,
-                        i.ProgramNumber,
-                        r.SampleInfo->UnityNote,
-                        i.Name.c_str()
-                    );
+                    itBank = banks.emplace(itBank);
+                    itBank->BankNumber = i.Bank;
                 }
+
+                auto& program = itBank->Programs.emplace_back();
+                program.ProgramNumber = i.ProgramNumber;
+                program.Name = i.Name;
+                TrimRight(program.Name);
             }
-            else
+        }
+
+        for (DLSBank& b : banks)
+        {
+            std::sort(b.Programs.begin(), b.Programs.end(), [] (auto&& a, auto&& b) { return a.ProgramNumber < b.ProgramNumber; });
+        }
+
+        return banks;
+    }
+
+    std::vector<DLSDrumset> GetDrumsetList() const
+    {
+        std::vector<DLSDrumset> drumsets;
+
+        for (const TimDLS::DLSInstrument& i : m_DLS.Instruments)
+        {
+            if (i.Bank == 128)
             {
-                ctl->cmsg(
-                    CMSG_INFO,
-                    VERB_NORMAL,
-                    "%d %%dls \"gm.dls\" %d %d # %s",
-                    i.ProgramNumber,
-                    i.Bank,
-                    i.ProgramNumber,
-                    i.Name.c_str()
-                );
+                auto& drumset = drumsets.emplace_back();
+                drumset.DrumsetNumber = i.ProgramNumber;
+                drumset.Name = i.Name;
+                TrimRight(drumset.Name);
+
+                for (const TimDLS::DLSRegion& r : i.Regions)
+                {
+                    drumset.Notes.push_back(r.SampleInfo->UnityNote);
+                }
+
+                std::sort(drumset.Notes.begin(), drumset.Notes.end());
             }
         }
-#endif
+
+        std::sort(drumsets.begin(), drumsets.end(), [] (auto&& a, auto&& b) { return a.DrumsetNumber < b.DrumsetNumber; });
+        return drumsets;
     }
 
     std::unique_ptr<Instrument, InstrumentDeleter> BuildInstrument(std::uint8_t bank, std::int8_t programNumber, std::int8_t note)
@@ -430,8 +488,10 @@ public:
 
                 pSample->cutoff_freq = 20000;
                 pSample->cutoff_low_limit = -1;
-                pSample->envelope_velf_bpo = 64;
-                pSample->modenv_velf_bpo = 64;
+                pSample->envelope_velf_bpo = 0;
+                pSample->modenv_velf_bpo = 0;
+                pSample->envelope_keyf_bpo = 0;
+                pSample->modenv_keyf_bpo = 0;
                 pSample->key_to_fc_bpo = 60;
                 pSample->scale_freq = 60;
                 pSample->scale_factor = 1024;
@@ -472,12 +532,12 @@ public:
                         case DLSConnectionBlock::DestinationKind::EG1AttackTime:
                             if (b.Source == DLSConnectionBlock::SourceKind::None && b.Control == DLSConnectionBlock::SourceKind::None && b.Transform == DLSConnectionBlock::TransformKind::None)
                             {
-                                attackTime = TimeCentToSecond(b.Scale);
+                                attackTime = std::clamp(TimeCentToSecond(b.Scale), 0.0, 20.0);
                                 continue;
                             }
                             else if (b.Source == DLSConnectionBlock::SourceKind::KeyOnVelocity && b.Control == DLSConnectionBlock::SourceKind::None && b.Transform == DLSConnectionBlock::TransformKind::None)
                             {
-                                pSample->envelope_velf[0] = static_cast<int16>(b.Scale / 65536);
+                                pSample->envelope_velf[0] = static_cast<int16>(b.Scale / 128 / 65536);
                                 continue;
                             }
                             break;
@@ -485,13 +545,12 @@ public:
                         case DLSConnectionBlock::DestinationKind::EG1DecayTime:
                             if (b.Source == DLSConnectionBlock::SourceKind::None && b.Control == DLSConnectionBlock::SourceKind::None && b.Transform == DLSConnectionBlock::TransformKind::None)
                             {
-                                decayTime = TimeCentToSecond(b.Scale);
+                                decayTime = std::clamp(TimeCentToSecond(b.Scale), 0.0, 40.0);
                                 continue;
                             }
                             else if (b.Source == DLSConnectionBlock::SourceKind::KeyNumber && b.Control == DLSConnectionBlock::SourceKind::None && b.Transform == DLSConnectionBlock::TransformKind::None)
                             {
-                                // this is probably incorrect
-                                pSample->envelope_keyf[1] = static_cast<int16>(b.Scale / 65536);
+                                pSample->envelope_keyf[1] = static_cast<int16>(b.Scale / 128 / 65536);
                                 continue;
                             }
                             break;
@@ -499,7 +558,7 @@ public:
                         case DLSConnectionBlock::DestinationKind::EG1SustainLevel:
                             if (b.Source == DLSConnectionBlock::SourceKind::None && b.Control == DLSConnectionBlock::SourceKind::None && b.Transform == DLSConnectionBlock::TransformKind::None)
                             {
-                                sustainLevel = std::lround(65533.0 * std::clamp(b.Scale, 0, 1000) / 1000.0);
+                                sustainLevel = std::clamp(b.Scale / 1000, 0, 65533);
                                 continue;
                             }
                             break;
@@ -507,7 +566,7 @@ public:
                         case DLSConnectionBlock::DestinationKind::EG1ReleaseTime:
                             if (b.Source == DLSConnectionBlock::SourceKind::None && b.Control == DLSConnectionBlock::SourceKind::None && b.Transform == DLSConnectionBlock::TransformKind::None)
                             {
-                                releaseTime = TimeCentToSecond(b.Scale);
+                                releaseTime = std::clamp(TimeCentToSecond(b.Scale), 0.0, 20.0);
                                 continue;
                             }
                             break;
@@ -551,6 +610,14 @@ public:
                             }
                             break;
 
+                        case DLSConnectionBlock::DestinationKind::Pan:
+                            if (b.Source == DLSConnectionBlock::SourceKind::None && b.Control == DLSConnectionBlock::SourceKind::None && b.Transform == DLSConnectionBlock::TransformKind::None)
+                            {
+                                pSample->sample_pan = std::clamp(b.Scale / 65536.0 / 1000.0, -0.5, 0.5);
+                                continue;
+                            }
+                            break;
+
                         default:
                             break;
                         }
@@ -575,15 +642,17 @@ public:
                 pSample->envelope_rate[1] = CalcRate(1, holdTime);
 
                 pSample->envelope_offset[2] = ToOffset(sustainLevel);
-                pSample->envelope_rate[2] = CalcRate(65534 - sustainLevel, std::clamp(decayTime, 0.0, 100.0));
+                pSample->envelope_rate[2] = CalcRate(65534 - sustainLevel, decayTime);
 
                 pSample->envelope_offset[3] = 0;
-                pSample->envelope_rate[3] = CalcRate(sustainLevel, releaseTime);
-                pSample->envelope_offset[4] = pSample->envelope_offset[3];
+                pSample->envelope_rate[3] = CalcRate(65535, releaseTime);
+                pSample->envelope_offset[4] = 0;
                 pSample->envelope_rate[4] = pSample->envelope_rate[3];
-                pSample->envelope_offset[5] = pSample->envelope_offset[3];
+                pSample->envelope_offset[5] = 0;
                 pSample->envelope_rate[5] = pSample->envelope_rate[3];
 
+                pSample->modes |= MODES_ENVELOPE;
+
                 filledSamples++;
 
                 if (filledSamples >= regionCount)
@@ -1669,3 +1738,86 @@ extern "C" void free_dls_file(Instrument *ip)
 {
     TimDLS::GlobalInstrumentCache.FreeInstrument(ip);
 }
+
+DLSCollectionInfo *get_dls_instrument_list(const char *sample_file)
+{
+    try
+    {
+        std::string fileName = sample_file;
+        TimDLS::DLSParser dls(fileName);
+        dls.Parse();
+
+        auto banks = dls.GetBankList();
+        auto drumsets = dls.GetDrumsetList();
+
+        std::unique_ptr<DLSCollectionInfo, TimDLS::TimDeleter> pList(reinterpret_cast<DLSCollectionInfo*>(safe_calloc(sizeof(DLSCollectionInfo), 1)));
+
+        // move data from C++ to C
+        pList->banks = reinterpret_cast<DLSBankInfo*>(safe_malloc(sizeof(DLSBankInfo) * banks.size()));
+        pList->bank_count = static_cast<int>(banks.size());
+
+        for (std::size_t i = 0; i < banks.size(); i++)
+        {
+            auto& b = banks[i];
+
+            pList->banks[i].bank = b.BankNumber;
+            pList->banks[i].programs = reinterpret_cast<DLSProgramInfo*>(safe_malloc(sizeof(DLSProgramInfo) * b.Programs.size()));
+            pList->banks[i].program_count = static_cast<int>(b.Programs.size());
+
+            for (std::size_t j = 0; j < b.Programs.size(); j++)
+            {
+                pList->banks[i].programs[j].name = safe_strdup(b.Programs[j].Name.c_str());
+                pList->banks[i].programs[j].program = b.Programs[j].ProgramNumber;
+            }
+        }
+
+        pList->drumsets = reinterpret_cast<DLSDrumsetInfo*>(safe_malloc(sizeof(DLSDrumsetInfo) * drumsets.size()));
+        pList->drumset_count = static_cast<int>(drumsets.size());
+
+        for (std::size_t i = 0; i < drumsets.size(); i++)
+        {
+            auto& ds = drumsets[i];
+            pList->drumsets[i].name = safe_strdup(ds.Name.c_str());
+            pList->drumsets[i].program = ds.DrumsetNumber;
+            pList->drumsets[i].notes = reinterpret_cast<uint8*>(safe_malloc(sizeof(uint8) * ds.Notes.size()));
+            pList->drumsets[i].note_count = static_cast<int>(ds.Notes.size());
+
+            std::uninitialized_copy(ds.Notes.begin(), ds.Notes.end(), pList->drumsets[i].notes);
+        }
+
+        return pList.release();
+    }
+    catch (const std::exception&)
+    {
+        return nullptr;
+    }
+}
+
+void free_dls_instrument_list(DLSCollectionInfo *list)
+{
+    if (!list)
+    {
+        return;
+    }
+
+    for (int i = 0; i < list->bank_count; i++)
+    {
+        for (int j = 0; j < list->banks[i].program_count; j++)
+        {
+            safe_free(list->banks[i].programs[j].name);
+        }
+
+        safe_free(list->banks[i].programs);
+    }
+
+    for (int i = 0; i < list->drumset_count; i++)
+    {
+        safe_free(list->drumsets[i].name);
+        safe_free(list->drumsets[i].notes);
+    }
+
+    safe_free(list->banks);
+    safe_free(list->drumsets);
+
+    safe_free(list);
+}
index a8d1b9c..0e25b14 100644 (file)
@@ -8,4 +8,32 @@ void free_dls(void);
 Instrument *extract_dls_file(char *sample_file, uint8 font_bank, int8 font_preset, int8 font_keynote);
 void free_dls_file(Instrument *ip);
 
+typedef struct {
+       char *name;
+       uint8 program;
+} DLSProgramInfo;
+
+typedef struct {
+       DLSProgramInfo *programs;
+       int program_count;
+       uint8 bank;
+} DLSBankInfo;
+
+typedef struct {
+       char *name;
+       uint8 *notes;
+       int note_count;
+       uint8 program;
+} DLSDrumsetInfo;
+
+typedef struct {
+       DLSBankInfo *banks;
+       DLSDrumsetInfo *drumsets;
+       int bank_count;
+       int drumset_count;
+} DLSCollectionInfo;
+
+DLSCollectionInfo *get_dls_instrument_list(const char *sample_file);
+void free_dls_instrument_list(DLSCollectionInfo *list);
+
 #endif
index 0a53ec6..4c94e59 100644 (file)
@@ -2250,7 +2250,7 @@ void free_instruments(int reload_default_inst)
                                if(bank->tone[j][elm] == NULL)
                                        continue;
                                ip = bank->tone[j][elm]->instrument;
-                               if(ip && (ip->type == INST_SF2 || ip->type == INST_PCM || ip->type == INST_MMS || ip->type == INST_SCC || ip->type == INST_SFZ) &&
+                               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) &&
                                        (i == 0 || !tonebank[0]->tone[j][elm] || ip != tonebank[0]->tone[j][elm]->instrument) )
                                                free_instrument(ip);
                                bank->tone[j][elm]->instrument = NULL;
@@ -2262,7 +2262,7 @@ void free_instruments(int reload_default_inst)
                                if(bank->tone[j][elm] == NULL)
                                        continue;
                                ip = bank->tone[j][elm]->instrument;
-                               if(ip && (ip->type == INST_SF2 || ip->type == INST_PCM || ip->type == INST_MMS || ip->type == INST_SCC || ip->type == INST_SFZ) &&
+                               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) &&
                                   (i == 0 || !drumset[0]->tone[j][elm] || ip != drumset[0]->tone[j][elm]->instrument) )
                                        free_instrument(ip);
                                bank->tone[j][elm]->instrument = NULL;
index 0486acc..2da4542 100755 (executable)
@@ -232,7 +232,7 @@ static int read_mfi_information(int infoLength, int *mfiVersion, int *noteType,
                                        case BE_FCC(0x30333030 /*0300*/):       *mfiVersion = 3;        break;
                                        default:
                                                ctl->cmsg(CMSG_WARNING, VERB_NORMAL, "Unknown MFi version.");
-                                               return 1;
+                                               //return 1;
                                }
                                ctl->cmsg(CMSG_TEXT, VERB_VERBOSE, "MFi Version: %d", *mfiVersion);
                                /*
index 7a4f755..52a4d37 100644 (file)
@@ -531,7 +531,6 @@ void mix_voice(DATA_T *buf, int v, int32 c)
                recompute_resample_filter(v);
        }
        apply_envelope_to_amp(v);
-#ifdef INT_SYNTH
        switch(vp->sample->inst_type){
        case INST_GUS:
        case INST_SF2:
@@ -553,24 +552,15 @@ void mix_voice(DATA_T *buf, int v, int32 c)
                        resample_filter(v, sp, c);
                }
                break;
+#ifdef INT_SYNTH
        case INST_MMS:
                compute_voice_mms(v, sp, c);
                break;
        case INST_SCC:
                compute_voice_scc(v, sp, c);
                break;
-       }
-#else
-       if(opt_resample_over_sampling){
-               int32 c2 = c * opt_resample_over_sampling;
-               resample_voice(v, sp, c2);
-               resample_filter(v, sp, c2);
-               resample_down_sampling(sp, c);
-       }else{
-               resample_voice(v, sp, c);
-               resample_filter(v, sp, c);
-       }
 #endif
+       }
 #ifdef VOICE_EFFECT
        voice_effect(v, sp, c);
 #endif
index d8b4763..640c966 100644 (file)
@@ -245,7 +245,7 @@ extern double playmode_rate_us;
 extern void init_output(void);
 extern void change_output_volume(int32);
 
-#ifdef __W32__
+#if defined(__W32__) && !defined(CFG_FOR_SF) 
 extern CRITICAL_SECTION critSect;
 #endif
 
index ea86631..c335a83 100644 (file)
@@ -4129,7 +4129,8 @@ static void recompute_mod_envelope_follow(int v, int ch)
                time_ms = calc_nrpn_param(time_ms, (double)add_param[EG_GUS_ATTACK] * env_attack_calc, nrpn_env_attack_mode);
                if(time_ms <= 0.0) 
                        vp->mod_env.rate[ENV0_ATTACK_STAGE] = ENV0_OFFSET_MAX;
-               vp->mod_env.rate[ENV0_ATTACK_STAGE] = sub_ofs_div_cr / time_ms;
+               else
+                       vp->mod_env.rate[ENV0_ATTACK_STAGE] = sub_ofs_div_cr / time_ms;
        }
        if(add_param[EG_GUS_DECAY]){
                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;
index bb49936..13d554a 100644 (file)
@@ -662,53 +662,53 @@ enum { // module_id
 
 struct _ModuleList {
        int num;
-       char *name;
+       const char *name;
 };
 static struct _ModuleList module_list[] = {
-       MODULE_TIMIDITY_DEFAULT,        "TiMidity++ Default",
-       MODULE_SC55,                            "SC-55 CM-300 CM-500C",
-       MODULE_SC88,                            "SC-88",
-       MODULE_SC88PRO,                         "SC-88Pro",
-       MODULE_SC8850,                          "SC-8850 SC-8820 SC-D70",
-       MODULE_SD20,                            "SD-20",
-       MODULE_SD80,                            "SD-80",
-       MODULE_SD90,                            "SD-90",
-       MODULE_SD50,                            "SD-50",
-       MODULE_MU50,                            "MU-50",
-       MODULE_MU80,                            "MU-80",
-       MODULE_MU90,                            "MU-90",
-       MODULE_MU100,                           "MU-100",
-       MODULE_MU128,                           "MU-128",
-       MODULE_MU500,                           "MU-500",
-       MODULE_MU1000,                          "MU-1000",
-       MODULE_MU2000,                          "MU-2000",
-       MODULE_AG10,                            "AG-10",
-       MODULE_05RW,                            "05R/W",
-       MODULE_NX5R,                            "NX5R NS5R",
-       MODULE_MT32,                            "MT-32",
-       MODULE_CM32L,                           "CM-32L",
-       MODULE_CM32P,                           "CM-32P",
-       MODULE_CM64,                            "CM-64 (CM32L+CM32P)",
-       MODULE_CM500D,                          "CM-500 mode D",
-       MODULE_CM64_SN01,                       "CM64+SN01 P.Orgn+Harpsi",
-       MODULE_CM64_SN02,                       "CM64+SN02 Latin+FXPerc",
-       MODULE_CM64_SN03,                       "CM64+SN03 Ethic",
-       MODULE_CM64_SN04,                       "CM64+SN04 E.Grnd+Clavi",
-       MODULE_CM64_SN05,                       "CM64+SN05 Orch Strings",
-       MODULE_CM64_SN06,                       "CM64+SN06 Orch Winds",
-       MODULE_CM64_SN07,                       "CM64+SN07 Elec Guitar",
-       MODULE_CM64_SN08,                       "CM64+SN08 Synthesizer",
-       MODULE_CM64_SN09,                       "CM64+SN09 Guitar+KB",
-       MODULE_CM64_SN10,                       "CM64+SN10 Rock Drums",
-       MODULE_CM64_SN11,                       "CM64+SN11 Sound Effect",
-       MODULE_CM64_SN12,                       "CM64+SN12 Sax+Trombone",
-       MODULE_CM64_SN13,                       "CM64+SN13 Super Strings",
-       MODULE_CM64_SN14,                       "CM64+SN14 Super AcGuitar",
-       MODULE_CM64_SN15,                       "CM64+SN15 Super Brass",
-       MODULE_SBLIVE,                          "Sound Blaster Live!",
-       MODULE_SBAUDIGY,                        "Sound Blaster Audigy",
-       MODULE_TIMIDITY_SPECIAL1,       "TiMidity++ Special 1",
-       MODULE_TIMIDITY_DEBUG,          "TiMidity++ Debug",
+       {MODULE_TIMIDITY_DEFAULT,       "TiMidity++ Default"},
+       {MODULE_SC55,                           "SC-55 CM-300 CM-500C"},
+       {MODULE_SC88,                           "SC-88"},
+       {MODULE_SC88PRO,                                "SC-88Pro"},
+       {MODULE_SC8850,                         "SC-8850 SC-8820 SC-D70"},
+       {MODULE_SD20,                           "SD-20"},
+       {MODULE_SD80,                           "SD-80"},
+       {MODULE_SD90,                           "SD-90"},
+       {MODULE_SD50,                           "SD-50"},
+       {MODULE_MU50,                           "MU-50"},
+       {MODULE_MU80,                           "MU-80"},
+       {MODULE_MU90,                           "MU-90"},
+       {MODULE_MU100,                          "MU-100"},
+       {MODULE_MU128,                          "MU-128"},
+       {MODULE_MU500,                          "MU-500"},
+       {MODULE_MU1000,                         "MU-1000"},
+       {MODULE_MU2000,                         "MU-2000"},
+       {MODULE_AG10,                           "AG-10"},
+       {MODULE_05RW,                           "05R/W"},
+       {MODULE_NX5R,                           "NX5R NS5R"},
+       {MODULE_MT32,                           "MT-32"},
+       {MODULE_CM32L,                          "CM-32L"},
+       {MODULE_CM32P,                          "CM-32P"},
+       {MODULE_CM64,                           "CM-64 (CM32L+CM32P)"},
+       {MODULE_CM500D,                         "CM-500 mode D"},
+       {MODULE_CM64_SN01,                      "CM64+SN01 P.Orgn+Harpsi"},
+       {MODULE_CM64_SN02,                      "CM64+SN02 Latin+FXPerc"},
+       {MODULE_CM64_SN03,                      "CM64+SN03 Ethic"},
+       {MODULE_CM64_SN04,                      "CM64+SN04 E.Grnd+Clavi"},
+       {MODULE_CM64_SN05,                      "CM64+SN05 Orch Strings"},
+       {MODULE_CM64_SN06,                      "CM64+SN06 Orch Winds"},
+       {MODULE_CM64_SN07,                      "CM64+SN07 Elec Guitar"},
+       {MODULE_CM64_SN08,                      "CM64+SN08 Synthesizer"},
+       {MODULE_CM64_SN09,                      "CM64+SN09 Guitar+KB"},
+       {MODULE_CM64_SN10,                      "CM64+SN10 Rock Drums"},
+       {MODULE_CM64_SN11,                      "CM64+SN11 Sound Effect"},
+       {MODULE_CM64_SN12,                      "CM64+SN12 Sax+Trombone"},
+       {MODULE_CM64_SN13,                      "CM64+SN13 Super Strings"},
+       {MODULE_CM64_SN14,                      "CM64+SN14 Super AcGuitar"},
+       {MODULE_CM64_SN15,                      "CM64+SN15 Super Brass"},
+       {MODULE_SBLIVE,                         "Sound Blaster Live!"},
+       {MODULE_SBAUDIGY,                       "Sound Blaster Audigy"},
+       {MODULE_TIMIDITY_SPECIAL1,      "TiMidity++ Special 1"},
+       {MODULE_TIMIDITY_DEBUG,         "TiMidity++ Debug"},
 };
 #define module_list_num (sizeof(module_list) / sizeof(struct _ModuleList))
 
index e6304f8..05dd7b1 100644 (file)
@@ -33,7 +33,6 @@
 #include <strings.h>
 #endif
 
-#include "interface.h"
 #include "timidity.h"
 #include "common.h"
 #include "instrum.h"
@@ -4640,9 +4639,10 @@ static void lo_rs_loop(Voice *vp, DATA_T *dest, int32 count)
        dest = resample_linear_multi(vp, dest, j, &i);
        for(; i < count; i++) {
                *dest++ = resample_linear_single(vp);
-               if((resrc->offset += resrc->increment) >= resrc->loop_end)
+               resrc->offset += resrc->increment;
+               while(resrc->offset >= resrc->loop_end)
                        resrc->offset -= resrc->loop_end - resrc->loop_start;
-               /* Hopefully the loop is longer than an increment. */
+               /* The loop may not be longer than an increment. */
        }
 }
 
@@ -4825,9 +4825,10 @@ static void lo_rs_loop_float(Voice *vp, DATA_T *dest, int32 count)
        dest = resample_linear_float_multi(vp, dest, j, &i);
        for(; i < count; i++) {
                *dest++ = resample_linear_float_single(vp);
-               if((resrc->offset += resrc->increment) >= resrc->loop_end)
+               resrc->offset += resrc->increment;
+               while(resrc->offset >= resrc->loop_end)
                        resrc->offset -= resrc->loop_end - resrc->loop_start;
-               /* Hopefully the loop is longer than an increment. */
+               /* The loop may not be longer than an increment. */
        }
 }
 
@@ -5704,9 +5705,10 @@ static void lao_rs_loop(Voice *vp, DATA_T *dest, int32 count)
        }
        for(; i < count; i++) {
                *dest++ = resample_lagrange_single(vp);
-               if((resrc->offset += resrc->increment) >= resrc->loop_end)
+               resrc->offset += resrc->increment;
+               while(resrc->offset >= resrc->loop_end)
                        resrc->offset -= resrc->loop_end - resrc->loop_start;
-               /* Hopefully the loop is longer than an increment. */
+               /* The loop may not be longer than an increment. */
        }
 }
 
@@ -6088,9 +6090,10 @@ static void lao_rs_loop_float(Voice *vp, DATA_T *dest, int32 count)
        }
        for(; i < count; i++) {
                *dest++ = resample_lagrange_float_single(vp);
-               if((resrc->offset += resrc->increment) >= resrc->loop_end)
+               resrc->offset += resrc->increment;
+               while(resrc->offset >= resrc->loop_end)
                        resrc->offset -= resrc->loop_end - resrc->loop_start;
-               /* Hopefully the loop is longer than an increment. */
+               /* The loop may not be longer than an increment. */
        }
 }
 
index 7cf02db..6d6e3f0 100644 (file)
@@ -28,6 +28,7 @@ Instrument *extract_sample_file(char *sample_file);
 #include <cstring>
 
 #include <algorithm>
+#include <deque>
 #include <exception>
 #include <iterator>
 #include <memory>
@@ -795,7 +796,7 @@ private:
     };
 
     std::vector<std::string> m_FileNames;
-    std::vector<TextBuffer> m_InBuffers;
+    std::deque<TextBuffer> m_InBuffers;
     std::stack<InputStackItem, std::vector<InputStackItem>> m_InputStack;
     TextBuffer m_OutBuffer;
     std::unordered_map<std::string, TextBuffer::View> m_DefinedMacros;
@@ -810,6 +811,8 @@ enum class OpCodeKind
     AmpEG_Hold,
     AmpEG_Release,
     AmpEG_Sustain,
+    AmpKeyCenter,
+    AmpKeyTrack,
     AmpVelTrack,
     DefaultPath,
     HiKey,
@@ -821,8 +824,10 @@ enum class OpCodeKind
     LoVelocity,
     Offset,
     Key,
+    Pan,
     PitchKeyCenter,
     Sample,
+    Transpose,
     Trigger,
     Tune,
     Volume
@@ -951,6 +956,7 @@ public:
                     {
                         switch (opVal.OpCode)
                         {
+                        case OpCodeKind::AmpKeyCenter:
                         case OpCodeKind::HiKey:
                         case OpCodeKind::LoKey:
                         case OpCodeKind::PitchKeyCenter:
@@ -975,12 +981,15 @@ public:
                         case OpCodeKind::AmpEG_Hold:
                         case OpCodeKind::AmpEG_Release:
                         case OpCodeKind::AmpEG_Sustain:
+                        case OpCodeKind::AmpKeyTrack:
                         case OpCodeKind::AmpVelTrack:
                         case OpCodeKind::HiVelocity:
                         case OpCodeKind::LoopEnd:
                         case OpCodeKind::LoopStart:
                         case OpCodeKind::LoVelocity:
                         case OpCodeKind::Offset:
+                        case OpCodeKind::Pan:
+                        case OpCodeKind::Transpose:
                         case OpCodeKind::Tune:
                         case OpCodeKind::Volume:
                             try
@@ -1111,19 +1120,23 @@ private:
             {"ampeg_hold"sv, OpCodeKind::AmpEG_Hold},
             {"ampeg_release"sv, OpCodeKind::AmpEG_Release},
             {"ampeg_sustain"sv, OpCodeKind::AmpEG_Sustain},
+            {"amp_keycenter"sv, OpCodeKind::AmpKeyCenter},
+            {"amp_keytrack"sv, OpCodeKind::AmpKeyTrack},
             {"amp_veltrack"sv, OpCodeKind::AmpVelTrack},
             {"default_path"sv, OpCodeKind::DefaultPath},
             {"hikey"sv, OpCodeKind::HiKey},
             {"hivel"sv, OpCodeKind::HiVelocity},
+            {"key"sv, OpCodeKind::Key},
             {"lokey"sv, OpCodeKind::LoKey},
             {"loop_end"sv, OpCodeKind::LoopEnd},
             {"loop_mode"sv, OpCodeKind::LoopMode},
             {"loop_start"sv, OpCodeKind::LoopStart},
             {"lovel"sv, OpCodeKind::LoVelocity},
             {"offset"sv, OpCodeKind::Offset},
-            {"key"sv, OpCodeKind::Key},
+            {"pan"sv, OpCodeKind::Pan},
             {"pitch_keycenter"sv, OpCodeKind::PitchKeyCenter},
             {"sample"sv, OpCodeKind::Sample},
+            {"transpose"sv, OpCodeKind::Transpose},
             {"trigger"sv, OpCodeKind::Trigger},
             {"tune"sv, OpCodeKind::Tune},
             {"volume"sv, OpCodeKind::Volume}
@@ -1503,6 +1516,7 @@ private:
 
                 case LoopModeKind::LoopContinuous:
                     s.modes |= MODES_LOOPING | MODES_SUSTAIN;
+                    s.data_length = s.loop_end;
                     break;
 
                 case LoopModeKind::LoopSustain:
@@ -1511,40 +1525,45 @@ private:
                 }
 
                 s.volume = std::pow(10.0, flatSection.GetAs<double>(OpCodeKind::Volume).value_or(0.0) / 10.0);
-                s.tune = std::pow(2.0, std::clamp(flatSection.GetAs<double>(OpCodeKind::Tune).value_or(0.0), -100.0, 100.0) / 1200.0);
+                s.tune = std::pow(
+                    2.0,
+                    std::clamp(flatSection.GetAs<double>(OpCodeKind::Transpose).value_or(0.0), -127.0, 127.0) / 12.0
+                        + std::clamp(flatSection.GetAs<double>(OpCodeKind::Tune).value_or(0.0), -100.0, 100.0) / 1200.0
+                );
+
+                s.sample_pan = std::clamp(flatSection.GetAs<double>(OpCodeKind::Pan).value_or(0.0), -100.0, 100.0) / 200.0;
 
-                s.envelope_delay = std::lround(std::clamp(flatSection.GetAs<double>(OpCodeKind::AmpEG_Delay).value_or(0.0), 0.0, 100.0) * ::play_mode->rate);
+                s.envelope_keyf_bpo = static_cast<int8>(std::clamp(flatSection.GetAs<std::int32_t>(OpCodeKind::AmpKeyCenter).value_or(60), -127, 127));
+                s.envelope_velf_bpo = 0;
+                s.modenv_velf_bpo = 0;
+
+                s.envelope_delay = std::lround(std::clamp(flatSection.GetAs<double>(OpCodeKind::AmpEG_Delay).value_or(0.0), 0.0, 100.0) * s.sample_rate);
 
                 TriggerKind trigger = flatSection.GetAs<TriggerKind>(OpCodeKind::Trigger).value_or(TriggerKind::Attack);
 
                 if (trigger == TriggerKind::Release)
                 {
-                    // HACK: don't play the sample if trigger=release
                     // FIXME: modify playmidi.c to implement this correctly
 
-                    auto loc = flatSection.GetLocationForOpCode(OpCodeKind::Trigger);
-                    ctl->cmsg(
-                        CMSG_WARNING,
-                        VERB_VERBOSE,
-                        "%s(%u): 'trigger=release' is not implemented yet",
-                        std::string(m_Parser.GetPreprocessor().GetFileNameFromID(loc.FileID)).c_str(),
-                        loc.Line
-                    );
-
-                    s.envelope_offset[0] = ToOffset(65535);
-                    s.envelope_rate[0] = CalcRate(65535, 0.0);
-                    s.envelope_offset[1] = ToOffset(65534);
+                    s.envelope_offset[0] = ToOffset(3);
+                    s.envelope_rate[0] = CalcRate(1, 0.0);
+                    s.envelope_offset[1] = ToOffset(2);
                     s.envelope_rate[1] = CalcRate(1, 0.0);
+                    s.envelope_offset[2] = ToOffset(1);
+                    s.envelope_rate[2] = CalcRate(1, 0.0);
 
-                    s.envelope_offset[2] = ToOffset(0);
-                    s.envelope_rate[2] = CalcRate(65534, 0.0);
+                    s.envelope_offset[3] = ToOffset(65535);
+                    s.envelope_rate[3] = CalcRate(65535, std::clamp(flatSection.GetAs<double>(OpCodeKind::AmpEG_Attack).value_or(0.0), 0.0, 100.0));
+                    s.envelope_offset[4] = ToOffset(65534);
+                    s.envelope_rate[4] = CalcRate(1, std::clamp(flatSection.GetAs<double>(OpCodeKind::AmpEG_Hold).value_or(0.0), 0.0, 100.0));
 
-                    s.envelope_offset[3] = 0;
-                    s.envelope_rate[3] = CalcRate(0, 0.0);
-                    s.envelope_offset[4] = s.envelope_offset[3];
-                    s.envelope_rate[4] = s.envelope_rate[3];
-                    s.envelope_offset[5] = s.envelope_offset[3];
-                    s.envelope_rate[5] = s.envelope_rate[3];
+                    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);
+                    s.envelope_offset[5] = ToOffset(sustainLevel);
+                    s.envelope_rate[5] = CalcRate(65534 - sustainLevel, std::clamp(flatSection.GetAs<double>(OpCodeKind::AmpEG_Decay).value_or(0.0), 0.0, 100.0));
+
+                    s.modes |= MODES_LOOPING | MODES_SUSTAIN | MODES_RELEASE;
+                    s.loop_start = 0;
+                    s.loop_end = std::clamp<splen_t>(s.loop_start + (1 << FRACTION_BITS), 0, s.data_length);
                 }
                 else
                 {
@@ -1573,17 +1592,22 @@ private:
 
                     double releaseTime = std::clamp(flatSection.GetAs<double>(OpCodeKind::AmpEG_Release).value_or(0.0), 0.0, 100.0);
                     s.envelope_offset[3] = 0;
-                    s.envelope_rate[3] = CalcRate(sustainLevel, releaseTime);
+                    s.envelope_rate[3] = CalcRate(65535, releaseTime);
                     s.envelope_offset[4] = s.envelope_offset[3];
                     s.envelope_rate[4] = s.envelope_rate[3];
                     s.envelope_offset[5] = s.envelope_offset[3];
                     s.envelope_rate[5] = s.envelope_rate[3];
                 }
 
+                if (auto ampKeyTrack = flatSection.GetAs<double>(OpCodeKind::AmpKeyTrack))
+                {
+                    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));
+                }
+
                 if (auto ampVelTrack = flatSection.GetAs<double>(OpCodeKind::AmpVelTrack))
                 {
                     // convert percent to rate
-                    std::fill(std::begin(s.envelope_velf), std::end(s.envelope_velf), std::clamp(ampVelTrack.value() * 0.01, -1.0, 1.0));
+                    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);
                 }
             }
 
@@ -1623,11 +1647,11 @@ private:
             switch (i.Header)
             {
             case HeaderKind::Control:
-                controlOpCodes.insert(controlOpCodes.end(), i.OpCodes.begin(), i.OpCodes.end());
+                controlOpCodes = i.OpCodes;
                 break;
 
             case HeaderKind::Global:
-                globalOpCodes.insert(globalOpCodes.end(), i.OpCodes.begin(), i.OpCodes.end());
+                globalOpCodes = i.OpCodes;
                 break;
 
             case HeaderKind::Group:
@@ -1686,12 +1710,10 @@ private:
 
 struct InstrumentCacheEntry
 {
-    InstrumentCacheEntry(std::string_view filePath, std::unique_ptr<Instrument, InstrumentDeleter> pInstrument)
-        : FilePath(filePath), pInstrument(std::move(pInstrument))
+    InstrumentCacheEntry(std::unique_ptr<Instrument, InstrumentDeleter> pInstrument) : pInstrument(std::move(pInstrument))
     {
     }
 
-    std::string FilePath;
     std::unique_ptr<Instrument, InstrumentDeleter> pInstrument;
     std::vector<Instrument*> RefInstruments;
 };
@@ -1701,14 +1723,7 @@ class InstrumentCache
 public:
     Instrument* LoadSFZ(std::string filePath)
     {
-        auto it = std::find_if(
-            m_Instruments.begin(),
-            m_Instruments.end(),
-            [&filePath] (auto&& x)
-            {
-                return x.FilePath == filePath;
-            }
-        );
+        auto it = m_Instruments.find(filePath);
 
         if (it == m_Instruments.end())
         {
@@ -1719,7 +1734,7 @@ public:
                 TimSFZ::Parser parser(pp);
                 parser.Parse();
                 TimSFZ::InstrumentBuilder builder(parser, filePath);
-                m_Instruments.emplace_back(filePath, builder.BuildInstrument());
+                it = m_Instruments.emplace(filePath, builder.BuildInstrument()).first;
             }
             catch (const std::exception& e)
             {
@@ -1732,12 +1747,12 @@ public:
         }
 
         std::unique_ptr<Instrument, InstrumentDeleter> pInstRef(reinterpret_cast<Instrument*>(safe_calloc(sizeof(Instrument), 1)));
-        it->RefInstruments.push_back(pInstRef.get());
-        pInstRef->type = it->pInstrument->type;
-        pInstRef->instname = safe_strdup(it->pInstrument->instname);
-        pInstRef->samples = it->pInstrument->samples;
-        pInstRef->sample = reinterpret_cast<Sample*>(safe_calloc(sizeof(Sample), it->pInstrument->samples));
-        std::copy_n(it->pInstrument->sample, it->pInstrument->samples, pInstRef->sample);
+        it->second.RefInstruments.push_back(pInstRef.get());
+        pInstRef->type = it->second.pInstrument->type;
+        pInstRef->instname = safe_strdup(it->second.pInstrument->instname);
+        pInstRef->samples = it->second.pInstrument->samples;
+        pInstRef->sample = reinterpret_cast<Sample*>(safe_calloc(sizeof(Sample), it->second.pInstrument->samples));
+        std::copy_n(it->second.pInstrument->sample, it->second.pInstrument->samples, pInstRef->sample);
         std::for_each(pInstRef->sample, pInstRef->sample + pInstRef->samples, [] (auto&& x) { x.data_alloced = false; });
 
         return pInstRef.release();
@@ -1753,16 +1768,16 @@ public:
             m_Instruments.end(),
             [pInstrument] (auto&& x)
             {
-                auto it = std::find(x.RefInstruments.begin(), x.RefInstruments.end(), pInstrument);
-                return it != x.RefInstruments.end();
+                auto it = std::find(x.second.RefInstruments.begin(), x.second.RefInstruments.end(), pInstrument);
+                return it != x.second.RefInstruments.end();
             }
         );
 
         if (it != m_Instruments.end())
         {
-            it->RefInstruments.erase(std::find(it->RefInstruments.begin(), it->RefInstruments.end(), pInstrument));
+            it->second.RefInstruments.erase(std::find(it->second.RefInstruments.begin(), it->second.RefInstruments.end(), pInstrument));
 
-            if (it->RefInstruments.empty())
+            if (it->second.RefInstruments.empty())
             {
                 m_Instruments.erase(it);
             }
@@ -1775,7 +1790,7 @@ public:
     }
 
 private:
-    std::vector<InstrumentCacheEntry> m_Instruments;
+    std::unordered_map<std::string, InstrumentCacheEntry> m_Instruments;
 };
 
 InstrumentCache GlobalInstrumentCache;
index 5c2a88c..08291de 100644 (file)
@@ -470,13 +470,17 @@ static void init_sf(SFInsts *rec)
                int bank = sfinfo.preset[i].bank;
                int preset = sfinfo.preset[i].preset;
 
-               if (bank == 128)
+               if (bank == 128 && 0 <= preset && preset < 128 + MAP_BANK_COUNT)
                    /* FIXME: why not allow exclusion of drumsets? */
                    alloc_instrument_bank(1, preset);
-               else {
+               else if (0 <= bank && bank < 128 + MAP_BANK_COUNT) {
                        if (is_excluded(rec, bank, preset, -1))
                                continue;
                        alloc_instrument_bank(0, bank);
+               } else {
+                       ctl->cmsg(CMSG_ERROR, VERB_VERBOSE, "%s: bank/preset is out of range [bank = %d, preset = %d]",
+                               FILENAME_REDUCED(rec->fname), bank, preset);
+                       continue;
                }
                load_font(&sfinfo, i);
        }
index 9bd59d8..ba20fea 100644 (file)
@@ -429,7 +429,6 @@ void mix_voice_thread(DATA_T *buf, int v, int32 c, int thread)
                recompute_resample_filter(v);
        }
        apply_envelope_to_amp(v);
-#ifdef INT_SYNTH
        switch(vp->sample->inst_type){
        case INST_GUS:
        case INST_SF2:
@@ -451,24 +450,15 @@ void mix_voice_thread(DATA_T *buf, int v, int32 c, int thread)
                        resample_filter(v, sp, c);
                }
                break;
+#ifdef INT_SYNTH
        case INST_MMS:
                compute_voice_mms_thread(v, sp, c, thread);
                break;
        case INST_SCC:
                compute_voice_scc_thread(v, sp, c, thread);
                break;
-       }
-#else
-       if(opt_resample_over_sampling){
-               int32 c2 = c * opt_resample_over_sampling;
-               resample_voice(v, sp, c2);
-               resample_filter(v, sp, c2);
-               resample_down_sampling(sp, c);
-       }else{
-               resample_voice(v, sp, c);
-               resample_filter(v, sp, c);
-       }
 #endif
+       }
 #ifdef VOICE_EFFECT
        voice_effect(v, sp, c);
 #endif
index fb4c244..1e13f77 100644 (file)
@@ -5776,7 +5776,7 @@ static int parse_opt_h(const char *arg)
 #endif
 {
        static char *help_list[] = {
-"TiMidity++ %s (C) 1999-2004 Masanao Izumo <iz@onicos.co.jp>",
+"TiMidity++ %s (C) 1999-2018 Masanao Izumo <iz@onicos.co.jp>",
 "The original version (C) 1995 Tuukka Toivonen <tt@cgs.fi>",
 "TiMidity is free software and comes with ABSOLUTELY NO WARRANTY.",
 "",
@@ -6258,64 +6258,64 @@ static int parse_opt_h(const char *arg)
                                fprintf(fp, "%s", h);
                } else
                        fputs(h, fp);
-               fputs(NLS, fp);
-       }
-       fputs(NLS, fp);
-       fputs("Effect options (-EF, --ext=F option):" NLS
-"  -EFdelay=d   Disable delay effect (default)" NLS
-"  -EFdelay=D   Enable delay effect" NLS
-"  -EFchorus=d  Disable MIDI chorus effect control" NLS
-"  -EFchorus=n  Enable Normal MIDI chorus effect control" NLS
-"    [,level]     `level' is optional to specify chorus level [0..127]" NLS
-"                 (default)" NLS
-"  -EFchorus=s  Surround sound, chorus detuned to a lesser degree" NLS
-"    [,level]     `level' is optional to specify chorus level [0..127]" NLS
-"  -EFreverb=d  Disable MIDI reverb effect control" NLS
+               fputs("\n", fp);
+       }
+       fputs("\n", fp);
+       fputs("Effect options (-EF, --ext=F option):" "\n"
+"  -EFdelay=d   Disable delay effect (default)" "\n"
+"  -EFdelay=D   Enable delay effect" "\n"
+"  -EFchorus=d  Disable MIDI chorus effect control" "\n"
+"  -EFchorus=n  Enable Normal MIDI chorus effect control" "\n"
+"    [,level]     `level' is optional to specify chorus level [0..127]" "\n"
+"                 (default)" "\n"
+"  -EFchorus=s  Surround sound, chorus detuned to a lesser degree" "\n"
+"    [,level]     `level' is optional to specify chorus level [0..127]" "\n"
+"  -EFreverb=d  Disable MIDI reverb effect control" "\n"
 #if !defined(REVERB_CONTROL_ALLOW) && !defined(FREEVERB_CONTROL_ALLOW)
-"                 (default)" NLS
+"                 (default)" "\n"
 #endif
-"  -EFreverb=n  Enable Normal MIDI reverb effect control" NLS
-"    [,level]     `level' is optional to specify reverb level [1..127]" NLS
+"  -EFreverb=n  Enable Normal MIDI reverb effect control" "\n"
+"    [,level]     `level' is optional to specify reverb level [1..127]" "\n"
 #if defined(REVERB_CONTROL_ALLOW)
-"                 (default)" NLS
+"                 (default)" "\n"
 #endif
-"  -EFreverb=g  Global reverb effect" NLS
-"    [,level]     `level' is optional to specify reverb level [1..127]" NLS
-"  -EFreverb=f  Enable Freeverb MIDI reverb effect control" NLS
-"    [,level]     `level' is optional to specify reverb level [1..127]" NLS
+"  -EFreverb=g  Global reverb effect" "\n"
+"    [,level]     `level' is optional to specify reverb level [1..127]" "\n"
+"  -EFreverb=f  Enable Freeverb MIDI reverb effect control" "\n"
+"    [,level]     `level' is optional to specify reverb level [1..127]" "\n"
 #if !defined(REVERB_CONTROL_ALLOW) && defined(FREEVERB_CONTROL_ALLOW)
-"                 (default)" NLS
+"                 (default)" "\n"
 #endif
-"  -EFreverb=G  Global Freeverb effect" NLS
-"    [,level]     `level' is optional to specify reverb level [1..127]" NLS
-"  -EFvlpf=d    Disable voice LPF" NLS
+"  -EFreverb=G  Global Freeverb effect" "\n"
+"    [,level]     `level' is optional to specify reverb level [1..127]" "\n"
+"  -EFvlpf=d    Disable voice LPF" "\n"
 #if !defined(VOICE_MOOG_LPF_ALLOW) && !defined(VOICE_CHAMBERLIN_LPF_ALLOW)
-"                 (default)" NLS
+"                 (default)" "\n"
 #endif
-"  -EFvlpf=c    Enable Chamberlin resonant LPF (12dB/oct)" NLS
+"  -EFvlpf=c    Enable Chamberlin resonant LPF (12dB/oct)" "\n"
 #if defined(VOICE_CHAMBERLIN_LPF_ALLOW)
-"                 (default)" NLS
+"                 (default)" "\n"
 #endif
-"  -EFvlpf=m    Enable Moog resonant lowpass VCF (24dB/oct)" NLS
+"  -EFvlpf=m    Enable Moog resonant lowpass VCF (24dB/oct)" "\n"
 #if defined(VOICE_MOOG_LPF_ALLOW) && !defined(VOICE_CHAMBERLIN_LPF_ALLOW)
-"                 (default)" NLS
-#endif
-"  -EFvlpf=b    Enable ButterworthFilter resonant lowpass (butterworth)" NLS
-"  -EFvlpf=i    Enable Resonant IIR lowpass VCF (12dB/oct)-2" NLS
-"  -EFvlpf=a    Enable amSynth resonant lowpass VCF (24dB/oct)-2" NLS
-"  -EFvlpf=o    Enable 1 pole 6db/oct resonant lowpass VCF (6dB/oct)" NLS
-"  -EFvlpf=e    Enable resonant 3 pole lowpass VCF (18dB/oct)" NLS
-"  -EFvlpf=t    Enable two first order lowpass VCF " NLS
-"  -EFvlpf=h    Enable HPF ButterworthFilter VCF (butterworth)" NLS
-"  -EFvlpf=B    Enable BPF ButterworthFilter VCF (butterworth)" NLS
-"  -EFns=n      Enable the n'th degree (type) noise shaping filter" NLS
-"                 n:[0..4] (for 8-bit linear encoding, default is 4)" NLS
-"                 n:[0..4] (for 16-bit linear encoding, default is 4)" NLS
-"                 n:[0] (for 24-bit linear encoding, default is 0)" NLS
-"                 n:[0] (for 32-bit linear encoding, default is 0)" NLS
-"                 n:[0] (for 64-bit linear encoding, default is 0)" NLS
-"                 n:[0] (for float 32-bit linear encoding, default is 0)" NLS
-"                 n:[0] (for float 64-bit linear encoding, default is 0)" NLS, fp);
+"                 (default)" "\n"
+#endif
+"  -EFvlpf=b    Enable ButterworthFilter resonant lowpass (butterworth)" "\n"
+"  -EFvlpf=i    Enable Resonant IIR lowpass VCF (12dB/oct)-2" "\n"
+"  -EFvlpf=a    Enable amSynth resonant lowpass VCF (24dB/oct)-2" "\n"
+"  -EFvlpf=o    Enable 1 pole 6db/oct resonant lowpass VCF (6dB/oct)" "\n"
+"  -EFvlpf=e    Enable resonant 3 pole lowpass VCF (18dB/oct)" "\n"
+"  -EFvlpf=t    Enable two first order lowpass VCF " "\n"
+"  -EFvlpf=h    Enable HPF ButterworthFilter VCF (butterworth)" "\n"
+"  -EFvlpf=B    Enable BPF ButterworthFilter VCF (butterworth)" "\n"
+"  -EFns=n      Enable the n'th degree (type) noise shaping filter" "\n"
+"                 n:[0..4] (for 8-bit linear encoding, default is 4)" "\n"
+"                 n:[0..4] (for 16-bit linear encoding, default is 4)" "\n"
+"                 n:[0] (for 24-bit linear encoding, default is 0)" "\n"
+"                 n:[0] (for 32-bit linear encoding, default is 0)" "\n"
+"                 n:[0] (for 64-bit linear encoding, default is 0)" "\n"
+"                 n:[0] (for float 32-bit linear encoding, default is 0)" "\n"
+"                 n:[0] (for float 64-bit linear encoding, default is 0)" "\n", fp);
 #ifndef FIXED_RESAMPLATION
 #ifdef HAVE_STRINGIZE
 #define tim_str_internal(x) #x
@@ -6326,147 +6326,147 @@ static int parse_opt_h(const char *arg)
        fputs("  -EFresamp=d  Disable resamplation", fp);
        if (! strcmp(tim_str(DEFAULT_RESAMPLATION), "resample_none"))
                fputs(" (default)", fp);
-       fputs(NLS, fp);
+       fputs("\n", fp);
        fputs("  -EFresamp=l  Enable Linear resample algorithm", fp);
        if (! strcmp(tim_str(DEFAULT_RESAMPLATION), "resample_linear"))
                fputs(" (default)", fp);
-       fputs(NLS, fp);
+       fputs("\n", fp);
        fputs("  -EFresamp=c  Enable C-spline resample algorithm", fp);
        if (! strcmp(tim_str(DEFAULT_RESAMPLATION), "resample_cspline"))
                fputs(" (default)", fp);
-       fputs(NLS, fp);
+       fputs("\n", fp);
        fputs("  -EFresamp=L  Enable Lagrange resample algorithm", fp);
        if (! strcmp(tim_str(DEFAULT_RESAMPLATION), "resample_lagrange"))
                fputs(" (default)", fp);
-       fputs(NLS, fp);
+       fputs("\n", fp);
        fputs("  -EFresamp=n  Enable Newton resample algorithm", fp);
        if (! strcmp(tim_str(DEFAULT_RESAMPLATION), "resample_newton"))
                fputs(" (default)", fp);
-       fputs(NLS, fp);
+       fputs("\n", fp);
        fputs("  -EFresamp=g  Enable Gauss-like resample algorithm", fp);
        if (! strcmp(tim_str(DEFAULT_RESAMPLATION), "resample_gauss"))
                fputs(" (default)", fp);
 ///r
-       fputs(NLS, fp);
+       fputs("\n", fp);
        fputs("  -EFresamp=s  Enable Sharp resample algorithm", fp);
        if (! strcmp(tim_str(DEFAULT_RESAMPLATION), "resample_sharp"))
                fputs(" (default)", fp);
-       fputs(NLS, fp);
+       fputs("\n", fp);
        fputs("  -EFresamp=p  Enable LinearP resample algorithm", fp);
        if (! strcmp(tim_str(DEFAULT_RESAMPLATION), "resample_linear_p"))
                fputs(" (default)", fp);
-       fputs(NLS
-"                 -EFresamp affects the behavior of -N option" NLS, fp);
-#endif
-       fputs(NLS, fp);
-       fputs("Alternative TiMidity sequencer extensional mode long options:" NLS
-"  --[no-]mod-wheel" NLS
-"  --[no-]portamento" NLS
-"  --[no-]vibrato" NLS
-"  --[no-]ch-pressure" NLS
-"  --[no-]mod-envelope" NLS
-"  --[no-]trace-text-meta" NLS
-"  --[no-]overlap-voice" NLS
+       fputs("\n"
+"                 -EFresamp affects the behavior of -N option" "\n", fp);
+#endif
+       fputs("\n", fp);
+       fputs("Alternative TiMidity sequencer extensional mode long options:" "\n"
+"  --[no-]mod-wheel" "\n"
+"  --[no-]portamento" "\n"
+"  --[no-]vibrato" "\n"
+"  --[no-]ch-pressure" "\n"
+"  --[no-]mod-envelope" "\n"
+"  --[no-]trace-text-meta" "\n"
+"  --[no-]overlap-voice" "\n"
 ///r
-"  --overlap-voice-count=n" NLS
-"  --[no-]temper-control" NLS
-"  --default-mid=<HH>" NLS
-"  --system-mid=<HH>" NLS
-"  --default-bank=n" NLS
-"  --force-bank=n" NLS
-"  --default-program=n/m" NLS
-"  --force-program=n/m" NLS
-"  --delay=(d|D)" NLS
-"  --chorus=(d|n|s|w|W|b|B|t|T|h|H|e|E)[,level]" NLS
-"  --reverb=(d|n|g|f|G)[,level]" NLS
-"  --reverb=(f|G)[,level[,scaleroom[,offsetroom[,predelay]]]]" NLS
-"  --voice-lpf=(d|c|m|b|i|a|o|e|t|h|B)" NLS
-"  --noise-shaping=n" NLS, fp);
+"  --overlap-voice-count=n" "\n"
+"  --[no-]temper-control" "\n"
+"  --default-mid=<HH>" "\n"
+"  --system-mid=<HH>" "\n"
+"  --default-bank=n" "\n"
+"  --force-bank=n" "\n"
+"  --default-program=n/m" "\n"
+"  --force-program=n/m" "\n"
+"  --delay=(d|D)" "\n"
+"  --chorus=(d|n|s|w|W|b|B|t|T|h|H|e|E)[,level]" "\n"
+"  --reverb=(d|n|g|f|G)[,level]" "\n"
+"  --reverb=(f|G)[,level[,scaleroom[,offsetroom[,predelay]]]]" "\n"
+"  --voice-lpf=(d|c|m|b|i|a|o|e|t|h|B)" "\n"
+"  --noise-shaping=n" "\n", fp);
 #ifndef FIXED_RESAMPLATION
-       fputs("  --resample=(d|l|c|L|n|g|s|p)" NLS, fp);
+       fputs("  --resample=(d|l|c|L|n|g|s|p)" "\n", fp);
 #endif
-       fputs(NLS, fp);
-       fputs("Available interfaces (-i, --interface option):" NLS, fp);
+       fputs("\n", fp);
+       fputs("Available interfaces (-i, --interface option):" "\n", fp);
        for (cmpp = ctl_list; (cmp = *cmpp) != NULL; cmpp++)
-               fprintf(fp, "  -i%c          %s" NLS,
+               fprintf(fp, "  -i%c          %s" "\n",
                                cmp->id_character, cmp->id_name);
 #ifdef IA_DYNAMIC
-       fprintf(fp, "Supported dynamic load interfaces (%s):" NLS,
+       fprintf(fp, "Supported dynamic load interfaces (%s):" "\n",
                        dynamic_lib_root);
        memset(mark, 0, sizeof(mark));
        for (cmpp = ctl_list; (cmp = *cmpp) != NULL; cmpp++)
                mark[(int) cmp->id_character] = 1;
        list_dyna_interface(fp, dynamic_lib_root, mark);
 #endif /* IA_DYNAMIC */
-       fputs(NLS, fp);
-       fputs("Interface options (append to -i? option):" NLS
-"  `v'          more verbose (cumulative)" NLS
-"  `q'          quieter (cumulative)" NLS
-"  `t'          trace playing" NLS
-"  `l'          loop playing (some interface ignore this option)" NLS
-"  `r'          randomize file list arguments before playing" NLS
-"  `s'          sorting file list arguments before playing" NLS, fp);
+       fputs("\n", fp);
+       fputs("Interface options (append to -i? option):" "\n"
+"  `v'          more verbose (cumulative)" "\n"
+"  `q'          quieter (cumulative)" "\n"
+"  `t'          trace playing" "\n"
+"  `l'          loop playing (some interface ignore this option)" "\n"
+"  `r'          randomize file list arguments before playing" "\n"
+"  `s'          sorting file list arguments before playing" "\n", fp);
 #ifdef IA_ALSASEQ
        fputs("  `D'          daemonize TiMidity++ in background "
-                       "(for alsaseq only)" NLS, fp);
-#endif
-       fputs(NLS, fp);
-       fputs("Alternative interface long options:" NLS
-"  --verbose=n" NLS
-"  --quiet=n" NLS
-"  --[no-]trace" NLS
-"  --[no-]loop" NLS
-"  --[no-]random" NLS
-"  --[no-]sort" NLS, fp);
+                       "(for alsaseq only)" "\n", fp);
+#endif
+       fputs("\n", fp);
+       fputs("Alternative interface long options:" "\n"
+"  --verbose=n" "\n"
+"  --quiet=n" "\n"
+"  --[no-]trace" "\n"
+"  --[no-]loop" "\n"
+"  --[no-]random" "\n"
+"  --[no-]sort" "\n", fp);
 #ifdef IA_ALSASEQ
-       fputs("  --[no-]background" NLS, fp);
+       fputs("  --[no-]background" "\n", fp);
 #endif
-       fputs(NLS, fp);
-       fputs("Available output modes (-O, --output-mode option):" NLS, fp);
+       fputs("\n", fp);
+       fputs("Available output modes (-O, --output-mode option):" "\n", fp);
        for (pmpp = play_mode_list; (pmp = *pmpp) != NULL; pmpp++)
-               fprintf(fp, "  -O%c          %s" NLS,
+               fprintf(fp, "  -O%c          %s" "\n",
                                pmp->id_character, pmp->id_name);
-       fputs(NLS, fp);
-       fputs("Output format options (append to -O? option):" NLS
-"  `S'          stereo" NLS
-"  `M'          monophonic" NLS
-"  `s'          signed output" NLS
-"  `u'          unsigned output" NLS
-"  `1'          16-bit sample width" NLS
-"  `2'          24-bit sample width" NLS
-"  `3'          32-bit sample width" NLS
-"  `6'          64-bit sample width" NLS
-"  `8'          8-bit sample width" NLS
-"  `f'          float 32-bit sample width" NLS
-"  `D'          float 64-bit sample width" NLS
-"  `l'          linear encoding" NLS
-"  `U'          U-Law encoding" NLS
-"  `A'          A-Law encoding" NLS
-"  `x'          byte-swapped output" NLS, fp);
-       fputs(NLS, fp);
-       fputs("Alternative output format long options:" NLS
-"  --output-stereo" NLS
-"  --output-mono" NLS
-"  --output-signed" NLS
-"  --output-unsigned" NLS
-"  --output-16bit" NLS
-"  --output-24bit" NLS
-"  --output-32bit" NLS
-"  --output-64bit" NLS
-"  --output-8bit" NLS
-"  --output-f32bit" NLS
-"  --output-float32bit" NLS
-"  --output-f64bit" NLS
-"  --output-float64bit" NLS
-"  --output-linear" NLS
-"  --output-ulaw" NLS
-"  --output-alaw" NLS
-"  --[no-]output-swab" NLS, fp);
-       fputs(NLS, fp);
-       fputs("Available WRD interfaces (-W, --wrd option):" NLS, fp);
+       fputs("\n", fp);
+       fputs("Output format options (append to -O? option):" "\n"
+"  `S'          stereo" "\n"
+"  `M'          monophonic" "\n"
+"  `s'          signed output" "\n"
+"  `u'          unsigned output" "\n"
+"  `1'          16-bit sample width" "\n"
+"  `2'          24-bit sample width" "\n"
+"  `3'          32-bit sample width" "\n"
+"  `6'          64-bit sample width" "\n"
+"  `8'          8-bit sample width" "\n"
+"  `f'          float 32-bit sample width" "\n"
+"  `D'          float 64-bit sample width" "\n"
+"  `l'          linear encoding" "\n"
+"  `U'          U-Law encoding" "\n"
+"  `A'          A-Law encoding" "\n"
+"  `x'          byte-swapped output" "\n", fp);
+       fputs("\n", fp);
+       fputs("Alternative output format long options:" "\n"
+"  --output-stereo" "\n"
+"  --output-mono" "\n"
+"  --output-signed" "\n"
+"  --output-unsigned" "\n"
+"  --output-16bit" "\n"
+"  --output-24bit" "\n"
+"  --output-32bit" "\n"
+"  --output-64bit" "\n"
+"  --output-8bit" "\n"
+"  --output-f32bit" "\n"
+"  --output-float32bit" "\n"
+"  --output-f64bit" "\n"
+"  --output-float64bit" "\n"
+"  --output-linear" "\n"
+"  --output-ulaw" "\n"
+"  --output-alaw" "\n"
+"  --[no-]output-swab" "\n", fp);
+       fputs("\n", fp);
+       fputs("Available WRD interfaces (-W, --wrd option):" "\n", fp);
        for (wlpp = wrdt_list; (wlp = *wlpp) != NULL; wlpp++)
-               fprintf(fp, "  -W%c          %s" NLS, wlp->id, wlp->name);
-       fputs(NLS, fp);
+               fprintf(fp, "  -W%c          %s" "\n", wlp->id, wlp->name);
+       fputs("\n", fp);
        close_pager(fp);
        exit(EXIT_SUCCESS);
        return 0; // dummy call