Make MIDI playback more robust against incorrect alternate endings.

Previously, if the number of alternate endings didn't exactly match the
total repeat count, the repeats would be ignored entirely.

Bug: #63