 void musicOn(int ID) {
   if (noteSet == 0) {
     switch (ID) {
-    case 0:
-      noteOn(NOTEON, note1, VOLUME);
-      break;
-    case 1:
-      noteOn(NOTEON, note2, VOLUME);
-      break;
-    case 2:
-      noteOn(NOTEON, note3, VOLUME);
-      break;
-    case 3:
-      noteOn(NOTEON, note4, VOLUME);
-      break;
-    case 4:
-      noteOn(NOTEON, note5, VOLUME);
-      break;
-    case 5:
-      noteOn(NOTEON, note6, VOLUME);
-      break;
-    case 6:
-      noteOn(NOTEON, note7, VOLUME);
-      break;
-    case 7:
-      noteOn(NOTEON, note8, VOLUME);
-      break;
-    default:
-      // WTF? It shouldn't reach here, because that's an invalid ID
-      noteOn(NOTEOFF, note1, 0x00);
-      break;
+      case 0:
+        noteOn(NOTEON, note1, VOLUME);
+        break;
+      case 1:
+        noteOn(NOTEON, note2, VOLUME);
+        break;
+      case 2:
+        noteOn(NOTEON, note3, VOLUME);
+        break;
+      case 3:
+        noteOn(NOTEON, note4, VOLUME);
+        break;
+      case 4:
+        noteOn(NOTEON, note5, VOLUME);
+        break;
+      case 5:
+        noteOn(NOTEON, note6, VOLUME);
+        break;
+      case 6:
+        noteOn(NOTEON, note7, VOLUME);
+        break;
+      case 7:
+        noteOn(NOTEON, note8, VOLUME);
+        break;
+      default:
+        // WTF? It shouldn't reach here, because that's an invalid ID
+        noteOn(NOTEOFF, note1, 0x00);
+        break;
     }
   } else if (noteSet == 1) {
     switch (ID) {
-    case 0:
-      noteOn(NOTEON, note9, VOLUME);
-      break;
-    case 1:
-      noteOn(NOTEON, note10, VOLUME);
-      break;
-    case 2:
-      noteOn(NOTEON, note11, VOLUME);
-      break;
-    case 3:
-      noteOn(NOTEON, note12, VOLUME);
-      break;
-    case 4:
-      noteOn(NOTEON, note13, VOLUME);
-      break;
-    case 5:
-      noteOn(NOTEON, note14, VOLUME);
-      break;
-    case 6:
-      noteOn(NOTEON, note15, VOLUME);
-      break;
-    case 7:
-      noteOn(NOTEON, note16, VOLUME);
-      break;
-    default:
-      // WTF? It shouldn't reach here, because that's an invalid ID
-      noteOn(NOTEOFF, note1, 0x00);
-      break;
+      case 0:
+        noteOn(NOTEON, note9, VOLUME);
+        break;
+      case 1:
+        noteOn(NOTEON, note10, VOLUME);
+        break;
+      case 2:
+        noteOn(NOTEON, note11, VOLUME);
+        break;
+      case 3:
+        noteOn(NOTEON, note12, VOLUME);
+        break;
+      case 4:
+        noteOn(NOTEON, note13, VOLUME);
+        break;
+      case 5:
+        noteOn(NOTEON, note14, VOLUME);
+        break;
+      case 6:
+        noteOn(NOTEON, note15, VOLUME);
+        break;
+      case 7:
+        noteOn(NOTEON, note16, VOLUME);
+        break;
+      default:
+        // WTF? It shouldn't reach here, because that's an invalid ID
+        noteOn(NOTEOFF, note1, 0x00);
+        break;
     }
   }
 }
