Thanks Tom for realizing my very stupid mistake! I've made some changes and I have got almost everything working how I wanted it to.
However, I have one issue and this problem happens only when I am running Fluidsynth on my Raspberry Pi 3. When I am jamming away on a lot of keys at one time on the keyboard it seems to sometimes miss midi noteon or noteoff events. I know this because when running Fluidsynth (compiled from the original git source code) if I set the midi channel to an organ and I press a lot of keys and I pull away my hands one or two notes will still be sustaining. It also happens that some notes don't turn on sometimes.
I verified this by adding an error printout to my program to detect noteoff events for notes that are already off and noteon events for notes that are already on. Sure enough I get one of these error printouts when I hear an issue.
I checked with top and the PI has plenty of memory and cpu power available when running fluidsynth. The only warning fluidsynth prints out is this:
fluidsynth: warning: Requested a period size of 64, got 256 instead
I don't think this would be related to not receiving midi events right??
Any suggestions?
Thanks for the help,
-Chris