|
20 | 20 |
|
21 | 21 | # from state_machine import SylMachine #---> for testing locally |
22 | 22 |
|
| 23 | +staffDef_lines = 4 |
| 24 | + |
23 | 25 | try: |
24 | 26 | from rodan.jobs.MEI_encoding import __version__ |
25 | 27 | except ImportError: |
@@ -206,7 +208,7 @@ def generate_base_document(column_split_info: Optional[dict]): |
206 | 208 | staffDef = new_el("staffDef", staffGrp) |
207 | 209 |
|
208 | 210 | staffDef.set("n", "1") |
209 | | - staffDef.set("lines", "4") |
| 211 | + staffDef.set("lines", str(staffDef_lines)) |
210 | 212 | staffDef.set("notationtype", "neume") |
211 | 213 | staffDef.set("clef.line", "4") |
212 | 214 | staffDef.set("clef.shape", "C") |
@@ -246,7 +248,8 @@ def create_primitive_element(xml: Element, glyph: dict, idx: int, surface: Eleme |
246 | 248 |
|
247 | 249 | # ncs, custos do not have a @line attribute. this is a bit of a hack... |
248 | 250 | 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)) |
250 | 253 |
|
251 | 254 | attribs["oct"] = str(glyph["octave"]) |
252 | 255 | attribs["pname"] = str(glyph["note"]) |
@@ -819,6 +822,9 @@ def process( |
819 | 822 | width_multiplier parameter for merging neume components. |
820 | 823 | """ |
821 | 824 | staves = reformat_staves(jsomr["staves"]) |
| 825 | + if staves is not None: |
| 826 | + global staffDef_lines |
| 827 | + staffDef_lines = staves[0]["num_lines"] |
822 | 828 | glyphs = jsomr["glyphs"] |
823 | 829 | syl_boxes = syls["syl_boxes"] if syls is not None else None |
824 | 830 | median_line_spacing = syls["median_line_spacing"] if syls is not None else None |
|
0 commit comments