// Input is standard in. // This inserts a different voice change for selected channels. // command line input is an even number of numerals: chan voice chan voice ... // Voice is a decimal numeral argument, one per channel, whose meaning // specified at http://www.borg.com/~jglatt/tutr/gm.htm#Patch // Changes go to track 0. // Old voices in named channels are reported and discarded. #include #include "h.h" #include BP bp; note * mus = 0; int main(int argc, char * * argv){ note* music = Read("", &bp); if(!(argc & 1) || argc==1) exit(printf("%s chan voice chan voice ...\n", argv[0])); {typedef struct{short old; short new;} tmbrs; tmbrs vce[16]; void fed(note n){ // printf("dur = %d pc=%d v=%d\n", n.dur, ProgramChange, n.o.prog); if(n.dur==ProgramChange && (vce[n.chan-1].new > -1)) { vce[n.chan-1].old = n.o.prog; printf("deleted change\n");} else aug(n, &mus);} {int k=16; while(k--) vce[k] = (tmbrs){-1, -1};} {int k; for(k=1; k -1) { note hp; hp.start=0; hp.chan=n+1; hp.trk=n+1; hp.dur=ProgramChange; hp.o.prog = vce[n].new; aug(hp, &mus); printf("Added change\n");}} Write("", mus, &bp); {int k; printf( "chan: "); for(k=0; k<16; ++k) printf ("%4d ", k+1); printf("\nold: "); for(k=0; k<16; ++k) printf ("%4d ", vce[k].old); printf("\nnew: "); for(k=0; k<16; ++k) printf ("%4d ", vce[k].new); printf("\n"); }} return 0;}