Issues with random MIDI messages over generic MIDI jack

To preface: I am attempting to turn a Casio SA-35 into a MIDI keyboard. I have an Arduino Uno R3 and some generic midi jack. I'm using Cantabile Lite (a live VST performance software.) I have the wires hooked up as per this: http://arduino.cc/en/Tutorial/Midi?from=Tutorial.MIDI and I tested the code from that page. It works correctly with Cantabile. I then substituted in my own code, in the file below (it was too long for the post.) BUT, when I tested the code Cantabile freaked out and started playing random notes. I changed Arduinos and it helped a little but after testing a few keys it started freaking out again. I also tested this with Ableton (the demo, although I doubt it makes a difference) and FL Studio (again, the demo, but I doubt this is the problem.) In both cases the midi freaked out and played randomly. I don't know if it was an error in my code or what. Thanks for any help you can provide! Also I'm really sorry about the terrible code, I should probably take a class.

midifinal.ino (8.36 KB)

You may be better to post this in the MIDI section or the programming section, as you have code for someone to review rather than just asking if something is possible.

I guess I don't have enough information to determine what the problem might be. From the code, it looks like you intend to press a button and it will play 4 simultaneous notes (or just 3?). So my first question is: do you have buttons connected to each of the input pins? If not, and you aren't using pulldown/pullup resistors, then any one of those inputs are "floating" which means they can fluctuate between on/off randomly, and it is purely environmental. That's my first guess based on your code and the information you provided.
Let us know if that helps at all!