made APat work with APC40, fixed bug in MidiEngine (should generalize)