@@ -1,9 +1,9 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
import pathlib
|
||||
|
||||
from generator import harmony
|
||||
from generator.musicxml import load_musicxml
|
||||
import generator.harmony
|
||||
import generator.musicxml
|
||||
|
||||
def same(left, right, location: str) -> None:
|
||||
if left != right:
|
||||
@@ -16,9 +16,9 @@ def tuplet_members(staff: dict, identifier: str) -> list:
|
||||
positions = event_positions(staff)
|
||||
return [positions[event['id']] for measure in staff['measures'] for voice in measure['voices'] for event in voice['notes'] if identifier in event.get('tuplet_ids', [])]
|
||||
|
||||
def audit_roundtrip(source: Path, output: Path) -> None:
|
||||
before = load_musicxml(source)['staves'][0]
|
||||
after = load_musicxml(output)['staves'][0]
|
||||
def audit_roundtrip(source: pathlib.Path, output: pathlib.Path) -> None:
|
||||
before = generator.musicxml.load_musicxml(source)['staves'][0]
|
||||
after = generator.musicxml.load_musicxml(output)['staves'][0]
|
||||
before_positions, after_positions = event_positions(before), event_positions(after)
|
||||
before_instruments = {i['id']: i for i in before.get('instruments', [])}
|
||||
after_instruments = {i['id']: i for i in after.get('instruments', [])}
|
||||
@@ -36,7 +36,7 @@ def audit_roundtrip(source: Path, output: Path) -> None:
|
||||
for a, b in zip(original['harmonies'], rendered['harmonies']):
|
||||
for field in ('root', 'bass', 'onset'):
|
||||
same(a.get(field), b.get(field), f'{location} harmony {field}')
|
||||
same(harmony.degrees(a), harmony.degrees(b), f'{location} harmony degrees')
|
||||
same(generator.harmony.degrees(a), generator.harmony.degrees(b), f'{location} harmony degrees')
|
||||
same(len(original['voices']), len(rendered['voices']), f'{location} voice count')
|
||||
for first, second in zip(original['voices'], rendered['voices']):
|
||||
same(len(first['notes']), len(second['notes']), f'{location} voice {first["id"]} event count')
|
||||
|
||||
Reference in New Issue
Block a user