//jon2.c--two counterpoint voices with scales #include "improv.h" //#include "user.h" long actiontime; short timb1,timb2; short off1,off2,uplimit1,lolimit1,uplimit2,lolimit2; short noteon1,noteon2,keyno1,keyno2,index1,index2,scale1,scale2,tranp; short ns1,ns2,ntp; short scale[5][40]={ {36,37,38,39,40,41,42,43,44,45, 46,48,49,50,51,52,53,54,55,56, 57,58,59,60,61,62,63,64,65,66, 67,68,69,70,71,72,73,74,75,76},//half step {24,26,28,30,32,34,36,38,40,42, 44,46,48,50,52,54,56,58,60,62, 64,66,68,70,72,74,76,78,80,82, 84,86,88,90,92,94,96,98,100,102}, //whole tone {24,26,28,29,31,33,35,36,38,40, 41,43,45,47,48,50,52,53,55,57, 59,60,62,64,65,67,69,71,72,74, 76,77,79,81,83,84,86,88,89,91}, //c major {24,26,27,29,31,33,35,36,38,39, 41,43,45,47,48,50,51,53,55,57, 59,60,62,63,65,67,69,71,72,74, 75,77,79,81,83,84,86,87,89,91}, //c minor {24,26,29,31,33,36,38,41,43,45, 48,50,53,55,57,60,62,65,67,69, 72,74,77,79,81,84,86,89,91,93, 96,98,101,103,105,108,110,113,115,117}//pentatonic }; void printcurrent(void){ printf ("%5d %5d %5d %5d %5d %5d %5d\r",keyno1,keyno2,scale1,scale2,timb1,timb2,tranp); } /*--------------------beginning improvization algorithms------------------*/ /*---------------------initialization algorithms--------------------------*/ void description(void){ printf("JON2--TWO STICK COUNTERPOINT WITH SCALES\n"); printf("B15+ -> RESTART \n"); }//end printheader() void initialization(void){ printf("TYPE PROGRAM #'s FOR STICK 1 TIMBRE AND FOR STICK 2 TIMBRE "); scanf("%d %d",&timb1,&timb2);program_change(1,timb1);program_change(2,timb2); off1=(set1*5)/6;off2=(set2*5)/6; printf("pot1->voice 1 scale pot2->voice 2 scale pot3-> transpose\n"); printf("b15- -> sustain\n"); printf("scale0=chromatic\nscale1=whole tone\nscale2=major\nscale3=minor\nscale4=pentatonic\n"); keyno1=60+tranp;keyno2=60+tranp;scale1=1;scale2=1; printf("keyn1 keyn2 scal1 scal2 timb1 timb2 transp\n"); t_time=actiontime=0; whack1y = whack2y = 0; } /*--------------------main loop algorithms -------------------------------*/ void mainloopalgorithms(void){ // stick1 poll algorithms--------------------------------------------------- if(t_time>actiontime){ actiontime=t_time+10; control_change(1,7,yt1); control_change(2,7,yt2); } if(whack1y){ whack1y=0; index1=(xw1*2)/5;if(index1>39)index1=39; note_on(1,keyno1,0); keyno1=tranp+scale[scale1][index1]; note_on(1,keyno1,127);noteon1=1; uplimit1=xt1+4;lolimit1=xt1-4; goto endpoll1; } if(zt1hit1){ if(xt1>uplimit1){ note_on(1,keyno1,0); index1++; if(index1>33)index1=33; if(index1<0)index1=0; keyno1=tranp+scale[scale1][index1]; note_on(1,keyno1,127);noteon1=1; printcurrent(); uplimit1=xt1+4;lolimit1=xt1-4; } if(xt133)index1=33; if(index1<0)index1=0; keyno1=tranp+scale[scale1][index1]; note_on(1,keyno1,127);noteon1=1; printcurrent(); uplimit1=xt1+4;lolimit1=xt1-4; } }//end if(zt1>hit1) endpoll1:; // stick2 poll code---------------------------------------------------------- if(whack2y){ whack2y=0; index2=(xw2*2)/5;if(index2>39)index2=39; note_on(2,keyno2,0); keyno2=tranp+scale[scale2][index2]; note_on(2,keyno2,127);noteon2=1; uplimit2=xt2+4;lolimit2=xt2-4; goto endpoll2; } if(zt2hit2){ if(xt2>uplimit2){ note_on(2,keyno2,0); index2++; if(index2>33)index2=33; if(index2<0)index2=0; keyno2=tranp+scale[scale2][index2]; note_on(2,keyno2,127);noteon2=1; printcurrent(); uplimit2=xt2+4;lolimit2=xt2-4; } if(xt233)index2=33; if(index2<0)index2=0; keyno2=tranp+scale[scale2][index2]; note_on(2,keyno2,127);noteon2=1; printcurrent(); uplimit2=xt2+4;lolimit2=xt2-4; } }//end if(zt2>hit2) endpoll2:; // pots poll code----------------------------------------------------------- ns1=pt1/16;if(ns1>4)ns1=4;if(ns1!=scale1){scale1=ns1;printcurrent();} ns2=pt2/16;if(ns2>4)ns2=4;if(ns2!=scale2){scale2=ns2;printcurrent();} ntp=(pt3-50)/6;if(ntp!=tranp){tranp=ntp;printcurrent();} }//end mainloopalgorithms() /*--------------------triggered algorithms--------------------------------*/ void stick1trig(void){ whack1y = 1;} void stick2trig(void){ whack2y = 1; } void b14plustrig(void){} void b15plustrig(void){initialization();} void b14minusuptrig(void){} void b14minusdowntrig(void){} void b15minusuptrig(void){control_change(1,64,0);control_change(2,64,0);} void b15minusdowntrig(void){control_change(1,64,127);control_change(2,64,127);} void keyboardchar(int c){} void finishup(void){} /*---------------------------poll responce algorithms----------------------*/ /*---------------------------end improvization algorithms------------------*/ /* some functions and variables provided by the support program m_send(a)-----------------------send midi character m_poll()------------------------receive midi character m_play(chan,keyno,keyvel)-------play note m_cont(chan,controller,value)---control change m_pc(chan,program)=-------------program change t_time--------------------------clock in milliseconds */