MusicXML - transposing instrument parts
Background
If a MusicXML file includes a part for a transposing instrument not notated at "concert pitch" (sounding pitch), as for a player's part, the code must include a transpose element. That element must include a chromatic subelement, which gives (in semitones) the interval between the encoded note pitches and their sounding pitches. This is sufficient to allow the receiving program to play the part at the intended sounding pitch.
But if the receiving program wishes to offer the display of the received part at concert pitch, there can be a dilemma as to how any resulting accidentals are spelled.
To resolve this, MusicXML allows (and even encourages, but does not require) the including in the transpose element of a second subelement, diatonic. This, together with the value of chromatic, defines the "named interval" (e.g., "perfect fourth") that the originating notation program would have used to display this transposed part at concert pitch. The numerical base of the pitch name is one more than the value of diatonic. Thus, if diatonic is 4, the transposition interval is one of those with "fifth" in its name.
Which of the "fifths" (perfect fifth or augmented fifth) is meant is discerned from the value of chromatic. Thus if diatonic is 4, and chromatic is 7, the transposition interval is perfect fifth. if diatonic is 4, and chromatic is 8, the transposition interval is augmented fifth. Only certain combinations of the values of diatonic and chromatic are meaningful. If diatonic is 4, for chromatic, only values of 7 and 8 (as used in the example above) are meaningful. (There are only two named intervals with "fifth" in their name.)
In MuseScore
For a MusicXML part that carries a transpose element with both diatonic and chromatic subelements, MuseScore in fact chooses the intended named interval to transpose the received part into concert pitch notation (when the Concert Pitch button is ON) as the originating program/scorist intended.
But if the element does not contain a diatonic subelement (which is perfectly legitimate under the MusicXML specification), MuseScore (perhaps understandably) treats the value of diatonic as zero. This means that MuseScore proceeds as if the intended interval for transposing the part to concert pitch is one with "unison" in its name. But that could only be correct if chromatic were 0 (no transposition, in which case we would need no transpose element) or 1 (if the named interval were augmented unison).
The result is that, of we ask MuseScore to show us this received transposed part at concert pitch, we may well have a "correct", but bizarre, transposition, perhaps full of double flats or sharps.
A better algorithm
It would be better if, when a received MusicXML file contains for a part a transpose element with a chromatic subelement but no diatonic subelement, MuseScore would treat the value of diatonic as one that was meaningful given the value of chromatic, probably the one that, with the value of chromatic, would imply a named interval of the "perfect", "major", or "minor" families. The exception would be for a chromatic value of 6 (a six semitone interval), for which there is no named interval of any of those qualities. There, an arbitrary choice would have to be made between inferring that the named interval were diminished fifth or augmented fourth.
Doing this would require a small lookup table working from the value of chromatic (or actually that value modulo 12, to deal with values of chromatic that were greater than an octave).
Doug
Comments
To illuminate the issue I will use a test score with a part for Bb trumpet, a transposing instrument. It has the transposition interval that MuseScore intially applies for that instrument, down a major second.
Here we see it in the originating program (MuseScore), set to show it at player pitch:
and here with MuseScore set to show it at concert pitch:
I export this as a MusicXML file (being careful to do so the Concert Pitch OFF; with Concert Pitch ON, the MusicXML code is anomalous.)
Now my MuseScore takes on the role of the receiving program, and I import the MusicXML file. With MuseScore set to show the score on a player pitch basis, we see this:
and here with MuseScore set to show it at concert pitch:
Note that this transposition to concert pitch is done the same way as it was done in the originating program.
I make a copy of the MusicXML file and delete the diatonic subelement. Imported into MuseScore, set to show it on a player pitch basis, we see this:
and seen on a concert pitch bais:
Note that now the concert pitch rendition, albeit "accurate", is not the same as was used at the originating program,. and in fact is not what I would call "handsome". This is a result of the fact that MuseScore, faced with a part in MusicXML that carries a transpose element but not the optional diatonic subelement, chooses (by default) transposition by a named interval that is not possibly the one used at the originating end (I would call it "doubly augmented unison", "unison" because the transposed notes are on the same staff position as the original note).
Alan
In reply to To illuminate the issue I… by Doug Kerr
I realized this morning (while still in bed!) that my original characterization of MuseScore's behavior when receiving in a MusicXML file a part for a transposed instrument in which the element did not contain a element (as of course is permitted by the MusicXML specification). was incorrect.
I indicated that MuseScore in such cases behaved as if were 0 and thus used a certain named transposition from the encoded pitch to concert pitch. Of course that named transposition would be meaningless for all but one value of , so that could not have been correct.
Further testing (and more thoughtful analysis!) indicates that MuseScore, in the absence of a element, in fact behaves the same as if were 0, but that does not lead to the use of a fixed named transposition to transpose from the encoded pitch to concert pitch.
Seemingly, the transposition used is in affected (in some sort of "zone" scheme) by the value of , but I have not yet done enough tests to fully characterize this. But it does not seem to follow the plan I recommended for this.
In any case, in the cases I have tested so far, the transposition used did not produce the "most handsome" result. They include unnecessary (and in some case, redundant) accidentals and often include double accidentals.
More later.
My apologies for the error in my original essay.
Doug
In reply to I realized this morning … by Doug Kerr
It seems that the transposition algorithm used by MuseScore when there is no element does not draw upon its normal transposition behavior under any "named interval". It is apparently something unique to this situation.
As I mentioned above, the result in many cases to me does not seem to be the "most handsome".
Doug