Accidentals in MIDI Import

• Aug 25, 2013 - 00:28

1. Open attached MSCZ (produced in 1.3).
2. 'Export...'.
3. Choose 'MIDI'.
4. 'Save'.
5. Open MIDI file.

Desired result: The note is A♭.
Desired result.png

Actual result: The note is G♯.
Actual result.png

Note: The produced MIDI is also attached.

Discussion: I think the MIDI file will only have information about the pitch and not whether it is a flat or sharp, etc. However, I wonder if we can still obtain a better result somehow. I'm not very familiar with this area, but I was looking at page 85 of 'Behind Bars' - I don't know if it is the correct information to look at, though.

Could someone provide some insight regarding conventions, etc?

Using MuseScore 2.0 Nightly Build (b0f01b4) - Mac 10.7.5.


Comments

It's not a notation issue but a music theory issue - the correct spelling depends on musical context, not on any sort of arbitrary notational conventions. It depends on the prevailing harmony (spelling the note to fit the current chord), the nature of the melodic line (chromatic tones in ascendng lines are typically spelled with sharps, descending lines with flats) and also some purely practical considerations for the players (avoid unnecessary Cb's, spelling a line that moves by step so it *looks* like it is moving by step, etc).

Getting it right in all cases, or even most cases, would require some pretty sophistated artificial intelligence and given that even music experts will disagree in some cases, it's really an impossibility.

But there are a few heuristics that could be worth employing. I think the smartest thing would be to go off the key signature and use a table that gives the most commn spelling off each note. There are only five notes to consider: the five notes of the chromatic scale that are not in the key. You'd use the the same basic table transposed for each key, except possibly modified by a user option to favor B over Cb and so forth.

Off the top of my head, and without going into detail into why (but I think any other theorists will recognize my reasoning), I think the table should probably go like this in the key of C:

Use C# instead of Db
*Use Eb instead of D#
Use F# instead of Gb
*Use G# instead of Ab
Use Bb instead of A#

The ones with the asterisk are the ones where this heuristic is probably most likely to be wrong. That is, in the key of C, guessing Bb instead of A# is likely to be right 90% of the time, but guessing G# instead of Ab is more 50/50. This is complicated by the fact that a C major key signature might really mean A minor. In A minor, it's no contest - G# wins for sure, in C major, it's more 50/50. And probably genre-dependent.

In reply to by David Bolton

For the record, the alogirthm was implemented, worked for a while, stopped working, started working again, etc. But it should be good now - I hope.

Also fixed as part of this most recent change is a bug that I think only existed for a brief period, because I don't think the conditions that led to it could have existed before a few weeks ago. The bug was that if you have a MIDI file that include tracks for instruments like clarinet or trumpet that are normally transposing instruments, the transposition info was interpreted incorrectly, so if you press the Concert Pitch buttons, all that happened were some notes changed octaves but pitch classes remained the same (eg, F stays F, just perhaps a different F). Actually, I think they'd play back OK but display wrong.

I believe that we never used to even try to recognize the instrumed to the point of actually setting up transposition, and that this capability was only added shortly before the Beta 2 release with the addition of the some new tags to support it. If I am correct about that, then I believe the bug existed since then. Wouldn't mind hearing from someone more familair with the situation - to confirm there was no transposition at all until a few weeks ago because we weren't even trying to set up it, that transposition never worked properly (playback OK, display wrong upon pressing Concert Pitch), and that my fix does work.

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