Skip to content

Commit 3a531c5

Browse files
authored
Merge pull request #1278 from DDMAL/mei-line-fix
Modifies build_mei_file.py in the MEI Encoding job to be able to encode a variable number of lines, rather than 4 which was previously hard coded in. Additionally implements a temporary fix for pitch errors due to a different number of lines than 4 by adjusting the clef position.
2 parents c9c83a9 + 093183c commit 3a531c5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

rodan-main/code/rodan/jobs/MEI_encoding/build_mei_file.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
# from state_machine import SylMachine #---> for testing locally
2222

23+
staffDef_lines = 4
24+
2325
try:
2426
from rodan.jobs.MEI_encoding import __version__
2527
except ImportError:
@@ -206,7 +208,7 @@ def generate_base_document(column_split_info: Optional[dict]):
206208
staffDef = new_el("staffDef", staffGrp)
207209

208210
staffDef.set("n", "1")
209-
staffDef.set("lines", "4")
211+
staffDef.set("lines", str(staffDef_lines))
210212
staffDef.set("notationtype", "neume")
211213
staffDef.set("clef.line", "4")
212214
staffDef.set("clef.shape", "C")
@@ -246,7 +248,8 @@ def create_primitive_element(xml: Element, glyph: dict, idx: int, surface: Eleme
246248

247249
# ncs, custos do not have a @line attribute. this is a bit of a hack...
248250
if xml.tag == "clef":
249-
attribs["line"] = str(int(float(glyph["strt_pos"])))
251+
#To resolve Rodan issue #1276 (https://github.com/DDMAL/Rodan/issues/1276), moves clef position to fix wrong note offsets due to different numbers of lines than 4
252+
attribs["line"] = str(int(float(glyph["strt_pos"])) + (staffDef_lines - 4))
250253

251254
attribs["oct"] = str(glyph["octave"])
252255
attribs["pname"] = str(glyph["note"])
@@ -819,6 +822,9 @@ def process(
819822
width_multiplier parameter for merging neume components.
820823
"""
821824
staves = reformat_staves(jsomr["staves"])
825+
if staves is not None:
826+
global staffDef_lines
827+
staffDef_lines = staves[0]["num_lines"]
822828
glyphs = jsomr["glyphs"]
823829
syl_boxes = syls["syl_boxes"] if syls is not None else None
824830
median_line_spacing = syls["median_line_spacing"] if syls is not None else None

0 commit comments

Comments
 (0)