  
 // Some defines
 #define THRESHOLD 700
+#define VOLUME 0x7F
+#define LASTPORT 4
+#define DELAY 10
+
+// MIDI command defines
+#define NOTEON 0x90
+#define NOTEOFF 0x80
+#define CHANGEINSTRUMENT 0xC0
 
 // Values for different notes
 int note8 = 0x68;

      musicOff(i + 1);
    }
    // Delay 10 to prevent weird analog readings
    delay(10);
  }
}


{
  // Main loop
  // 5 ports, from 0 to 4
  for (int i = 0; i <= LASTPORT; i++) {
    if(analogRead(i) > THRESHOLD) {
      // Beam has been cut
      // i+1 is because i is 0 indexed, but the ID starts with 1
