MeasuringPolyphony / mp_editor

https://editor.measuringpolyphony.org
4 stars 2 forks source link

Issue with System Ordering #95

Closed martha-thomae closed 2 years ago

martha-thomae commented 2 years ago

Sometimes the order of the systems gets inverted and I cannot figure out why this is happening. Would you mind taking a look at this, @JRegimbal?

Here is an example. This MEI Parts file comes from MuRET (everything is fine here, all systems are in the proper order).

MuRET.zip

When I upload it to the MP Editor, everything seems fine, but two systems are already inverted as one can see if downloading the MEI Parts file from the MP Editor (the code is shown at the end of this issue). When I move into the Score Editor, the inversion of the systems is obvious from the rendered music. You can see this in the folio 20v, in the 4th and 5th systems of that page. The MP Editor thinks that the 5th system goes before the 4th one.

Score Editor: inverted systems

Again, the issue happens since the Input Editor because it is already present in the MEI Parts file exported from the MP Editor as shown below:

Lines 422-477 from the MEI Parts file exported from the MP Editor. As can be seen here the s5 is being placed before the s4 (see last <syl> elements, which are meant to label the systems in MuRET).

<sb facs="#m9e20e261-6055-4176-93ea-f38211258536" xml:id="spb_330"/>
<clef xml:id="clef_331" shape="G" line="2"/>
<rest xml:id="PART0_A620" dur="brevis"/>
<rest xml:id="PART0_A629" dur="minima"/>
<note xml:id="PART0_A633" dur="minima" oct="4" pname="g">
    <verse xml:id="m-c42e1726-42aa-49a4-80b3-510ae6093460" color="black" n="1">
        <syl xml:id="m-e3e2fccc-322d-4323-894a-e8f6cd934fb5" con="b">20v.jpg,</syl>
        <syl xml:id="m-ce0e5068-815f-45fc-b7fd-4427db4a9f45" con="b">p1,</syl>
        <syl xml:id="m-f2ce72c9-e987-4150-ad90-05e6100c562f">s5</syl>
    </verse>
</note>
<note xml:id="PART0_A639" dur="minima" oct="4" pname="a"/>
<dot xml:id="m-9fceefa8-d465-44d5-8eb9-34b626d05cd7"/>
<note xml:id="PART0_A644" dur="semiminima" oct="4" pname="b"/>
<note xml:id="PART0_A645" dur="minima" oct="5" pname="c"/>
<note xml:id="PART0_A649" dur="minima" oct="5" pname="d"/>
<note xml:id="PART0_A651" dur="minima" oct="5" pname="e"/>
<note xml:id="PART0_A654" dur="minima" oct="5" pname="f"/>
<dot xml:id="m-cd6ec970-f8f5-4d92-80fb-5e94bb8ca4fe"/>
<note xml:id="PART0_A658" dur="semiminima" oct="5" pname="e"/>
<note xml:id="PART0_A660" dur="semiminima" oct="5" pname="d"/>
<note xml:id="PART0_A664" dur="semiminima" oct="5" pname="c"/>
<note xml:id="PART0_A668" dur="semibrevis" oct="5" pname="d"/>
<barLine xml:id="m-719d2508-a398-490b-8787-bbe44b7519bb" form="invis"/>
<sb facs="#m3bf9f544-7538-4e19-aa37-0ea1cdd1ede7" xml:id="spb_323"/>
<clef xml:id="clef_324" shape="G" line="2"/>
<note xml:id="PART0_A543" dur="semibrevis" oct="5" pname="e">
    <verse xml:id="m-15acd291-a1a6-4084-acc0-7b2bf9adc0ec" color="black" n="1">
        <syl xml:id="m-20b23aec-d5ed-478e-b9d8-c9944591614c" con="b">20v.jpg,</syl>
        <syl xml:id="m-100129e9-5a09-4247-9007-2008775411b5" con="b">p1,</syl>
        <syl xml:id="m-09f9fe85-add6-40ab-9d51-48551dd7d85a">s4</syl>
    </verse>
