Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MEI Encoding job does not allow for staves with any number of lines other than four #1271

Open
martha-thomae opened this issue Mar 21, 2025 · 1 comment
Labels
MEI Encoding Issues pertaining to MEI Encoding rodan job

Comments

@martha-thomae
Copy link

MEI Encoding job has harcoded the value of the lines to be equal to 4 (@lines=4) for the <staffDef> element, which makes it impossible to have staves of any other number of lines.

The number of lines should be taken from the MEI Encoding's input port that receives the JSOMR file coming from the Heuristic Pitch Fiding (which in turn comes from the Miyao Staff Finding job, where one can use the job's settings to set the number of staff lines). This is an example of the JSOMR information (coming out of the Heuristic Pitch Finding) that is received by the MEI Encoding job. See the lines that read "num_lines": 5,, this parameter is the one that should be used to fix the @lines attribute in the MEI Encoding job. Right now, this number of lines is overwritten to four.

{
   "page": {"resolution": 0.0, "bounding_box": {"ncols": 3888, "nrows": 2592, "ulx": 0, "uly": 0}}, 
   "staves": [
      {"staff_no": 1, 
       "bounding_box": {"ncols": 1144, "nrows": 126, "ulx": 665, "uly": 605}, 
       "num_lines": 5, 
       "line_positions": [[[665, 560], [740, 560], [925, 558], [1110, 555], [1296, 550], [1481, 550], [1666, 549], [1809, 549]], [[665, 588], [740, 588], [925, 586], [1110, 583], [1296, 578], [1481, 578], [1666, 577], [1809, 577]], [[665, 616], [740, 616], [925, 614], [1110, 611], [1296, 606], [1481, 606], [1666, 605], [1809, 605]], [[665, 644], [740, 644], [925, 644], [1110, 640], [1296, 637], [1481, 634], [1666, 633], [1809, 632]], [[665, 673], [740, 672], [925, 672], [1110, 671], [1296, 665], [1481, 664], [1666, 664], [1809, 664]], [[665, 703], [740, 703], [925, 701], [1110, 697], [1296, 694], [1481, 693], [1666, 694], [1809, 694]], [[665, 731], [740, 731], [925, 730], [1110, 727], [1296, 725], [1481, 724], [1666, 725], [1809, 727]], [[665, 759], [740, 759], [925, 758], [1110, 755], [1296, 753], [1481, 752], [1666, 753], [1809, 755]], [[665, 787], [740, 787], [925, 786], [1110, 783], [1296, 781], [1481, 780], [1666, 781], [1809, 783]]]
       }, 
       {"staff_no": 2, 
        "bounding_box": {"ncols": 1205, "nrows": 126, "ulx": 667, "uly": 797}, 
        "num_lines": 5, 
        "line_positions": [[[667, 749], [740, 749], [925, 748], [1110, 744], [1296, 743], [1481, 742], [1666, 742], [1851, 741], [1871, 741], [1872, 741]], [[667, 777], [740, 777], [925, 776], [1110, 772], [1296, 771], [1481, 770], [1666, 770], [1851, 769], [1871, 769], [1872, 769]], [[667, 805], [740, 805], [925, 804], [1110, 800], [1296, 799], [1481, 798], [1666, 798], [1851, 797], [1871, 797], [1872, 797]], [[667, 833], [740, 833], [925, 833], [1110, 829], [1296, 828], [1481, 826], [1666, 824], [1851, 823], [1871, 822], [1872, 822]], [[667, 863], [740, 862], [925, 862], [1110, 861], [1296, 859], [1481, 857], [1666, 856], [1851, 856], [1871, 856], [1872, 856]], [[667, 893], [740, 893], [925, 892], [1110, 890], [1296, 889], [1481, 886], [1666, 886], [1851, 888], [1871, 888], [1872, 888]], [[667, 923], [740, 923], [925, 922], [1110, 920], [1296, 919], [1481, 917], [1666, 917], [1851, 917], [1871, 917], [1872, 917]], [[667, 953], [740, 953], [925, 952], [1110, 950], [1296, 949], [1481, 947], [1666, 947], [1851, 947], [1871, 947], [1872, 947]], [[667, 983], [740, 983], [925, 982], [1110, 980], [1296, 979], [1481, 977], [1666, 977], [1851, 977], [1871, 977], [1872, 977]]]
       },
       ...
    ]
    "glyphs": [
       {"pitch": {"staff": "1", "offset": "674", "strt_pos": "3", "note": "None", "octave": "None", "clef_pos": "None", "clef": "None"}, "glyph": {"bounding_box": {"ncols": 20, "nrows": 71, "ulx": 674, "uly": 623}, "state": "MANUAL", "name": "clef.c"}}, 
       {"pitch": {"staff": "1", "offset": "725", "strt_pos": "9", "note": "a", "octave": "3", "clef_pos": "7", "clef": "clef.c"}, "glyph": {"bounding_box": {"ncols": 23, "nrows": 21, "ulx": 725, "uly": 666}, "state": "MANUAL", "name": "neume.punctum"}}, 
       {"pitch": {"staff": "1", "offset": "740", "strt_pos": "8", "note": "b", "octave": "3", "clef_pos": "7", "clef": "clef.c"}, "glyph": {"bounding_box": {"ncols": 22, "nrows": 37, "ulx": 740, "uly": 647}, "state": "MANUAL", "name": "neume.virga"}}, 
       ...
    ]
} 

I am including the whole file here too in case you want to use it eventually to test the fix in the MEI Encoding (together with the CSV file that goes in the other input port of the job).

Heuristic Pitch Finding - JSOMR of glyphs, staves, and page properties.json

SQUAREnotation-NClevel.csv

@martha-thomae martha-thomae added the MEI Encoding Issues pertaining to MEI Encoding rodan job label Mar 21, 2025
@DeannaLC
Copy link

It looks like the generate_base_document function which has code for staffDef.set("lines", "4") only currently has the parameter column_split_info, and I'm not sure if it contains the data for the number of lines. It looks like if you pass in the staff data and extract that, the number of lines can be extracted from the JSOMR file.

I have a local copy where I've altered lines 170, 212, and 584 from the original code to the following which adds in staves, and it seems to do the trick with the files provided.

Image
Image
Image

Output (file was originally .mei but changed it to .txt so it could be attached here):
MEI Encoding - MEI.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MEI Encoding Issues pertaining to MEI Encoding rodan job
Projects
None yet
Development

No branches or pull requests

2 participants