fix #41511: bad tpc1 for notes entered in keys other than C

The issue has existed since a change how Note::setNval() works in https://github.com/musescore/MuseScore/commit/58763e6c.  The basic problem is that were are relying on calculating tpc1 from pitch & key in a case where the parent chord has not been added to the score yet and hence there is no way to determine key from its tick (tick is -1).

There are multiple ways this could be fixed.  I elected to add an optional "tick" parameter to the function and passing in the current tick at the one place I could find where setNval() was being called on a chord that had not been added - in Score::setNoteRest().  I continue to deduce the tick from the chord in cases where a note is simply being added to an existing chord (also for repitch mode).  I could also have made the extra parameter a Key, but since we already had code to find key from tick in setNval(), I didn't see a good reason to duplicate it (even if if only one line).  I also considered making "tick" a member of the NoteVal structure, but that somehow didn't seem right.

I have verified this works for various forms of note entry:

- typing notes into an empty measure
- adding notes to chords using shift+letter and alt+number
- adding notes to empty measures by clicking
- adding notes to empty measures via MIDI input (single notes and chords)
- repitch mode, using both typing and MIDI