Do not use MIDI channel 10 for sound output
MIDI channel 10 is reserved for drums sound. When doing output to a midi device approx every 12-16th Note a 'drums' sound is produced. I think the reason is that a MIDI event is sent to channel 10. This channel should be skipped.