fix #38041: pedal not exported to MIDI

Pedal events were not being collected at all during export - only during playback.  I factored that out so the same code is used for both playback and export.  Swing was also not being exported correctly if you tried exporting before listening to playback within MuseScore; I fixed that as well.  There are some other things that are done in Score::renderMidi() but not in ExportMidi::write() - like calling updateVelo() - but this appears to not be necessary as updateVelo is called on every doLayout() (something we could consider eliminating, BTW).
Same here - even more - nested loop.