filter duplicate notes and apply looped note offs to prevent unterminated notes