Carry a re-engraved slice's notation in the bundle
A replaced slice shipped as pixels only, so the LilyPond behind it died with the project file — and a project is spent once exported. Correcting one wrong note meant retyping the system. Slices gain an optional `engraving` object: the language, key, time and one entry per voice holding the notes and lyrics verbatim. Structured per staff rather than one blob of source, because that is what both a later edit and a MIDI render want; song-level key and time are resolved per slice so reading one needs no context from its neighbours. Additive and ignorable, so the format stays at version 1.
This commit is contained in:
@@ -22,6 +22,8 @@ from noteman_slicer.project import ( # noqa: E402
|
||||
Cut,
|
||||
Marker,
|
||||
Project,
|
||||
Replacement,
|
||||
Voice,
|
||||
default_path,
|
||||
)
|
||||
|
||||
@@ -91,6 +93,29 @@ def main() -> int:
|
||||
assert slices[1]["markers"][0] == {"type": "coda"}
|
||||
assert slices[0]["markers"][1] == {"type": "to_coda", "destination": 1}
|
||||
|
||||
# A re-engraved slice carries its notation into the bundle; a scanned one
|
||||
# carries none. This is what makes a later edit or a MIDI render possible
|
||||
# from the bundle alone.
|
||||
project.key, project.time = "aes", "3/4"
|
||||
page.replacements[second] = Replacement(
|
||||
voices=[Voice("treble", "c4 d e f", "la la la la"), Voice("bass", " c4 d e f ", " ")]
|
||||
)
|
||||
engraved = song_json(project, names)["slices"]
|
||||
assert "engraving" not in engraved[0], "a scanned slice has no notation"
|
||||
ly = engraved[1]["engraving"]
|
||||
assert ly["lang"] == "lilypond"
|
||||
# Song defaults are resolved per slice: reading one slice needs no context.
|
||||
assert (ly["key"], ly["time"], ly["print_time"]) == ("aes", "3/4", False)
|
||||
assert ly["voices"][0] == {"clef": "treble", "notes": "c4 d e f", "lyrics": "la la la la"}
|
||||
assert "lyrics" not in ly["voices"][1], "an empty field is absent, not empty"
|
||||
assert ly["voices"][1]["notes"] == "c4 d e f"
|
||||
|
||||
override = Replacement(voices=page.replacements[second].voices, key="d", print_time=True)
|
||||
page.replacements[second] = override
|
||||
ly = song_json(project, names)["slices"][1]["engraving"]
|
||||
assert (ly["key"], ly["time"], ly["print_time"]) == ("d", "3/4", True)
|
||||
page.replacements[second] = None
|
||||
|
||||
# A jump whose target got discarded is dropped, not exported dangling.
|
||||
project.pages[0].discards[second] = True
|
||||
dropped = song_json(project, ["001.webp"])
|
||||
|
||||
Reference in New Issue
Block a user