MuseScore 4: unwanted key signatures when opening MIDI files

• Aug 16, 2023 - 01:44

I'm using MuseScore 4.1.1 and I found what seems to be a bug: when importing a MIDI file, MuseScore for some reason introduces an arbitrary (and in my case, completely wrong) key signature, not present in the file.
I have MIDI files with chromatic, non-tonal passages, and I end up with some ridiculous key signatures. I haven't found a way to disable this annoying "feature".

I thought that an effective workaround would be to explicitly introduce a C major keychange in the MIDI file, but to my surprise, even then MuseScore tries to second-guess what's in the file. Please see the attached test MIDI file, and how it's imported in MuseScore.

Am I missing something? How can I prevent MuseScore from introducing these unwanted key signatures?

Attachment Size
test_import.mid 218 bytes
test_import.png 18.89 KB

Comments

MIDI was never designed to be a music notation format, and therefore a whole ton needs to be guessed if all MuseScore has to work with is a MIDI file. Since the vast majority of MIDI files won't include a key signature, it makes sense for MuseScore to try to guess one, but if you don't like it, just replace it with the one you want - probably the open/atonal one.

In reply to by Marc Sabatella

"Since the vast majority of MIDI files won't include a key signature, it makes sense for MuseScore to try to guess one"

No, it makes no sense whatsoever. It only makes sense if you assume that: 1. all music is tonal and must necessarily have a key signature, and 2. MuseScore will always be able to "guess" it right. But both assumptions are wrong.

The reality is that, unless it's very simple tonal music, the key signature introduced will be wrong, either because the music doesn't have a key signature, or because it is indeed tonal but more complex than what MS is able to guess.

So, I don't see any sense in introducing a key signature just in case you hit it right, and if not, forcing users to waste lots of time removing or changing key signatures and respelling notes for every single system, because of something that wasn't there in the first place.

The only thing that makes sense if a MIDI file doesn't include a key signature is to leave it alone and let the user decide if a key signature is needed. At most, it could be an option somewhere like "try to guess key signature when importing MIDI". But I don't see it is an option that you can disable.

In reply to by theloni0us

I don't assume "all" music is tonal. Just as I said, the majority. For the atonal music, simply replace the key signature after import. Takes all of a few seconds. Similarly, for the cases where MuseScore guesses wrong, also, takes but seconds to fix. A few seconds once upon import, then it's good for the rest of the hours you spend fixing the various issues that MIDI import entails.

In my experience, though having imported hundreds of MIDI files representing centuries of music, the guesses key signature is correct far more often than it isn't, so it's still beneficial to have it as a starting point. That is, it saves those few seconds more than it costs. But either way, we're talking seconds. You've already more time on this thread than you'll probably spend fixing key signatures this year :-).

In reply to by Marc Sabatella

" You've already more time on this thread than you'll probably spend fixing key signatures this year :-)."

Not really. I'm composing algorithmically, and I have a REPL where I edit my Python script, it generates a bunch of notes, writes the stream(s) to a MIDI file, I open it in MuseScore, listen to it, refine the script, and repeat. Dozens of times every hour.

It's very distracting and annoying to read an atonal, chromatic piece of music with six flats in the key signature and then double flats in the score.

But never mind, I decided to simply avoid the problem. I changed my REPL, I modified my Python library, and I'm going to skip MIDI files altogether.

Anyway, and whatever our subjective perceptions of "majorities" and "few seconds" might be, I would still suggest that guessing the key signature should at least be an option that users can enable or disable, according to their specific use cases.

Thanks for your attention, anyway.

In reply to by Marc Sabatella

That's exactly what I'm doing now.

And to close my rant about MIDI import in MS, you said: "Since the vast majority of MIDI files won't include a key signature, it makes sense for MuseScore to try to guess one." What about MIDI files with a key signature, is it observed?

In the MIDI file attached in my original message, I tried including an explicit C Major keychange message, and you can see what I get in MS. Isn't this a bug?

This is what I see in Rosegarden:

Attachment Size
test_import-rosegarden.png 90.88 KB

In reply to by theloni0us

I'm not sure about key changes mid-score, but initial ones should be recognized, for each instrument individually even as far as I know (that is, a so-called "control track" is not used). I just did a quick test and it worked as expected. Make your your key signature is in the same track as the instrument itself. If you have a MIDI file where a key signature in the instrument track itself is ignored, that would be a bug indeed, but I can't reproduce it with MIDI files I create myself. A quick glance at your file, though, shows the key sign is indeed not in the same track as the instrument.

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