opening a musicxml file seems to mess up the voices

• Aug 8, 2024 - 16:42

Hello,

The scores I let Newzik parse from pdf to musicxml, have their voices mixed up when opened in MuseScore 4. Where notes should be voice 2 on the first staff, musescore shows them as voice 1 of the second staff, but displayed on the 1st staff.

I edited a file to restrict it to 2 measures so that it's easier to show what's going on.

If you open file newzik_file.musicxml in MuseScore 4 (I checked for new versions and got the message: your version is up to date), and select the second staff of the second measure, you'll see that voice 1 is displayed on staff 1. See newzik_file_measure_2.png.

In case you see something different, I saved the file in MuseScore, see newzik_file.mscz.

To compare what's in the xml files, I exported the file as musicxml file, see newzik_file_ms.musicxml.

I compared the note descriptions in the second message, and they both describe the notes of voice 1 in staff 1. Then the files continue with the G half note at the beginning of the first staff.

The original file contains:

           <note>
                <pitch>
                    <step>G</step>
                    <octave>4</octave>
                </pitch>
                <duration>4</duration>
                <voice>2</voice>
                <type>half</type>
                <stem>down</stem>
                <staff>1</staff>
            </note>

That seems ok, however the musescore xml file contains:

<note default-x="34.56" default-y="-30.00">
        <pitch>
          <step>G</step>
          <octave>4</octave>
          </pitch>
        <duration>8</duration>
        <voice>5</voice>
        <type>half</type>
        <stem>down</stem>
        <staff>1</staff>
        </note>

So musescore has changed the note from voice 1 staff 1 to voice 5 staff 1.

Question is: why ? :-).

Now, I have corrected the musescore file in what I expect it to be, see newzik_file_good.mscz, and exported it to musicxml, see newzik_file_ms_good.musicxml.

As said before, first the notes of voice one are described in both files, but then the code differs.

The original file contains:

           <backup>
                <duration>8</duration>
            </backup>
            <note>
                <pitch>
                    <step>G</step>
                    <octave>4</octave>
                </pitch>
                <duration>4</duration>
                <voice>2</voice>
                <type>half</type>
                <stem>down</stem>
                <staff>1</staff>
            </note>
            <note>
                <chord/>
                <pitch>
                    <step>B</step>
                    <octave>4</octave>
                </pitch>
                <duration>4</duration>
                <voice>2</voice>
                <type>half</type>
                <stem>down</stem>
                <staff>1</staff>
            </note>

While the musescore export contains:

<backup>
        <duration>8</duration>
        </backup>
      <note default-x="101.91" default-y="-30.00">
        <pitch>
          <step>G</step>
          <octave>4</octave>
          </pitch>
        <duration>4</duration>
        <voice>5</voice>
        <type>half</type>
        <stem>down</stem>
        <staff>1</staff>
        </note>
      <note default-x="101.91" default-y="-20.00">
        <chord/>
        <pitch>
          <step>B</step>
          <octave>4</octave>
          </pitch>
        <duration>4</duration>
        <voice>5</voice>
        <type>half</type>
        <stem>down</stem>
        <staff>1</staff>
        </note>

So there is a difference in the duration values in the backup and note descriptions.
Does this make musescore mixing things up and introducing voice 5?

If the original file is wrong, I don't expect MuseScore to react the way it does now.
Could it do better :-)?

Thanks!
Luc.


Comments

I don't quite follow your whole argument, but just wanted to mention:
you can exchange voices within a staff: Tools> voices
and voices in different staves using Tools>Explode and Implode

In reply to by elsewhere

Hi, thanks for your reply.

Exchanging voices or implode/explode doesn't help me.

What I need is a way to move cross staffed notes on staff 2 to a note on staff 1 (so the appearance stays the same, but the note belongs to staff 1 instead of staff 2). I'm affraid that can only be done by writing a plugin.

And I'd like to know the algorithm MuseScore uses to decide that a note in a musicxml file is a cross-staffed note. Then I can try to find out if there is an 'error' in the original musicxml file, or MuseScore makes the 'wrong' decission.

