fix #26516: crash on repitch

I might as well get the ties working for MIDI too, and fix a couple of other issues with MIDI input on repitch (treatment of rests).  Should have it ready by end of day.