// Short version of the Hundred program #include "batonImprov.h" Voice voice; // keeps track of note-offs int time1 = 0; // trigger time of baton 1 in milliseconds int time2 = 0; // trigger time of baton 2 in milliseconds int maxwait = 60; // maximum time to wait for 2nd baton in milliseconds int note; // the MIDI note number to play int loudness; // loudness of the MIDI note to play void playnote(void); // play a note according to the 2 baton positions int makedigit(int a, int b); // make a digit for the note number void stick1trig(void) { time1 = t_time; if (abs(time1-time2) < maxwait) playnote(); } void stick2trig(void) { time2 = t_time; if (abs(time1-time2) < maxwait) playnote(); } void playnote(void) { note = 10*makedigit(baton.x1ts(1,5), baton.y1ts(1,2)) + makedigit(baton.x2ts(1,5), baton.y2ts(1,2)); loudness = (baton.w1t + baton.w2t)/2; voice.play(note, loudness); cout << " note = " << note << endl; } int makedigit(int a, int b) { switch (10*b+a) { case 11: return 6; case 21: return 1; case 12: return 7; case 22: return 2; case 13: return 8; case 23: return 3; case 14: return 9; case 24: return 4; case 15: return 0; case 25: return 5; default: return 0; } } void mainloopalgorithms(void) { } void description(void) { } void initialization(void) { } void finishup(void) { } void b14plustrig(void) { } void b15plustrig(void) { } void b14minusuptrig(void) { } void b14minusdowntrig(void) { } void b15minusuptrig(void) { } void b15minusdowntrig(void) { } void keyboardchar(int key) { }