A MIDI piano synthesizer that implements the Karplus Strong physical modeling algorithm.
Dependencies: mbed USBDevice PinDetect
Diff: LEDController.cpp
- Revision:
- 20:bf675ba2c454
- Parent:
- 17:55e6132c54a8
- Child:
- 21:8b5d753b6bf5
diff -r 894c31ee9ad4 -r bf675ba2c454 LEDController.cpp --- a/LEDController.cpp Thu Apr 21 01:56:20 2016 +0000 +++ b/LEDController.cpp Thu Apr 21 02:37:49 2016 +0000 @@ -26,38 +26,10 @@ void chooseLedForKey(int colors[3], int type, int signature, int key); void setLedToKey(int colors[3], int type, int signature, int led, int key); -//These are the notes numbers and RGB values. -//int noteC[] = {24,1,0,1}; -//int noteD[] = {26,1,0,0}; -//int noteE[] = {16,0,1,0}; -//int noteF[] = {17,0,0,1}; -//int noteG[] = {32,1,1,0}; -//int noteA[] = {34,0,1,1}; -//int noteB[] = {36,1,1,1}; - -//A larger array of all the keys to be iterated over. -//int keys[7][4] = {noteC, noteD, noteE, noteF, noteG, noteA, noteB}; int colors[12][3] = {{1,0,1},{1,0,1},{1,0,0},{1,0,0},{0,1,0},{0,0,1},{0,0,1},{1,1,0},{1,1,0},{0,1,1},{0,1,1},{1,1,1}}; -//Midi Numbers -//int keys[11][12] = {{0,1,2,3,4,5,6,7,8,9,10,11}, -// {12,13,14,15,16,17,18,19,20,21,22,23}, -// {24,25,26,27,28,29,30,31,32,33,34,35}, -// {36,37,38,39,40,41,42,43,44,45,46,47}, -// {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,77,78,79,80,81,82,83}, -// {84,85,86,87,88,89,90,91,92,93,94,95}, -// {96,97,98,99,100,101,102,103,104,105,106,107}, -// {108,109,110,111,112,113,114,115,116,117,118,119}, -// {120,121,122,123,124,125,126,127,0,0,0,0}}; - int ledKeys[4] = {-1,-1,-1,-1}; -LEDController::LEDController() { - -} - void LEDController::identifyKeyForLed(int key, int type){ //pc.printf("\r\nGetting note"); int octave = key%12; @@ -83,20 +55,19 @@ setLedToKey(colors, type, signature, 3, key); }else if(ledKeys[3] == key){ setLedToKey(colors, type, signature, 4, key); - } + } - }else{ - if(ledKeys[0] == -1){ - //pc.printf("\r\nLED1 chosen."); - setLedToKey(colors, type, signature, 1, key); - }else if(ledKeys[1] == -1){ - setLedToKey(colors, type, signature, 2, key); - }else if(ledKeys[2] == -1){ - setLedToKey(colors, type, signature, 3, key); - }else if(ledKeys[3] == -1){ - setLedToKey(colors, type, signature, 4, key); - } + } else { + if(ledKeys[0] == -1){ + setLedToKey(colors, type, signature, 1, key); + }else if(ledKeys[1] == -1){ + setLedToKey(colors, type, signature, 2, key); + }else if(ledKeys[2] == -1){ + setLedToKey(colors, type, signature, 3, key); + }else if(ledKeys[3] == -1){ + setLedToKey(colors, type, signature, 4, key); } + } } //This sets the key or clears the previously set key if the type is off.