Avoiding invalid MIDIs