//cond.c--conductor program //date: Wed Apr 26 13:52:47 PDT 2000 #include "batonImprov.h" #include /*--------------------beginning improvization algorithms------------------*/ /*---------------------initialization algorithms--------------------------*/ void description(void) { cout << " CONDUCTOR PROGRAM COMMANDS\n" "s--select score z--play score\n" "b--stop score playing n--toggle no baton mode on/off\n" << endl; } void initialization(void) { } /*--------------------main loop algorithms -------------------------------*/ void mainloopalgorithms(void) { } /*--------------------triggered algorithms--------------------------------*/ void stick1trig(void) { } void stick2trig(void) { } void b14plustrig(void) { printf("b14+ trigger\n"); } void b15plustrig(void) { printf("b15+ trigger\n"); } void b14minusuptrig(void) { startmeasure=measure; } void b14minusdowntrig(void) { b14minusup=1; } void b15minusuptrig(void) { b15minusdown=1; } void b15minusdowntrig(void) { b15minusup=1; } void keyboardchar(testch){ switch(testch){ case 's': //select and compile score command(17,0); //turn off position reporting cout << "type name of score file: "; cin.getline(scoref, '\n', 1024); strcpy(scorepf, scoref); strcat(scorepf, ".p"); strcpy(midif, scoref); strcat(midif, ".mid"); if ((fp2=fopen(scorepf,"r+b")) != NULL) { cout << "playing existing .p file" << endl; newdotp=0; cout << "type COMMAND (type z to start playing)" << endl; } else{ makedotp(); } break; case 'S': //forces compilation of score file -> dotp.p command(17,0); //turn off position reporting cout << "force compilation of new score.p file" << endl; cout << "type name of score file: "; cin.getline(scoref, '\n', 1024); strcpy(scorepf, scoref); strcat(scorepf, ".p"); strcpy(midif, scoref); strcat(midif, ".p"); makedotp(); break; case 'z': command(17,127); //turn on position reporting loadplay(); pc(); break; case 'n': //toggle no baton mode if (nobat) { nobat=0; cout << "NOBAT MODE OFF << endl; } else { nobat=1; cout << "NOBAT MODE ON << endl; } break; case 'm': //set startmeasure cout << "startmeasure = "; cin >> startmeasure; break; default: cout << "UNKNOWN COMMAND" << endl; pc(); break; } } /*---------------------------end improvization algorithms------------------*/ ////////////////////////////// // // makedotp -- // void makedotp(void){ if ((fp1=fopen(scoref,"r")) != NULL) { discardcnt = 5; scoresok = 1; fp2 = fopen("dotp.p","w+b"); compile(); fclose(fp1); fclose(fp2); if (fp3! = NULL) { fclose(fp3); } if (errorflag) { scoresok=0; } while (m_poll() != -1) { if (readkeyboard++>1000) { readkeyboard = 0; if (kbhit()) { keych = getch(); if (keych=='Q') { goto endmake; } } } } printf("score file--%s compiled\n",scoref); newdotp = 1; printf("type COMMAND (type z to start playing)\n"); } else { printf("score file--%s not found\ntype COMMAND\n",scoref); scoresok = 0; newdotp = 0; } endmake:; } ////////////////////////////// // // loadplay -- // void loadplay(void){ int ii; long nexttime; for (ii=0; ii<16; ii++) { m_cont2(ii,64,0); } nexttime = t_time; while (t_time < nexttime); if (!newdotp) { printf("play existing .p file\n"); if ((fp2 = fopen(scorepf,"r+b")) != NULL){ playf(); } else { printf(".p file not found\ntype COMMAND\n"); scoresok = 0; } } if (newdotp) { printf("play newly compiled .p file--dotp.p\n"); if ((fp2=fopen("dotp.p","r+b")) != NULL) { playf(); } else{ printf("no source score file\ntype COMMAND\n"); scoresok = 0; } } }