Two fundamental problems, one minor issue

• Apr 10, 2015 - 21:35

I searched the forum and didn't see these bugs listed.

I loaded a MIDI file of a string quartet, and MuseScore did a great job setting it up as a score. But when I set the key to C minor (three flats) many notes were assigned as sharps rather than their enharmonic flat notes. So I started changing them to flats, then Saved what I had so far. When I opened the score again they were all back to sharps! I tried this several times with the same result.

Another problem is using Save As saves the current file to a folder above the one it loaded from. My .mscz file was loaded from:

D:\Scores\Saturday Night\

But MuseScore wants to save it to:


I attached the score so you can see the problem. The G# in Bar 4 of the Violin 1 should be an Ab, with no flat needed since that's part of the key. The F# in Bar 7 of Violin 2 should be a Gb, and there the flat is needed.


Attachment Size
Score.mscz 52.03 KB


The bug with the "J" command not surviving save/load is a known issue with 2.0 that only affects concert pitch instruments and only when *not* in concert pitch mode. So the workaround for now is to switch to concert pitch mode to do your respelling. There are actually a couple of threads and a bug report in the issue tracker discussing this. It's fixed in the latest nightly build. See #51886: Enharmonic change made using "J" on concert pitch instrument not saved, and also, for example.

However, you shouldn't have been having to do as much of this as you seem to be. If the key signature of C minor is recorded properly in the MIDI file, then MuseScore should already spell notes as Ab rather than G#. The forum thread referenced above discusses a similar issue that as far as I know only affects MIDI files created by from one particular program, and my best guess is that this program is creating the files either incorrectly or else in a less common internal format that MuseScore isn't recognizing correctly.

So, do you know what program created the MIDI file you are trying to import? Can you post the MIDI file itself? Do realize MIDI is generally a poor choice for import because it contain much, much less information than the preferred import format, MusicXML. But we do try to do as well as we can.

Or maybe you mean, there was no key signature originally, so you added one later? If so, then indeed, you will need to respell the pitches yourself - that doesn't happen automatically.

The quick fix is to select all, hit up arrow to transpose up a half step, then down to transpose back down. This will respell all accidentals with flats. Not that this is really exactly what you want. The F# you mention, for example, really *should* be an F#, not a Gb. At least, "most" F#'s in the key of C minor really should be F#'s and not Gb's, since it's the leading tone of the dominant. Maybe that one is an exception because it occurs in a different harmonic context. But anyhow, MuseScore isn't very smart about such things.

As for Save As, the last Save As folder is remembered separately from the default Open folder. That's a feature - makes it easy to go through a whole folder of files loading them one at a time and saving them all into a new folder together. If you wish to save back to the original folder, simply navigate there the first time, and then subsequent Save As operations will also go there.

In reply to by Marc Sabatella

Thanks very much for the detailed and *prompt* reply! I really like this program, and I'm glad to help by reporting bugs.

This project is an old MIDI file I exported from Master Tracks Pro many years ago, before Passport Designs went out of business the first time. I picked this file just to see how MuseScore works. (A lot of my other MIDI files are complex productions.) I have no idea if the key of C minor is embedded in the file! Assuming the key is not in the file, is there a way to tell MuseScore the same information after the MIDI file is loaded?

I found Concert Pitch mode on the Note menu. It was already checked. So I unchecked it, checked it again, and now my edits to change sharp notes to their enharmonic equivalents are indeed saved. So this is a different bug I guess, that Concert Pitch was in effect but not recognized until I turned it Off then On again. The F# (and other sharp notes) really are supposed to be flat. This is a very chromatic piece that cycles through many different chords.

Thanks for the Save As explanation. That makes sense and is a good feature!

Attachment Size
Saturday Night.mid 25.83 KB

In reply to by Ethan Winer

I can reproduce the problem where the key signature in this MIDI file is not honored for some reason. I see three flats when I import it, so the information *is* clearly there in the file, but the note spelling is not honoring this. It could be the same as the issue in that other thread I mentioned, not sure. I do know that "normally" key signature *is* honored when importing MIDI files, but somehow, your file and the one in that other thread must be unusual in some way that causes this not to work.

In fact, simply loading that MIDI file into 2.0, then immediately exporting it to MIDI again, then importing *that* MIDI file, produces the expected results! So apparently the way Master Tracks Pro exports key signature info is different from how MuseScore itself does. This provides another workaround, one that gives you the spellings you should have had in the first place. Looks pretty good, actually.

