diff -urN midi_prog-/ch.c midi_prog/ch.c --- midi_prog-/ch.c 2015-06-03 00:00:00.000000000 +0900 +++ midi_prog/ch.c 2015-06-09 00:00:00.000000000 +0900 @@ -5,8 +5,8 @@ void ch_init(int ac, char **av) { - int i; - char *s, s_ch[8], buf[1024]; + int i, ch; + char *s; double v; for(i=0; i") != 0){ + for(np=notes_buf; np && sscanf(np, "%[^,]", note_buf) == 1; np=np_update(np)){ + if((note = str_to_note(note_buf)) < 0){ + printf("delta=0 cmd=f8\n"); + }else{ + printf("delta=0 on ch=%d note=%d velo=%d\n", ch, note, velo); + } + } + }else{ + printf("delta=0 cmd=f8\n"); + } + + if(strcmp(sla, "-") != 0 && strcmp(sla, "<") != 0){ + delta = len_on; + for(np=notes_buf; np && sscanf(np, "%[^,]", note_buf) == 1; np=np_update(np)){ + if((note = str_to_note(note_buf)) < 0){ + printf("delta=%d cmd=f8\n", delta); + }else{ + printf("delta=%d off ch=%d note=%d velo=%d\n", delta, ch, note, velo); + } + delta = 0; + } + if((delta = len - len_on) > 0){ + printf("delta=%d cmd=f8\n", delta); + } + }else{ + printf("delta=%d cmd=f8\n", len); + } + } + return 0; +} + +int +trans_conv(int ac, char **av, int trans) +{ + int en[ MIDI_CH_N ] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1 }; + char *s = opt_str("-tx_trans_enable", ac, av, NULL); + char buf[BUFSZ], buf_time[BUFSZ], buf_cmd[BUFSZ], buf_velo[BUFSZ]; + int i, v, ch, note; + + while(opt_ch_loop_get(&s, &ch, &v)){ + if(ch == -1) for(i=0; i= 0) return rconv(); if(opt_idx("-tx_abs", ac, av) >= 0) return tx_abs_conv(); if(opt_idx("-tx_delta", ac, av) >= 0) return tx_delta_conv(); + if(opt_idx("-len", ac, av) >= 0) return len_to_delta_conv(ac, av); + if((trans = opt_int("-tx_trans", ac, av, 0)) != 0) return trans_conv(ac, av, trans); rd_str(4, buf); printf("%s\n", buf); diff -urN midi_prog-/out.c midi_prog/out.c --- midi_prog-/out.c 2015-04-29 00:00:00.000000000 +0900 +++ midi_prog/out.c 2015-06-09 00:00:00.000000000 +0900 @@ -23,7 +23,7 @@ void out_init(struct out_rec *ot, int ac, char **av) { - char cmd[1024], *fn; + char cmd[BUFSZ], *fn; ot->smp_freq = opt_int("-r", ac, av, 44100); ot->smp_cnt = 0; diff -urN midi_prog-/util.c midi_prog/util.c --- midi_prog-/util.c 2015-04-20 00:00:00.000000000 +0900 +++ midi_prog/util.c 2015-06-09 00:00:00.000000000 +0900 @@ -37,6 +37,28 @@ return strtod(s, NULL); } +int +opt_ch_loop_get(char **sp, int *ch, int *v) +{ + double d; + int ret = opt_ch_loop_get_dbl(sp, ch, &d); + if(ret) *v = (int)d; + return ret; +} + +int +opt_ch_loop_get_dbl(char **sp, int *ch, double *v) +{ + char s_ch[8], buf[BUFSZ]; + int ret = *sp && **sp && sscanf(*sp, "%[^:]:%s", s_ch, buf) == 2; + if(ret){ + *v = strtod(buf, sp); + *ch = strcmp(s_ch, "all") == 0 ? -1 : strtol(s_ch, NULL, 0); + if(**sp == ',') (*sp)++; + } + return ret; +} + struct stklst * stklst_alloc(int size, struct stklst *prev) { diff -urN midi_prog-/util.h midi_prog/util.h --- midi_prog-/util.h 2015-04-20 00:00:00.000000000 +0900 +++ midi_prog/util.h 2015-06-09 00:00:00.000000000 +0900 @@ -11,6 +11,7 @@ #define OFF 0 #define ON 1 +#define BUFSZ 1024 #define MIX(a, b, rate) ( (a) * (1 - (rate)) + (b) * (rate) ) @@ -19,6 +20,9 @@ int opt_int(char *key, int ac, char **av, int def); double opt_double(char *key, int ac, char **av, double def); +int opt_ch_loop_get(char **sp, int *ch, int *v); +int opt_ch_loop_get_dbl(char **sp, int *ch, double *v); + struct stklst{ int size; diff -urN midi_prog-/voco.c midi_prog/voco.c --- midi_prog-/voco.c 2015-04-29 00:00:00.000000000 +0900 +++ midi_prog/voco.c 2015-06-09 00:00:00.000000000 +0900 @@ -31,22 +31,15 @@ adj_vol_init(int ac, char **av) { double *adj_vol, v; - char *s, s_idx[8], buf[1024]; + char *s; int i; if((adj_vol = malloc(sizeof(*adj_vol) * band.n)) == NULL) ERR("No Mem"); for(i=0; i