</note>
<rest xml:id="PART0_A548" dur="minima"/>
<note xml:id="PART0_A550" dur="minima" oct="4" pname="a"/>
<note xml:id="PART0_A553" dur="minima" oct="4" pname="a"/>
<note xml:id="PART0_A557" dur="minima" oct="4" pname="a"/>
<note xml:id="PART0_A560" dur="semibrevis" oct="5" pname="e"/>
<note xml:id="PART0_A565" dur="minima" oct="5" pname="f"/>
<dot xml:id="m-75555843-f14f-445b-bcf2-d9531957e264"/>
<note xml:id="PART0_A569" dur="semiminima" oct="5" pname="e"/>
<note xml:id="PART0_A570" dur="semiminima" oct="5" pname="d"/>
<note xml:id="PART0_A573" dur="semiminima" oct="5" pname="c"/>
<note xml:id="PART0_A575" dur="semibrevis" oct="5" pname="d"/>
<note xml:id="PART0_A579" dur="minima" oct="5" pname="c"/>
<note xml:id="PART0_A582" dur="semibrevis" oct="4" pname="b"/>
<rest xml:id="PART0_A586" dur="semibrevis"/>
<note xml:id="PART0_A591" dur="semibrevis" oct="5" pname="d"/>
<dot xml:id="m-7fe924b2-4d40-4f20-8b7c-2de085b92b78"/>
<note xml:id="PART0_A599" dur="minima" oct="5" pname="d"/>
<note xml:id="PART0_A602" dur="semibrevis" oct="5" pname="c"/>
<note xml:id="PART0_A606" dur="brevis" oct="5" pname="f"/>
<note xml:id="PART0_A610" dur="semibrevis" oct="5" pname="f"/>
<note xml:id="PART0_A614" dur="semibrevis" oct="5" pname="e"/>
<barLine xml:id="m-903e7b50-70fd-4e26-9f70-17f0f7e76dbb" form="invis"/>
<pb facs="#m-7978caca-0983-4e35-a5f3-b659d37704a9" xml:id="spb_337"/>

I am attaching here the MP Editor Parts and Score MEI files obtained when uploading the original MuRET file. MP-Editor.zip

I don't know the internal logic for ordering the systems, but would you mind taking a look at it please? What could be causing the inversion of these systems when one is evidently lower than the other? Thanks, @JRegimbal!

martha-thomae commented 2 years ago

I see that the <zone> elements are also inverted when looking at the facsimile part.

martha-thomae commented 2 years ago

If it is useful, the zones inverted are given by the following encoding in MuRET:

4th system:

<zone xml:id="region_31363" ulx="148" uly="541" lrx="1146" lry="722" type="region" label="staff"/>

5th system:

<zone xml:id="region_31364" ulx="147" uly="662" lrx="1142" lry="867" type="region" label="staff"/>

The @uly coordinate clearly indicates that system 5 goes below system 4, but maybe they are ordered given the @ulx value?


And they are definitely inverted in the <facsimile> of the MEI Parts file exported by the MP Editor:

<zone xml:id="m9e20e261-6055-4176-93ea-f38211258536" ulx="147" uly="662" lrx="1142" lry="867"/>
<zone xml:id="m3bf9f544-7538-4e19-aa37-0ea1cdd1ede7" ulx="148" uly="541" lrx="1146" lry="722"/>

with the zone of system 5 appearing before that one of system 4

JRegimbal commented 2 years ago

The logic is in src/app/utils/system.ts. If there's intersection between systems on the y-axis, they're assumed to be side-by-side and the left-most system is ordered first. Otherwise the highest system is ordered first. Since the systems intersect on the y-axis pretty significantly, system 5 (with 147 ulx) is placed first.

The only easy alternative I can see is having the y-axis intersection also be conditioned on there not being significant x-axis intersection, though I'm unsure if that would break something else. Are you okay with that?

martha-thomae commented 2 years ago

I think that solution will work perfectly in this case and also in general. I don't anticipate any issues with it. Thank you, Juliette!