// This program transposes a MIDI file into another key. // "trnsp 12 < x.mid" makes a file out.midi which is like // x.mid but an octave higher. // "trnsp -12 < x.mid" an octave lower. #include "h.h" #include #include BP bp; note * mus = 0; int main(int argc, char * argl[]){note* music = Read("", &bp); if(argc<2){printf("trnsp halfsteps < x.mid\n"); exit(42);} {int v = atoi(argl[1]); void fed(note n){ if(n.dur < maxdur) n.o.n.freq += v; aug(n, &mus);} printf("Transposing %s %d half steps\n", v<0?"down":"up", abs(v)); scan(fed, music, 1); Write("", mus, &bp); return 0;}}