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 -12
View File
@@ -4,16 +4,16 @@ from pathlib import Path
from generator.guitar import place_guitar
from generator.musicxml import load_musicxml
from generator.parts import PART_TYPES, build_measure, propagated_chords, validate_source
from generator.pitch import concert_document
from generator.parts import PART_TYPES, build_measure, prepare_document, propagated_chords, source_paths
from generator.scat import add_scat
from generator.score import make_arranged_document, reidentify, source_staff, write_json
def practice_document(document: dict, part_type: str) -> dict:
return _practice_document(prepare_document(document, practice=True), part_type)
def _practice_document(document: dict, part_type: str) -> dict:
if part_type not in PART_TYPES:
raise ValueError(f'unknown practice part: {part_type}')
validate_source(document, practice=True)
document = concert_document(document, octave_transposing=True)
staff = source_staff(document)
previous = propagated_chords(staff['measures'])
role = {'acoustic': 'accompaniment', 'electric': 'melody', 'vocal': 'vocal'}[part_type]
@@ -30,17 +30,15 @@ def practice_document(document: dict, part_type: str) -> dict:
return result
def generate_practice_scores(source_dir: Path, output_dir: Path) -> int:
if not source_dir.is_dir():
raise ValueError(f'practice source directory not found: {source_dir}')
sources = sorted(source_dir.rglob('*.xml'))
sources = source_paths(source_dir, practice=True)
for path in sources:
if path.parent != source_dir or len(path.stem) != 3 or not path.stem.isascii() or not path.stem.isdecimal():
raise ValueError(f'{path}: practice sources require a three-digit filename directly under data/practice')
for path in sources:
document = load_musicxml(path)
try:
document = prepare_document(load_musicxml(path), practice=True)
except ValueError as error:
raise ValueError(f'{path}: {error}') from error
for part in PART_TYPES:
try:
write_json(output_dir / path.stem / (part + '.json'), practice_document(document, part))
write_json(output_dir / path.stem / (part + '.json'), _practice_document(document, part))
except ValueError as error:
raise ValueError(f'{path}, part {part}: {error}') from error
return len(sources) * len(PART_TYPES)