When I export the score to musicxml, musescore exports a cross-staffed note of voice one on staff 2 (so the note belongs to staff 2 but is displayed on staff 1) as a note of voice 5 on staff 1. Which I understand since voice 5 is actually a voice 1 note on staff 2. But that is not 'standard' musicxml, at least I didn't find any references, and my original musicxml file doens't contain cross staffed notes.

Thanks,
Luc.

In reply to by Jojo-Schmitz

Hi Jojo,

Thanks for your reply.

What I fail to see is how in newzik_file.musicxml notes are defined as cross-staff notes.
I'm probably overlooking something, how did you come to that conclusion?

I also don't find how cross-staffed notes should be described in musicxml.
Although https://www.w3.org/2021/06/musicxml40/musicxml-reference/elements/staff/ shows a picture of a measure with cross-staffed notes, I can't find any reference to cross-staffed notes.

If it's not defined , then each user of musicxml has to make his own interpretation. I know I have to be careful with using the word 'wrong', in this case it means, not as I exptected :-).

If you look at the score, you wouldn't guess that there are cross-staffed notes in the second measure, it more seems like a voice one and two on staff one and voice one on staff two. It's only when you select the measure that the cross-staffed notes become visible.

Thanks,
Luc.

Answers to the questions in the original post:

Question 1: MuseScore voices are fixed for the whole score and are associated with a staff. When importing MusicXML cross staff voices, it assigns the voice to the staff where it contains the most notes. Thus in your abbreviated Newzik file, the half G4 note is in voice 2 which gets assigned to the first voice in staff 2 by MuseScore (which will be exported as voice 5).

Question 2: the note duration changes in MuseScore's export because Newzik used a different divisions value in measures 1 and 2, while MuseScore uses the same value for both measures. So, no, MuseScore does not mess up anything. The MusicXML exports by Newzik and MuseScore are different, both are correct MusicXML.

In reply to by Leon Vinken

Hello Leon,

Thanks for your reply.
Can you explain 'When importing MusicXML cross staff voices' because I fail to see, based on the musicxml file what notes are cross staffed.

The musicxml file contains the following notes in the second measure:
Voice 1 staff 1 D5 E5 D5 C5 D5 C5
Voice 2 staff 1 G4+B4 F#4
Voice 3 staff 2 G2 D2+D3

'it assigns the voice to the staff where it contains the most notes', voice 2 has 3 notes in staff one, so why is it assigned to staff 2?
And what staff/voices should be in the musicxml to obtain the desired result (i.e. the notes that are now voice one on staff 2 should be voice 2 on staff 1) ?

This is the first time I use Newzik to digitalize my sheet music, normally I use playscore2 and this is the first time that cross-staff notes are added 'out of the blue'.

Thanks,
Luc.

In reply to by lucvdv

Hi Luc,

In file newzik_file.musicxml, voice 2 is on staff 2 in measure 1, but on staff 1 in measure 2. MuseScore assigns voices for the score, not for individual measures. As voice 2 in newzik_file.musicxml contains ten notes on staff 2 but only three on staff 1, every voice 2 note in newzik_file.musicxml is imported by MuseScore into voice 1 on staff 2. This applies to measure 1 and to measure 2. MuseScore does not provide anything to influence this assignment, it just uses what is in the MusicXML file.

Regards, Leon.

In reply to by Leon Vinken

Thanks, Leon!

I just realized this when waking up this morning, but it was too late to correct my comment :-).
It's now clear how it works.

And musescore is self-consistent in the way it handles voices. The attached file has notes in voice 1 of staff 2 and staff 2. If you export it to musicxml and open the result, voice 1 of staff 2 became voice 2 of staff 1 adding an invisible rest for voice 1. One could argue that the voice assignments should remain the same but I think it shows the lack of definition how voices should be handled in musicxml.

It seems that newzik looks at all staffs in one measure at once, and adds voices as long as there are notes with different duration at the same moment. So it means that the voices of the notes in staff 2 depends on the number of voices used in staff 1. What should be voice 1 in staff 2 can be voice 2 in one measure and voice 3 in another.
Since voices are altered during the import of a musicxml file, I'm not sure I can correct them with a plugin.
I'm going to write a perl script that reassigns voices to notes in staff 2 and see if that solves my problem :-).

Thanks,
Luc.

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