Diff for /np2/sound/vermouth/midimod.c between versions 1.4 and 1.13

version 1.4, 2003/12/08 00:55:34 version 1.13, 2011/02/04 00:39:34
Line 1 Line 1
 #include        "compiler.h"  #include        "compiler.h"
 #include        "strres.h"  #include        "strres.h"
 #include        "dosio.h"  #include        "dosio.h"
 #include        "textfile.h"  #include        "textfile.h"
 #include        "midiout.h"  #include        "midiout.h"
   #if defined(SUPPORT_ARC)
   #include        "arc.h"
 #define CFG_MAXAMP              400  #endif
 #define MAX_NAME                64  
   
 enum {  #define CFG_MAXAMP              400
         CFG_DIR          = 0,  #define MAX_NAME                64
         CFG_SOURCE,  
         CFG_DEFAULT,  enum {
         CFG_BANK,          CFG_DIR          = 0,
         CFG_DRUM          CFG_SOURCE,
 };          CFG_DEFAULT,
           CFG_BANK,
 static const char str_dir[] = "dir";          CFG_DRUM
 static const char str_source[] = "source";  };
 static const char str_default[] = "default";  
 static const char str_bank[] = "bank";  static const OEMCHAR str_dir[] = OEMTEXT("dir");
 static const char str_drumset[] = "drumset";  static const OEMCHAR str_source[] = OEMTEXT("source");
 static const char *cfgstr[] = {str_dir, str_source, str_default,  static const OEMCHAR str_default[] = OEMTEXT("default");
                                                                 str_bank, str_drumset};  static const OEMCHAR str_bank[] = OEMTEXT("bank");
   static const OEMCHAR str_drumset[] = OEMTEXT("drumset");
 static const char str_amp[] = "amp";  static const OEMCHAR *cfgstr[] = {str_dir, str_source, str_default,
 static const char str_keep[] = "keep";                                                                  str_bank, str_drumset};
 static const char str_note[] = "note";  
 static const char str_pan[] = "pan";  static const OEMCHAR str_amp[] = OEMTEXT("amp");
 static const char str_strip[] = "strip";  static const OEMCHAR str_keep[] = OEMTEXT("keep");
 static const char str_left[] = "left";  static const OEMCHAR str_note[] = OEMTEXT("note");
 static const char str_center[] = "center";  static const OEMCHAR str_pan[] = OEMTEXT("pan");
 static const char str_right[] = "right";  static const OEMCHAR str_strip[] = OEMTEXT("strip");
 static const char str_env[] = "env";  static const OEMCHAR str_left[] = OEMTEXT("left");
 static const char str_loop[] = "loop";  static const OEMCHAR str_center[] = OEMTEXT("center");
 static const char str_tail[] = "tail";  static const OEMCHAR str_right[] = OEMTEXT("right");
 static const char file_timiditycfg[] = "timidity.cfg";  static const OEMCHAR str_env[] = OEMTEXT("env");
   static const OEMCHAR str_loop[] = OEMTEXT("loop");
   static const OEMCHAR str_tail[] = OEMTEXT("tail");
 static void pathadd(MIDIMOD mod, const char *path) {  static const OEMCHAR file_timiditycfg[] = OEMTEXT("timidity.cfg");
   static const OEMCHAR str_basedir[] = OEMTEXT("${basedir}");
         _PATHLIST       pl;  
         PATHLIST        p;  
   static void VERMOUTHCL pathadd(MIDIMOD mod, const OEMCHAR *path) {
         ZeroMemory(&pl, sizeof(pl));  
         if (path) {          _PATHLIST       pl;
                 pl.path[0] = '\0';          PATHLIST        p;
                 file_catname(pl.path, path, sizeof(pl.path));   // separator change!  
                 if (path[0]) {          ZeroMemory(&pl, sizeof(pl));
                         file_setseparator(pl.path, sizeof(pl.path));          if (path) {
                 }                  pl.path[0] = '\0';
         }                  // separator change!
                   file_catname(pl.path, path, NELEMENTS(pl.path));
         pl.next = mod->pathlist;                  if (path[0]) {
         p = pl.next;  #if defined(SUPPORT_ARC)
         while(p) {                          if (milstr_chr(pl.path, '#') == NULL)
                 if (!strcmp(p->path, pl.path)) {  #endif
                         return;                                  file_setseparator(pl.path, NELEMENTS(pl.path));
                 }                  }
                 p = p->next;          }
         }  
         p = (PATHLIST)listarray_append(mod->pathtbl, &pl);          pl.next = mod->pathlist;
         if (p) {          p = pl.next;
                 mod->pathlist = p;          while(p) {
         }                  if (!file_cmpname(p->path, pl.path)) {
 }                          return;
                   }
 static int cfggetarg(char *str, char *arg[], int maxarg) {                  p = p->next;
           }
         int             ret;          p = (PATHLIST)listarray_append(mod->pathtbl, &pl);
         BOOL    quot;          if (p) {
         char    *p;                  mod->pathlist = p;
         BYTE    c;          }
   }
         ret = 0;  
         while(maxarg--) {  static void VERMOUTHCL pathaddex(MIDIMOD mod, const OEMCHAR *path) {
                 quot = FALSE;  
                 while(1) {          OEMCHAR _path[MAX_PATH];
                         c = *str;  
                         if ((c == 0) || (c == 0x23)) {          if (milstr_memcmp(path, str_basedir)) {
                                 goto cga_done;                  pathadd(mod, path);
                         }          }
                         if (c > 0x20) {          else {
                                 break;                  file_cpyname(_path, file_getcd(str_null), NELEMENTS(_path));
                         }                  file_cutseparator(_path);
                         str++;                  file_catname(_path, path + 10, NELEMENTS(_path));
                 }                  pathadd(mod, _path);
                 arg[ret++] = str;          }
                 p = str;  }
                 while(1) {  
                         c = *str;  static int VERMOUTHCL cfggetarg(OEMCHAR *str, OEMCHAR *arg[], int maxarg) {
                         if (c == 0) {  
                                 break;          int             ret;
                         }          BOOL    quot;
                         str++;          OEMCHAR *p;
                         if (c == 0x22) {          OEMCHAR c;
                                 quot = !quot;  
                         }          ret = 0;
                         else if (quot) {          while(maxarg--) {
                                 *p++ = c;                  quot = FALSE;
                         }                  while(1) {
                         else if (c == 0x23) {                          c = *str;
                                 *p = '\0';                          if ((c == 0) || (c == 0x23)) {
                                 goto cga_done;                                  goto cga_done;
                         }                          }
                         else if (c > 0x20) {                          if ((c < 0) || (c > 0x20)) {
                                 *p++ = c;                                  break;
                         }                          }
                         else {                          str++;
                                 break;                  }
                         }                  arg[ret++] = str;
                 }                  p = str;
                 *p = '\0';                  while(1) {
         }                          c = *str;
                           if (c == 0) {
 cga_done:                                  break;
         return(ret);                          }
 }                          str++;
                           if (c == 0x22) {
 static char *seachr(char *str, char sepa) {                                  quot = !quot;
                           }
         char    c;                          else if (quot) {
                                   *p++ = c;
         while(1) {                          }
                 c = *str;                          else if (c == 0x23) {
                 if (c == '\0') {                                  *p = '\0';
                         break;                                  goto cga_done;
                 }                          }
                 if (c == sepa) {                          else if ((c < 0) || (c > 0x20)) {
                         return(str);                                  *p++ = c;
                 }                          }
                 str++;                          else {
         }                                  break;
         return(NULL);                          }
 }                  }
                   *p = '\0';
 enum {          }
         VAL_EXIST       = 1,  
         VAL_SIGN        = 2  cga_done:
 };          return(ret);
   }
 static BOOL cfggetval(const char *str, int *val) {  
   static OEMCHAR *VERMOUTHCL seachr(const OEMCHAR *str, OEMCHAR sepa) {
         int             ret;  
         int             flag;          OEMCHAR c;
         int             c;  
           while(1) {
         ret = 0;                  c = *str;
         flag = 0;                  if (c == '\0') {
         c = *str;                          break;
         if (c == '+') {                  }
                 str++;                  if (c == sepa) {
         }                          return((OEMCHAR *)str);
         else if (c == '-') {                  }
                 str++;                  str++;
                 flag |= VAL_SIGN;          }
         }          return(NULL);
         while(1) {  }
                 c = *str++;  
                 c -= '0';  enum {
                 if ((unsigned)c < 10) {          VAL_EXIST       = 1,
                         ret *= 10;          VAL_SIGN        = 2
                         ret += c;  };
                         flag |= VAL_EXIST;  
                 }  static BRESULT VERMOUTHCL cfggetval(const OEMCHAR *str, int *val) {
                 else {  
                         break;          int             ret;
                 }          int             flag;
         }          int             c;
         if (flag & VAL_EXIST) {  
                 if (flag & VAL_SIGN) {          ret = 0;
                         ret *= -1;          flag = 0;
                 }          c = *str;
                 if (val) {          if (c == '+') {
                         *val = ret;                  str++;
                 }          }
                 return(SUCCESS);          else if (c == '-') {
         }                  str++;
         else {                  flag |= VAL_SIGN;
                 return(FAILURE);          }
         }          while(1) {
 }                  c = *str++;
                   c -= '0';
                   if ((unsigned)c < 10) {
 // ----                          ret *= 10;
                           ret += c;
 static void settone(MIDIMOD mod, int bank, int argc, char *argv[]) {                          flag |= VAL_EXIST;
                   }
         int             val;                  else {
         TONECFG tone;                          break;
         char    *name;                  }
         int             i;          }
         char    *key;          if (flag & VAL_EXIST) {
         char    *data;                  if (flag & VAL_SIGN) {
         BYTE    flag;                          ret *= -1;
                   }
         if ((bank < 0) || (bank >= (MIDI_BANKS * 2)) || (argc < 2) ||                  if (val) {
                 (cfggetval(argv[0], &val) != SUCCESS) || (val < 0) || (val >= 128)) {                          *val = ret;
                 return;                  }
         }                  return(SUCCESS);
         tone = mod->tonecfg[bank];          }
         if (tone == NULL) {          else {
                 tone = (TONECFG)_MALLOC(sizeof(_TONECFG) * 128, "tone cfg");                  return(FAILURE);
                 if (tone == NULL) {          }
                         return;  }
                 }  
                 mod->tonecfg[bank] = tone;  
                 ZeroMemory(tone, sizeof(_TONECFG) * 128);  // ----
         }  
         tone += val;  static void VERMOUTHCL settone(MIDIMOD mod, int bank, int argc,
         name = tone->name;                                                                                                                          OEMCHAR *argv[]) {
         if (name == NULL) {  
                 name = (char *)listarray_append(mod->namelist, NULL);          int             val;
                 tone->name = name;          TONECFG tone;
         }          OEMCHAR *name;
         if (name) {          int             i;
                 name[0] = '\0';          OEMCHAR *key;
                 file_catname(name, argv[1], MAX_NAME);          // separator change!          OEMCHAR *data;
         }          UINT8   flag;
         flag = TONECFG_EXIST;  
         tone->amp = TONECFG_AUTOAMP;          if ((bank < 0) || (bank >= (MIDI_BANKS * 2)) || (argc < 2) ||
         tone->pan = TONECFG_VARIABLE;                  (cfggetval(argv[0], &val) != SUCCESS) || (val < 0) || (val >= 128)) {
                   return;
         if (!(bank & 1)) {                                      // for tone          }
                 tone->note = TONECFG_VARIABLE;          tone = mod->tonecfg[bank];
         }          if (tone == NULL) {
         else {                                                          // for drums                  tone = (TONECFG)_MALLOC(sizeof(_TONECFG) * 128, "tone cfg");
                 flag |= TONECFG_NOLOOP | TONECFG_NOENV;                  if (tone == NULL) {
                 tone->note = (BYTE)val;                          return;
         }                  }
                   mod->tonecfg[bank] = tone;
         for (i=2; i<argc; i++) {                  ZeroMemory(tone, sizeof(_TONECFG) * 128);
                 key = argv[i];          }
                 data = seachr(key, '=');          tone += val;
                 if (data == NULL) {          name = tone->name;
                         continue;          if (name == NULL) {
                 }                  name = (OEMCHAR *)listarray_append(mod->namelist, NULL);
                 *data++ = '\0';                  tone->name = name;
                 if (!milstr_cmp(key, str_amp)) {          }
                         if (cfggetval(data, &val) == SUCCESS) {          if (name) {
                                 if (val < 0) {                  name[0] = '\0';
                                         val = 0;                  file_catname(name, argv[1], MAX_NAME);          // separator change!
                                 }          }
                                 else if (val > CFG_MAXAMP) {          flag = TONECFG_EXIST;
                                         val = CFG_MAXAMP;          tone->amp = TONECFG_AUTOAMP;
                                 }          tone->pan = TONECFG_VARIABLE;
                                 tone->amp = val;  
                         }          if (!(bank & 1)) {                                      // for tone
                 }                  tone->note = TONECFG_VARIABLE;
                 else if (!milstr_cmp(key, str_keep)) {          }
                         if (!milstr_cmp(data, str_env)) {          else {                                                          // for drums
                                 flag &= ~TONECFG_NOENV;                  flag |= TONECFG_NOLOOP | TONECFG_NOENV;
                                 flag |= TONECFG_KEEPENV;                  tone->note = (UINT8)val;
                         }          }
                         else if (!milstr_cmp(data, str_loop)) {  
                                 flag &= ~TONECFG_NOLOOP;          for (i=2; i<argc; i++) {
                         }                  key = argv[i];
                 }                  data = seachr(key, '=');
                 else if (!milstr_cmp(key, str_note)) {                  if (data == NULL) {
                         if ((cfggetval(data, &val) == SUCCESS) &&                          continue;
                                 (val >= 0) && (val < 128)) {                  }
                                 tone->note = (BYTE)val;                  *data++ = '\0';
                         }                  if (!milstr_cmp(key, str_amp)) {
                 }                          if (cfggetval(data, &val) == SUCCESS) {
                 else if (!milstr_cmp(key, str_pan)) {                                  if (val < 0) {
                         if (!milstr_cmp(data, str_left)) {                                          val = 0;
                                 val = 0;                                  }
                         }                                  else if (val > CFG_MAXAMP) {
                         else if (!milstr_cmp(data, str_center)) {                                          val = CFG_MAXAMP;
                                 val = 64;                                  }
                         }                                  tone->amp = val;
                         else if (!milstr_cmp(data, str_right)) {                          }
                                 val = 127;                  }
                         }                  else if (!milstr_cmp(key, str_keep)) {
                         else if (cfggetval(data, &val) == SUCCESS) {                          if (!milstr_cmp(data, str_env)) {
                                 if (val < -100) {                                  flag &= ~TONECFG_NOENV;
                                         val = -100;                                  flag |= TONECFG_KEEPENV;
                                 }                          }
                                 else if (val > 100) {                          else if (!milstr_cmp(data, str_loop)) {
                                         val = 100;                                  flag &= ~TONECFG_NOLOOP;
                                 }                          }
                                 val = val + 100;                  }
                                 val *= 127;                  else if (!milstr_cmp(key, str_note)) {
                                 val += 100;                          if ((cfggetval(data, &val) == SUCCESS) &&
                                 val /= 200;                                  (val >= 0) && (val < 128)) {
                         }                                  tone->note = (UINT8)val;
                         else {                          }
                                 continue;                  }
                         }                  else if (!milstr_cmp(key, str_pan)) {
                         tone->pan = (BYTE)val;                          if (!milstr_cmp(data, str_left)) {
                 }                                  val = 0;
                 else if (!milstr_cmp(key, str_strip)) {                          }
                         if (!milstr_cmp(data, str_env)) {                          else if (!milstr_cmp(data, str_center)) {
                                 flag &= ~TONECFG_KEEPENV;                                  val = 64;
                                 flag |= TONECFG_NOENV;                          }
                         }                          else if (!milstr_cmp(data, str_right)) {
                         else if (!milstr_cmp(data, str_loop)) {                                  val = 127;
                                 flag |= TONECFG_NOLOOP;                          }
                         }                          else if (cfggetval(data, &val) == SUCCESS) {
                         else if (!milstr_cmp(data, str_tail)) {                                  if (val < -100) {
                                 flag |= TONECFG_NOTAIL;                                          val = -100;
                         }                                  }
                 }                                  else if (val > 100) {
         }                                          val = 100;
         tone->flag = flag;                                  }
 }                                  val = val + 100;
                                   val *= 127;
                                   val += 100;
 // ----                                  val /= 200;
                           }
 BOOL cfgfile_getfile(MIDIMOD mod, const char *filename,                          else {
                                                                                                         char *path, int size) {                                  continue;
                           }
         PATHLIST        p;                          tone->pan = (UINT8)val;
         short           attr;                  }
                   else if (!milstr_cmp(key, str_strip)) {
         if ((filename == NULL) || (filename[0] == '\0') ||                          if (!milstr_cmp(data, str_env)) {
                 (path == NULL) || (size == 0)) {                                  flag &= ~TONECFG_KEEPENV;
                 goto fpgf_exit;                                  flag |= TONECFG_NOENV;
         }                          }
         p = mod->pathlist;                          else if (!milstr_cmp(data, str_loop)) {
         while(p) {                                  flag |= TONECFG_NOLOOP;
                 file_cpyname(path, p->path, size);                          }
                 file_catname(path, filename, size);                          else if (!milstr_cmp(data, str_tail)) {
                 attr = file_attr(path);                                  flag |= TONECFG_NOTAIL;
                 if (attr != -1) {                          }
                         return(SUCCESS);                  }
                 }          }
                 p = p->next;          tone->flag = flag;
         }  }
   
 fpgf_exit:  
         return(FAILURE);  // ----
 }  
   BRESULT VERMOUTHCL midimod_getfile(MIDIMOD mod, const OEMCHAR *filename,
 BOOL cfgfile_load(MIDIMOD mod, const char *filename, int depth) {                                                                                                          OEMCHAR *path, int size) {
   
         TEXTFILEH       tfh;          PATHLIST        p;
         char            buf[1024];          short           attr;
         int                     bank;  
         int                     i;          if ((filename == NULL) || (filename[0] == '\0') ||
         int                     argc;                  (path == NULL) || (size == 0)) {
         char            *argv[16];                  goto fpgf_exit;
         int                     val;          }
         UINT            cfg;          p = mod->pathlist;
           while(p) {
         bank = -1;                  file_cpyname(path, p->path, size);
                   file_catname(path, filename, size);
         if ((depth >= 16) ||  #if defined(SUPPORT_ARC)
                 (cfgfile_getfile(mod, filename, buf, sizeof(buf)) != SUCCESS)) {                  attr = arcex_attr(path);
                 goto cfl_err;  #else
         }                  attr = file_attr(path);
 //      TRACEOUT(("open: %s", buf));  #endif
         tfh = textfile_open(buf, 0x1000);                  if (attr != -1) {
         if (tfh == NULL) {                          return(SUCCESS);
                 goto cfl_err;                  }
         }                  p = p->next;
         while(textfile_read(tfh, buf, sizeof(buf)) == SUCCESS) {          }
                 argc = cfggetarg(buf, argv, sizeof(argv)/sizeof(char *));  
                 if (argc < 2) {  fpgf_exit:
                         continue;          return(FAILURE);
                 }  }
                 cfg = 0;  
                 while(cfg < (sizeof(cfgstr)/sizeof(char *))) {  static BRESULT VERMOUTHCL cfgfile_load(MIDIMOD mod, const OEMCHAR *filename,
                         if (!milstr_cmp(argv[0], cfgstr[cfg])) {                                                                                                                                  int depth) {
                                 break;  
                         }          TEXTFILEH       tfh;
                         cfg++;          OEMCHAR         buf[1024];
                 }          int                     bank;
                 switch(cfg) {          int                     i;
                         case CFG_DIR:          int                     argc;
                                 for (i=1; i<argc; i++) {          OEMCHAR         *argv[16];
                                         pathadd(mod, argv[i]);          int                     val;
                                 }          UINT            cfg;
                                 break;  
           bank = -1;
                         case CFG_SOURCE:  
                                 for (i=1; i<argc; i++) {          if ((depth >= 16) ||
                                         depth++;                  (midimod_getfile(mod, filename, buf, NELEMENTS(buf)) != SUCCESS)) {
                                         cfgfile_load(mod, argv[i], depth);                  goto cfl_err;
                                         depth--;          }
                                 }  // TRACEOUT(("open: %s", buf));
                                 break;          tfh = textfile_open(buf, 0x1000);
           if (tfh == NULL) {
                         case CFG_DEFAULT:                  goto cfl_err;
                                 break;          }
           while(textfile_read(tfh, buf, NELEMENTS(buf)) == SUCCESS) {
                         case CFG_BANK:                  argc = cfggetarg(buf, argv, NELEMENTS(argv));
                         case CFG_DRUM:                  if (argc < 2) {
                                 if ((cfggetval(argv[1], &val) == SUCCESS) &&                          continue;
                                         (val >= 0) && (val < 128)) {                  }
                                         val <<= 1;                  cfg = 0;
                                         if (cfg == CFG_DRUM) {                  while(cfg < NELEMENTS(cfgstr)) {
                                                 val++;                          if (!milstr_cmp(argv[0], cfgstr[cfg])) {
                                         }                                  break;
                                         bank = val;                          }
                                 }                          cfg++;
                                 break;                  }
                   switch(cfg) {
                         default:                          case CFG_DIR:
                                 settone(mod, bank, argc, argv);                                  for (i=1; i<argc; i++) {
                                 break;                                          pathaddex(mod, argv[i]);
                 }                                  }
         }                                  break;
         textfile_close(tfh);  
         return(SUCCESS);                          case CFG_SOURCE:
                                   for (i=1; i<argc; i++) {
 cfl_err:                                          depth++;
         return(FAILURE);                                          cfgfile_load(mod, argv[i], depth);
 }                                          depth--;
                                   }
                                   break;
 // ----  
                           case CFG_DEFAULT:
 MIDIMOD midimod_create(UINT samprate) {                                  break;
   
         UINT    size;                          case CFG_BANK:
         MIDIMOD ret;                          case CFG_DRUM:
         BOOL    r;                                  if ((cfggetval(argv[1], &val) == SUCCESS) &&
                                           (val >= 0) && (val < 128)) {
         size = sizeof(_MIDIMOD);                                          val <<= 1;
         size += sizeof(INSTRUMENT) * 128 * 2;                                          if (cfg == CFG_DRUM) {
         size += sizeof(_TONECFG) * 128 * 2;                                                  val++;
         ret = (MIDIMOD)_MALLOC(size, "MIDIMOD");                                          }
         if (ret == NULL) {                                          bank = val;
                 goto mmcre_err1;                                  }
         }                                  break;
         ZeroMemory(ret, size);  
         ret->samprate = samprate;                          default:
         ret->tone[0] = (INSTRUMENT *)(ret + 1);                                  settone(mod, bank, argc, argv);
         ret->tone[1] = ret->tone[0] + 128;                                  break;
         ret->tonecfg[0] = (TONECFG)(ret->tone[1] + 128);                  }
         ret->tonecfg[1] = ret->tonecfg[0] + 128;          }
         ret->pathtbl = listarray_new(sizeof(_PATHLIST), 64);          textfile_close(tfh);
         pathadd(ret, NULL);          return(SUCCESS);
         pathadd(ret, file_getcd(str_null));  
         ret->namelist = listarray_new(MAX_NAME, 128);  cfl_err:
         r = cfgfile_load(ret, file_timiditycfg, 0);          return(FAILURE);
 #if defined(TIMIDITY_CFGFILE)  }
         if (r != SUCCESS) {  
                 r = cfgfile_load(ret, TIMIDITY_CFGFILE, 0);  
         }  // ----
 #endif  
         if (r != SUCCESS) {  VEXTERN MIDIMOD VEXPORT midimod_create(UINT samprate) {
                 goto mmcre_err2;  
         }          UINT    size;
         return(ret);          MIDIMOD ret;
           BRESULT r;
 mmcre_err2:  
         listarray_destroy(ret->namelist);          size = sizeof(_MIDIMOD);
         listarray_destroy(ret->pathtbl);          size += sizeof(INSTRUMENT) * 128 * 2;
         _MFREE(ret);          size += sizeof(_TONECFG) * 128 * 2;
           ret = (MIDIMOD)_MALLOC(size, "MIDIMOD");
 mmcre_err1:          if (ret == NULL) {
         return(NULL);                  goto mmcre_err1;
 }          }
           ZeroMemory(ret, size);
 void midimod_destroy(MIDIMOD hdl) {          ret->samprate = samprate;
           ret->tone[0] = (INSTRUMENT *)(ret + 1);
         UINT    r;          ret->tone[1] = ret->tone[0] + 128;
         TONECFG bank;          ret->tonecfg[0] = (TONECFG)(ret->tone[1] + 128);
           ret->tonecfg[1] = ret->tonecfg[0] + 128;
         if (hdl) {          ret->pathtbl = listarray_new(sizeof(_PATHLIST), 16);
                 r = 128;          pathadd(ret, NULL);
                 do {          pathadd(ret, file_getcd(str_null));
                         r--;          ret->namelist = listarray_new(MAX_NAME, 128);
                         inst_bankfree(hdl, r);          r = cfgfile_load(ret, file_timiditycfg, 0);
                 } while(r > 0);  #if defined(TIMIDITY_CFGFILE)
                 for (r=2; r<(MIDI_BANKS*2); r++) {          if (r != SUCCESS) {
                         bank = hdl->tonecfg[r];                  r = cfgfile_load(ret, TIMIDITY_CFGFILE, 0);
                         if (bank) {          }
                                 _MFREE(bank);  #endif
                         }          if (r != SUCCESS) {
                 }                  goto mmcre_err2;
                 listarray_destroy(hdl->namelist);          }
                 listarray_destroy(hdl->pathtbl);          midimod_lock(ret);
                 _MFREE(hdl);          return(ret);
         }  
 }  mmcre_err2:
           listarray_destroy(ret->namelist);
 void midimod_loadprogram(MIDIMOD hdl, UINT num) {          listarray_destroy(ret->pathtbl);
           _MFREE(ret);
         UINT    bank;  
   mmcre_err1:
         if (hdl != NULL) {          return(NULL);
                 bank = (num >> 8) & 0x7f;  }
                 num &= 0x7f;  
                 if (inst_singleload(hdl, bank << 1, num) != MIDIOUT_SUCCESS) {  void VERMOUTHCL midimod_lock(MIDIMOD mod) {
                         inst_singleload(hdl, 0, num);  
                 }          mod->lockcount++;
         }  }
 }  
   void VERMOUTHCL midimod_unlock(MIDIMOD mod) {
 void midimod_loadrhythm(MIDIMOD hdl, UINT num) {  
           UINT    r;
         UINT    bank;          TONECFG bank;
   
         if (hdl != NULL) {          if (!mod->lockcount) {
                 bank = (num >> 8) & 0x7f;                  return;
                 num &= 0x7f;          }
                 if (inst_singleload(hdl, (bank << 1) + 1, num) != MIDIOUT_SUCCESS) {          mod->lockcount--;
                         inst_singleload(hdl, 1, num);          if (mod->lockcount) {
                 }                  return;
         }          }
 }  
           r = 128;
 void midimod_loadgm(MIDIMOD hdl) {          do {
                   r--;
         if (hdl) {                  inst_bankfree(mod, r);
                 inst_bankload(hdl, 0);          } while(r > 0);
                 inst_bankload(hdl, 1);          for (r=2; r<(MIDI_BANKS*2); r++) {
         }                  bank = mod->tonecfg[r];
 }                  if (bank) {
                           _MFREE(bank);
 void midimod_loadall(MIDIMOD hdl) {                  }
           }
         UINT    b;          listarray_destroy(mod->namelist);
           listarray_destroy(mod->pathtbl);
         if (hdl) {          _MFREE(mod);
                 for (b=0; b<(MIDI_BANKS*2); b++) {  }
                         inst_bankload(hdl, b);  
                 }  VEXTERN void VEXPORT midimod_destroy(MIDIMOD mod) {
         }  
 }          if (mod) {
                   midimod_unlock(mod);
           }
   }
   
   VEXTERN BRESULT VEXPORT midimod_cfgload(MIDIMOD mod,
                                                                                                   const OEMCHAR *filename) {
   
           return(cfgfile_load(mod, filename, 0));
   }
   
   VEXTERN void VEXPORT midimod_loadprogram(MIDIMOD mod, UINT num) {
   
           UINT    bank;
   
           if (mod != NULL) {
                   bank = (num >> 8) & 0x7f;
                   num &= 0x7f;
                   if (inst_singleload(mod, bank << 1, num) != MIDIOUT_SUCCESS) {
                           inst_singleload(mod, 0, num);
                   }
           }
   }
   
   VEXTERN void VEXPORT midimod_loadrhythm(MIDIMOD mod, UINT num) {
   
           UINT    bank;
   
           if (mod != NULL) {
                   bank = (num >> 8) & 0x7f;
                   num &= 0x7f;
                   if (inst_singleload(mod, (bank << 1) + 1, num) != MIDIOUT_SUCCESS) {
                           inst_singleload(mod, 1, num);
                   }
           }
   }
   
   VEXTERN void VEXPORT midimod_loadgm(MIDIMOD mod) {
   
           if (mod) {
                   inst_bankload(mod, 0);
                   inst_bankload(mod, 1);
           }
   }
   
   VEXTERN void VEXPORT midimod_loadall(MIDIMOD mod) {
   
           UINT    b;
   
           if (mod) {
                   for (b=0; b<(MIDI_BANKS*2); b++) {
                           inst_bankload(mod, b);
                   }
           }
   }
   
   
   VEXTERN int VEXPORT midimod_loadallex(MIDIMOD mod, FNMIDIOUTLAEXCB cb,
                                                                                                                           void *userdata) {
   
           int                                     result;
           MIDIOUTLAEXPARAM        param;
           UINT                            b;
   
           result = MIDIOUT_SUCCESS;
           if (mod) {
                   ZeroMemory(&param, sizeof(param));
                   param.userdata = userdata;
                   for (b=0; b<(MIDI_BANKS*2); b++) {
                           param.totaltones += inst_gettones(mod, b);
                   }
                   for (b=0; b<(MIDI_BANKS*2); b++) {
                           param.bank = b;
                           result = inst_bankloadex(mod, b, cb, &param);
                           if (result != MIDIOUT_SUCCESS)
                           {
                                   break;
                           }
                   }
           }
           return result;
   }
   

Removed from v.1.4  
changed lines
  Added in v.1.13


RetroPC.NET-CVS <cvs@retropc.net>