As for Concert Pitch, yes, it is under the notes menu. but there is also the big Concert Pitch button on the right hand side of the toolbar. My guess is you pressed that accidentally at some point, because Concert Pitch would *not* normally be enabled by default. If you can show a specific and reproducible sequence of events where you do see it being enabled by default, do post the precise steps to reproduce it, but my guess is, it was just an accident.

And yes, I do understand that based on the context, the some of the F#'s in this piece should be Gb, but that kind of information is not present in a MIDI file. Which is one reason (among many) why MIDI should be consider a "last resort" only, not something to rely on when communicating between different notation programs unless you have no choice, and you must be prepared to accept that there is a lot of decisions to be made where MuseScore will simply have to guess, because the relevant information is not present in a MIDI file. Enharmonic spellings are but one example of this. So MuseScore has algorithm to allow it to guess on how to spell any given accidental, and sometimes that guess will be right, other times wrong.

But again, it should not have happened with regard to G#/Ab in the key of C minor. That is not an accidental - it is in the key. So MuseScore should have spelled it Ab, not G#, and it does, if you export to MIDI then re-import it. Thus lending support to my guess that there is something unusual / unexpected about how the key signatures are represented in these particular files.

In reply to by Marc Sabatella

That's a heckuva technique, bring it in, export to midi, and reimport! (Uh, why isn't "respell pitches" equivalent?) I wish we had thought of that earlier. But that's three files from different sources that seem to have the same problem. Clearly, any of these files is worth further introspection.

MuseScore ought to have a tool or tools that operate on only pitches or notes specified, e.g., a dialog that would allow me to say "convert all G#'s on this staff (perhaps in the selected region) to Ab's and nothing else." Ideally, Midi import should offer an optional dialog of how you want each and every one of the five "black notes" spelled; this business of guessing/negotiating/crowdsourcing accidentals is no solution. Often, in one portion of a piece, G is G natural, but in another, F double sharp, so this needs to be by region.

We who import from Midi usually have no choice about format; the importation process could still use a lot of help in this regard.

In reply to by [DELETED] 1831606

I don't understand exactly what Respell Pitches does - the algorithm looks like black magic to me. Maybe something where it looks for ascending passagers to spell with sharps, descending to spell with flats. Maybe also looking for different spellings of the same pitch within the same measure and changing them to be consistent. That sort of thing. It definitely does not seem to be a simple spell-according-to-key-signature as on initial import.

As I said before, I could try to look with a simpel example. But the current examples have too much going on. I'd want a single note, so I could set a breakpoint at the place where it is spelled and trace what is happening. Someone with a better understanding of MIDI file format and/or the current code might be able to do better with the current examples.

In reply to by Marc Sabatella

Wait a minute --- aren't you a maintainer? If you don't know, who does? I'm not trying to be disrespectful, but trying to understand the support model here.

With respect to "respell pitches", if its action is incomprehensible, perhaps it should be replaced by something comprehensible and well-defined. Again, a filter on which pitches you wanna respell would be optimal. I think I've suggested before that a "spell according to key signature" would be useful (different varieties/options of "respell pitches"?)

In reply to by [DELETED] 1831606

I've worked on some portions of the code, but MIDI import is a black box to me. There are literally dozens of source files in the "importmidi" folder, and I've never looked at any of them. The "support model" here is, MuseScore is open source. Anyone with the necessary skills can step in and make improvements in areas that interest them. And it generally works best if people who don't understand a section of code don't risk making things worse by stepping in and trying to make changes when there are others better equipped to do so.

That said, when I did a search just now on the issue tracker to find the issue for this, I found another issue I submitted on someone else's behalf a few months ago that I had forgotten all about but might be related - see #44226: Initial key signature not transposed via dialog on imported MIDI file. That gave me enough to go on to do a little more investigating with the debugger, and I am posting my findings back to your issue.

As for respell pitches, the *code* is incomprehensible. For all I know the action would be clearly describable in two sentences. i just don't know. Again, not an area of code I've looked at.

In reply to by Marc Sabatella

Like the solution to a crossword puzzle or a factoring problem, even if the answer is easily expressible, if its value is not computable, it's obscure(d). If we can't determine what respell pitches does, even if it might be simply described, the case for replacing it is made.

I do have significant programming skills and might at some time investigate this or contribute myself, but not right now (not enough time).

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