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