Musescore ignores Key signatures

• Aug 23, 2022 - 19:41

In the attached file, there is a key change at measure 59 to 3 flats, but it is ignored. There is another change of key at measure 131 to 1 sharp which is also ignored. Is there any way to cause Musescore to honor the embedded key signature events?

Attachment Size
TWV40-121.MID 10.69 KB


In reply to by jeetee

That musescore ignores the first key signature event has been known for a long time, substituting a guess for the key signature instead. I have always assumed that if a key change occurred musescore would at least see and honor it, but apparently it never sees key changes.

The curious thing is, in order to stay synchronized with the events in a MIDI file it has to see the key change event and know how many bytes to skip over. It would be so easy to set the key of each track to the new setting at that point.

In reply to by tpgettys

To be clear - MuseScoee absolutely honors keys signatures and key signature changes in MIDI files - if they occur in the track they apply to. Because MuseScore supports things like different key signatures in different staves (something I gather most non-notation focused MIDI sequencers don't), MuseScore doesn't automatically assume a key signature in one track appplies to all others also. There's been a request for it to do so, and maybe someday that possibility will be supported as well. But for now, just make sure your signatures are actually in the tracks they apply to.

In reply to by Marc Sabatella

"just make sure your signatures are actually in the tracks they apply to"

Ha Ha, good joke Marc. There is no way to do that, and I am sure you know that. All PROFESSIONAL software that generate MIDI files use the same convention: a key signature event applies to all tracks.

To be clear: Using a MIDI file created by musescore as input to musescore proves nothing.

Musescore ignores all key signature events, which is easily proven using any MIDI file that has multiple keys. Musescore stands alone in its incorrect interpretation of MIDI files.

In reply to by tpgettys

It's important to keep in mind that MuseScore is open source - anyone has been welcome to make this change during that time, and anyone continues to be welcome to do so today or at any time in the future. So it's not a question of someone saying "no", it's a question of no one yet having said "yes". All it would take is one person. So presumably, if this is something of value to enough people, one of them will have the technical skills and the inclination to volunteer.

In reply to by tpgettys

Let's try to cut the slander and not call the MIDI specification a joke, agreed?
MIDI Type-2 files exist and according to the spec those enforce the Key Signature Event to be in each track. It is also the only way within the spec that allows for different key signatures on different tracks.

So far for theory, in practice though it seems that only a minority of programs, including so-called "professional software" (not sure why you'd consider MuseScore to not be one of those btw) actually implement that part of the MIDI-standard. Type-0 and Type-1 files are way more common.

To be equally clear: everyone in this thread agrees that MuseScore should honor those events (if no conflicting events on the track itself exist). The only thing you seem to revolt against is that some people here in addition also want to show you how you can achieve what you're looking for today. Let's then not blame MuseScore for the inability of your other software to create standard Type-2 MIDI files. (But yes, let's DO blame MuseScore for not handling the events in the Type-0/1 style).

Asserting plainly wrong statements though, doesn't really help at all (nor does it come across as friendly, but let's write that up to "heat of the moment frustration posting").
You wrote that MuseScore ignores all key signature events; a fact that is easily disproven by loading a Type-2 MIDI file.
You wrote that MuseScore uses an incorrect interpretation of MIDI files; yet here is explained to you that it honors the MIDI standard. At best you can claim that has an incomplete interpretation for a common feature; something we all agree on and why this is an open issue in the issue tracker.
You also claim that MuseScore must already be seeing and understanding this event in order to skip over it. However, as a Key Signature Event is a meta-event it means that: (A) one doesn't have to understand it to be able to skip over it and (B) there is no requirement in the MIDI standard to honor such an event for a parser to be in accordance with the standard. Meta-events are just that, meta.

That's three wrong assertions in this thread alone.

Now to circle back and be clear again; none of those wrong assertions diminish the claim, validity, plea and request for MuseScore to honor those meta-events if they occur on a general track instead of on the local track. We all still want that to happen.

In reply to by jeetee

Thanks for doing that jeetee, and for putting me onto MIDIEditor. I installed it and used it to inspect the file you created.

It looks like you left the track 0 key signature events in so I deleted those. I also deleted the key signature events on track 1 and loaded the resulting file into musescore. The key signature was correct on both lines and changed at the correct places! I will attach the file so you can verify my edits and the behavior by musescore.

If you confirm that the only key signature events are on track 2 and yet were applied to both tracks, that suggests that the incorrect handling of key signature events on track 0 might be even easier to fix that I was thinking.

Attachment Size
TWV40-121-keysigTrack2.MID 14.09 KB

In reply to by tpgettys

I can confirm what you did and experienced.
For fun, see attached where I've placed a different key signature at the start of Track 1. Having that in makes it so the Track2 changes (further in) are no longer applied to Track 1 either.

I think this just means that MuseScore will by default use the key signatures from the first instrument track where it can find them, unless a track contains its own key signatures.

Attachment Size
TWV40-121-keysigTrack2start1.mid 14.1 KB

In reply to by jeetee

Thanks for confirming jeetee.

I did an experiment similar to yours and saw the same result. I agree with your interpretation of those results:
one key signature event on any track will be applied to all tracks unless overridden.

Since a key signature event on any track other than 0 will be honored, it is almost as if there is a line of code that says "if trknum != 0 {apply this key signature event} else {ignore it}

In reply to by tpgettys

Actually, all professional MIDI software I've used has been capable to placing key signature events anywhere you like. It's possible the ones you use are capable of this as well, and you simply haven't discovered how. Feel free to ask for help on the support forums for those programs, probably someone can show you. Maybe even someone here might know.

And, we all agree that someday it would be nice if MuseScore worked from the "conductor track". Meanwhile, it's perfectly capable of reading key signatures - you just need to place them in the tracks, as noted. It's helpful advice, not a joke at all - it's perfectly possible to do this.

Interestingly enough, MuseScore may not display the key change at bar 59, but it does not ignore it, either Note that all the A's are marked flat after 59.

In reply to by bobjp

Hi bobjp, thank you for your observation.
Just to be clear, in a MIDI file the notes themselves are encoded individually and separately from the key signature, so they will always be correct no matter what key signature is displayed. Keep in mind that MIDI files were invented to send music to instruments; the key signature event in a MIDI file is there as a nod to notation software. No MIDI keyboard needs to know anything about "key signature"!

My simple request is that musescore honor the key signature information that is embedded in a MIDI file, which is associated with track 0. This one track is ignored when it comes to key signature information, and yet it is the one that is used to indicate the key signature of a piece of music. If the key signature changes it is so stated on track 0.

This is so not because I want it to be so, but simply because that is what is found in MIDI files in the wild.

In reply to by tpgettys

I agree that it would be nice if MuseScore produced the key signatures in the score. BTW, there is another key change between the two you pointed out. So you don't need to read further.


There is the problem of what instruments are used in this score. Also what clef and octave. MuseScore labels line one as Alto Recorder, Recorder. And the second line as Alto recorder, Flute. Standard treble clef. MuseScore loads a Recorder sound for both.
I opened this in Sibelius, which did show all three key changes. Staves are labeled line one, Recorder and line two, Flute. Clefs are treble 8va up. However the notes display an octave down. Sibelius doesn't playback an octave up ( like the clef says), so it thinks lower notes are out of range and don't play. In spite of staff two being marked Flute, a recorder sound is used. Notes below C 4(?) don't sound. Notes below C are out of range for flute and soprano, and tenor recorder (in their octave). But at least key signatures are there.

So there are other questions besides key signatures. Which Instruments are used? What octave? And a big one, what else is missing?

We know using midi import for any software can be iffy. So try not to use it. And if that is all there is, deal with it, because no matter the program, there are problems.

Do you still have an unanswered question? Please log in first to post your question.