// The device number to open 0 => int deviceNum; // keyboard Hid kb; // hid message HidMsg msg; // Open keyboard. if(!kb.openKeyboard(deviceNum)) me.exit(); // Successful! Print name of device. <<< "Keyboard '", kb.name(), "' ready." >>>; // Key x-axis coordinate int x[256]; 0 => x[100] => x[53]; 1 => x[41] => x[49] => x[30] => x[20] => x[4] => x[29]; 2 => x[58] => x[31] => x[26] => x[22] => x[27]; 3 => x[59] => x[32] => x[8] => x[7] => x[6]; 4 => x[60] => x[33] => x[21] => x[9] => x[25]; 5 => x[61] => x[34] => x[23] => x[10] => x[5]; 6 => x[62] => x[35] => x[28] => x[11] => x[17]; 7 => x[63] => x[36] => x[24] => x[13] => x[16]; 8 => x[64] => x[37] => x[12] => x[14] => x[54]; 9 => x[65] => x[38] => x[18] => x[15] => x[55]; 10 => x[66] => x[39] => x[19] => x[51] => x[56]; 11 => x[67] => x[45] => x[47] => x[52] => x[229]; 12 => x[68] => x[46] => x[48] => x[49]; // Key y-axis coordinate int y[256]; 0 => y[49] => y[58] => y[59] => y[60] => y[61] => y[62] => y[63] => y[64] => y[65] => y[66] => y[67] => y[68] => y[69]; 1 => y[100] => y[30] => y[31] => y[32] => y[33] => y[34] => y[35] => y[36] => y[37] => y[38] => y[39] => y[45] => y[46]; 2 => y[20] => y[26] => y[8] => y[21] => y[23] => y[28] => y[24] => y[12] => y[18] => y[19] => y[47] => y[48]; 3 => y[4] => y[22] => y[7] => y[9] => y[10] => y[11] => y[13] => y[14] => y[15] => y[51] => y[52] => y[49]; 4 => y[53] => y[29] => y[27] => y[6] => y[25] => y[5] => y[17] => y[16] => y[54] => y[55] => y[56] => y[229]; // Key serving as origin 7 => int x0; 3 => int y0; int init[256]; // Tuning frequency 440.0 => float f0; Gain g; .1 => g.gain; BeeThree s[256]; JCRev r[256]; Echo e[256]; Echo e2[256]; // infinite event loop while(true) { // wait on event kb => now; // get one or more messages while(kb.recv(msg) && !((x[msg.which] == 0) && (y[msg.which] == 0))) { // check for action type if(msg.isButtonDown()) { if (init[msg.which] == 0) { 1 => init[msg.which]; 240::ms => e[msg.which].max => e[msg.which].delay; 480::ms => e2[msg.which].max => e2[msg.which].delay; // set gains .2 => e[msg.which].gain; .1 => e2[msg.which].gain; .05 => r[msg.which].mix; r[msg.which] => dac; s[msg.which] => r[msg.which] => e[msg.which] => e2[msg.which] => dac; } // print <<< " key", msg.which, "down (", x[msg.which], ",", y[msg.which], ")" >>>; f0 * Math.pow(2, (5*(x[msg.which] - x0) + 3*(y[msg.which] - y0))/31.0) => s[msg.which].freq; 1 => s[msg.which].noteOn; } else { // print <<< " key", msg.which, "up (", x[msg.which], ",", y[msg.which], ")" >>>; 1 => s[msg.which].noteOff; } } }