# This is meant to be invoked after setting Word, Leng, and Outfile function keychain(c,x) { p = progchange(c,1); # program change on channel 1 p += x; writemf(p,"www.mid") writelines(p,"www.lines") } function qn_(s) { return(phrase("'"+s+"'")); } function adddrumpatt(x,n) { f=Keyroot+"/music/patt"+string(n)+".mid"; p = readmid(f); if ( sizeof(p) == 0 ) p = 'p38c10d192'; p = repleng(p,x.length); return(p|x); } function writelines(p,fn) { f = open(fn,"w") xsize1 = string(1+latest(p)) put(f,"size "+xsize1+" 128\n") xsize = string(latest(p)) put(f,"line 0 0 "+xsize+" 0\n") # top put(f,"line "+xsize+" 0 "+xsize+" 127\n") # right put(f,"line 0 127 "+xsize+" 127\n") # bottom put(f,"line 0 0 0 127\n") for ( n in p ) { if ( n.type != NOTE ) continue ys = string(127-n.pitch) put(f,"line "+string(n.time)+" "+ys+" " +string(n.time+n.dur)+" "+ys+"\n") } close(f) }