-  
-  // Function for turning off a specific note based on ID
-  // Just a slightly modified version of musicOn()
+
+// Function for turning off a specific note based on ID
+// Just a slightly modified version of musicOn()
 void musicOff(int ID) {
   if (noteSet == 0) {
     switch (ID) {
-    case 0:
-      noteOn(NOTEOFF, note1, 0x7F);
-      break;
-    case 1:
-      noteOn(NOTEOFF, note2, 0x7F);
-      break;
-    case 2:
-      noteOn(NOTEOFF, note3, 0x7F);
-      break;
-    case 3:
-      noteOn(NOTEOFF, note4, 0x7F);
-      break;
-    case 4:
-      noteOn(NOTEOFF, note5, 0x7F);
-      break;
-    case 5:
-      noteOn(NOTEOFF, note6, 0x7F);
-      break;
-    case 6:
-      noteOn(NOTEOFF, note7, 0x7F);
-      break;
-    case 7:
-      noteOn(NOTEOFF, note8, 0x7F);
-      break;
-    default:
-      // WTF? It shouldn't reach here, because that's an invalid ID
-      noteOn(NOTEOFF, note1, 0x00);
-      break;
+      case 0:
+        noteOn(NOTEOFF, note1, 0x7F);
+        break;
+      case 1:
+        noteOn(NOTEOFF, note2, 0x7F);
+        break;
+      case 2:
+        noteOn(NOTEOFF, note3, 0x7F);
+        break;
+      case 3:
+        noteOn(NOTEOFF, note4, 0x7F);
+        break;
+      case 4:
+        noteOn(NOTEOFF, note5, 0x7F);
+        break;
+      case 5:
+        noteOn(NOTEOFF, note6, 0x7F);
+        break;
+      case 6:
+        noteOn(NOTEOFF, note7, 0x7F);
+        break;
+      case 7:
+        noteOn(NOTEOFF, note8, 0x7F);
+        break;
+      default:
+        // WTF? It shouldn't reach here, because that's an invalid ID
+        noteOn(NOTEOFF, note1, 0x00);
+        break;
     }
   } else if (noteSet == 1) {
     switch (ID) {
-    case 0:
-      noteOn(NOTEOFF, note9, VOLUME);
-      break;
-    case 1:
-      noteOn(NOTEOFF, note10, VOLUME);
-      break;
-    case 2:
-      noteOn(NOTEOFF, note11, VOLUME);
-      break;
-    case 3:
-      noteOn(NOTEOFF, note12, VOLUME);
-      break;
-    case 4:
-      noteOn(NOTEOFF, note13, VOLUME);
-      break;
-    case 5:
-      noteOn(NOTEOFF, note14, VOLUME);
-      break;
-    case 6:
-      noteOn(NOTEOFF, note15, VOLUME);
-      break;
-    case 7:
-      noteOn(NOTEOFF, note16, VOLUME);
-      break;
-    default:
-      // WTF? It shouldn't reach here, because that's an invalid ID
-      noteOn(NOTEOFF, note1, 0x00);
-      break;
+      case 0:
+        noteOn(NOTEOFF, note9, VOLUME);
+        break;
+      case 1:
+        noteOn(NOTEOFF, note10, VOLUME);
+        break;
+      case 2:
+        noteOn(NOTEOFF, note11, VOLUME);
+        break;
+      case 3:
+        noteOn(NOTEOFF, note12, VOLUME);
+        break;
+      case 4:
+        noteOn(NOTEOFF, note13, VOLUME);
+        break;
+      case 5:
+        noteOn(NOTEOFF, note14, VOLUME);
+        break;
+      case 6:
+        noteOn(NOTEOFF, note15, VOLUME);
+        break;
+      case 7:
+        noteOn(NOTEOFF, note16, VOLUME);
+        break;
+      default:
+        // WTF? It shouldn't reach here, because that's an invalid ID
+        noteOn(NOTEOFF, note1, 0x00);
+        break;
     }
   }
 }

  // LASTPORT+1 ports, from 0 to LASTPORT
  for (int i = 0; i <= LASTPORT; i++) {
    /* The following three lines convert the port we want
     * into the correct bit selections for the 74HC4051. I'm
     * not really sure exactly how it works, but I'm pretty
     * sure it's some bit shifting
     */
    r0 = bitRead(i,0);
    r1 = bitRead(i,1);
    r2 = bitRead(i,2);
    // Select the correct input using the values we calculated above
    digitalWrite(2, r0);
    digitalWrite(3, r1);
    digitalWrite(4, r2);
    // Detect if the instrument selection button is pressed
    if(digitalRead(INSTRUMENTBUTTON) == HIGH) {
      /* Make sure that this is the first time that the button
       * has been pressed
       */
      if (instrumentButtonState == 0) {
        if (currentInstrument >= (NUMINSTRUMENTS - 1)) {
          // Max number of instruments, so wrap around to 0

// MIDI property defines
#define VOLUME 0x7F

// Debounce threshold (milliseconds)
#define DEBOUNCE_THRESHOLD 100

/* Comment out the below to enable a slight delay between reading
   each note. This may be necessary because sometimes rapidly reading
   analog values can cause strange values. Comment out the below if
   you notice anything strange, because this is probably the culprit */
#define NODELAY

#ifndef NODELAY
