A MIDI piano synthesizer that implements the Karplus Strong physical modeling algorithm.
Dependencies: mbed USBDevice PinDetect
Diff: LEDController.cpp
- Revision:
- 22:b800e1766647
- Parent:
- 21:8b5d753b6bf5
diff -r 8b5d753b6bf5 -r b800e1766647 LEDController.cpp --- a/LEDController.cpp Mon Apr 25 03:23:43 2016 +0000 +++ b/LEDController.cpp Mon Apr 25 23:58:15 2016 +0000 @@ -71,16 +71,27 @@ void LEDController::chooseLedForKey(int colors[3], int type, int signature, int key){ //Determines if the LED is not set and therefore can be used. - //Or if it is in use by the same key being passed in this means the led needs to be turned off. - if(ledKeys[0] == -1 || ledKeys[0] == key){ - setLedToKey(colors, type, signature, cLED1, key); - }else if(ledKeys[1] == -1 || ledKeys[1] == key){ - setLedToKey(colors, type, signature, cLED2, key); - }else if(ledKeys[2] == -1 || ledKeys[2] == key){ - setLedToKey(colors, type, signature, cLED3, key); - }else if(ledKeys[3] == -1 || ledKeys[3] == key){ - setLedToKey(colors, type, signature, cLED4, key); + if(type == -1){ + if(ledKeys[0] == key){ + setLedToKey(colors, type, signature, 1, key); + }else if(ledKeys[1] == key){ + setLedToKey(colors, type, signature, 2, key); + }else if(ledKeys[2] == key){ + setLedToKey(colors, type, signature, 3, key); + }else if(ledKeys[3] == key){ + 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 LED to the key or clears the previously set LED of that specific key if the type is off.