Cleanupf
ci / checks (push) Successful in 1h15m45s

This commit is contained in:
khodowany
2026-09-23 23:54:19 -05:00
parent a0faa9b565
commit da5640291a
24 changed files with 366 additions and 233 deletions
+10 -9
View File
@@ -6,19 +6,19 @@ from pathlib import Path
from generator.arrange.form import full_arrangement_sections
from generator.guitar import place_guitar
from generator.parts import PART_TYPES, build_measure, propagated_chords, validate_source
from generator.parts import PART_TYPES, build_measure, prepare_document, propagated_chords, source_paths
from generator.model import fraction, key_label, make_event, meter_label, rational
from generator.musicxml import load_musicxml
from generator.pitch import concert_document
from generator.score import copy_source_voices, make_arranged_document, reidentify, slugify, source_staff, write_json
FINAL_SECTION_INDEX = 6
def arrange_document(document: dict, part_type: str) -> dict:
return _arrange_document(prepare_document(document), part_type)
def _arrange_document(document: dict, part_type: str) -> dict:
if part_type not in PART_TYPES:
raise ValueError(f'unknown arrangement part: {part_type}')
validate_source(document)
document = concert_document(document, octave_transposing=True)
staff = source_staff(document)
source = staff['measures']
sections = full_arrangement_sections(source, part_type)
@@ -90,14 +90,15 @@ def arrange_document(document: dict, part_type: str) -> dict:
return result
def generate_performance_scores(source_dir: Path, output_dir: Path) -> int:
if not source_dir.exists():
raise ValueError(f'performance source directory not found: {source_dir}')
count = 0
for path in sorted(source_dir.glob('*.xml')):
document = load_musicxml(path)
for path in source_paths(source_dir):
try:
document = prepare_document(load_musicxml(path))
except ValueError as error:
raise ValueError(f'{path}: {error}') from error
for part in PART_TYPES:
try:
write_json(output_dir / f'{slugify(path.stem)}-{part}.json', arrange_document(document, part))
write_json(output_dir / f'{slugify(path.stem)}-{part}.json', _arrange_document(document, part))
except ValueError as error:
raise ValueError(f'{path}, part {part}: {error}') from error
count += 1