fix #39316: non-diatonic ornament playback

There was no code in diatonicUpDown to handle cases where the the input pitch was not in the key.  I add some, commenting and restructuring the function a bit along the way.  Also added a test.

BTW, I see this same function is called when adding a trill line, and a whole bunch of NoteEvents are generated as if we were trying to implement trill playback.  But it is not having any effect.  probably because this this code doesn't belong in cmdAddSpanner() but in renderMidi().  As a result, trills don't playback.  Seems if the code is there, maybe we should fix it?