Package
ci / checks (push) Successful in 48m34s

This commit is contained in:
khodowany
2026-09-30 19:46:37 -05:00
parent 2a1aa2c67a
commit 09656a9d60
6621 changed files with 698 additions and 774 deletions
+7 -7
View File
@@ -44,7 +44,7 @@ def write_json(path: pathlib.Path, document: dict) -> None:
path.write_text(json.dumps(document, indent=2, ensure_ascii=False) + '\n', encoding='utf-8')
def slugify(value: str) -> str:
return re.sub(r'[^a-z0-9]+', '-', value.strip().lower()).strip('-') or 'score'
return re.sub(r'[^a-z0-9]+', '_', value.strip().lower()).strip('_') or 'score'
def source_staff(document: dict) -> dict:
if len(document.get('staves', [])) != 1:
@@ -71,9 +71,9 @@ def copy_source_voices(measure: dict, *, strip_lyrics: bool) -> list[dict]:
def make_measure(measure_id: str, source: dict, notes: list[dict], *, section_label: str = '') -> dict:
result = copy.deepcopy(source)
result.update({'id': measure_id, 'section_label': section_label, 'voices': [{'id': 'voice-arranged', 'notes': notes}]})
result.update({'id': measure_id, 'section_label': section_label, 'voices': [{'id': 'voice_arranged', 'notes': notes}]})
for note in notes:
note['voice'] = 'voice-arranged'
note['voice'] = 'voice_arranged'
return result
def reidentify(measures: list[dict], source_tuplets: list[dict]) -> list[dict]:
@@ -82,14 +82,14 @@ def reidentify(measures: list[dict], source_tuplets: list[dict]) -> list[dict]:
tuplets = []
for measure in measures:
for hi, harmony in enumerate(measure.get('harmonies', [])):
harmony['id'] = f'{measure["id"]}-h{hi + 1}'
harmony['id'] = f'{measure["id"]}_h{hi + 1}'
for ni, note in enumerate(measure_notes(measure)):
old = note['id']
note['id'] = f'{measure["id"]}-n{ni + 1}'
note['id'] = f'{measure["id"]}_n{ni + 1}'
event_map[old] = note['id']
for pi, pitch in enumerate(note['pitches']):
old_pitch = pitch['id']
pitch['id'] = f'{note["id"]}-p{pi + 1}'
pitch['id'] = f'{note["id"]}_p{pi + 1}'
tone_map[old_pitch] = pitch['id']
for measure in measures:
for note in measure_notes(measure):
@@ -111,7 +111,7 @@ def reidentify(measures: list[dict], source_tuplets: list[dict]) -> list[dict]:
if not members:
continue
t = copy.deepcopy(source)
t.update({'id': f'{measures[0]["id"]}-{source["id"]}', 'start': members[0]['id'], 'end': members[-1]['id'], 'continued_start': source['start'] not in event_map, 'continued_end': source['end'] not in event_map})
t.update({'id': f'{measures[0]["id"]}_{source["id"]}', 'start': members[0]['id'], 'end': members[-1]['id'], 'continued_start': source['start'] not in event_map, 'continued_end': source['end'] not in event_map})
for n in members:
n['tuplet_ids'] = [t['id'] if v == source['id'] else v for v in n['tuplet_ids']]
tuplets.append(t)