Midi sync for cdj-800

If it resets, it sounds electrical. I can't see offhand what would do it in your code. I'm not trying to attack your programming practice, but am suggesting that if you write in a way that is easy to follow, you will help yourself. The use of symbolic names, good layout, comments, etc. help in this regard.