Problems sending midi messages - values not the same at arrival

I wonder whether the MIDI circuit connection is doing something to the analog side - making an earth float, dragging a supply down, forming a ground loop or similar.

Perhaps you could create a simplified sketch which has no inputs and just outputs some hard-coded values. This would (hopefully) allow you to rule out any peculiar behaviour on the MIDI transmission itself, and imply that the problem is connecting the MIDI port causes the analog readings to change.