Soloing
ci / checks (push) Successful in 1h9m55s

This commit is contained in:
khodowany
2026-10-01 08:35:12 -05:00
parent eae432aa83
commit 75655786e9
16 changed files with 1015 additions and 161 deletions
+11
View File
@@ -3,6 +3,7 @@ from __future__ import annotations
import dataclasses
import fractions
import hashlib
import json
import generator.harmony
import generator.model
@@ -16,6 +17,16 @@ class Analysis:
tempo: fractions.Fraction
melody: tuple[generator.solo.types.Note, ...]
def identity(analysis, measures, part):
anchor = analysis.melody[0].pitch.number() if analysis.melody else 0
melody = [(str(n.start), str(n.end), n.pitch.number() - anchor) for n in analysis.melody]
harmony = []
for measure in measures:
for chord in measure['harmonies']:
pitches = sorted((int(p) - anchor) % 12 for p in generator.harmony.pitch_classes(chord)) if chord['kind'] != 'none' else []
harmony.append((chord['kind'], pitches, chord['onset']))
return hashlib.sha256(json.dumps((part, melody, harmony), sort_keys=True).encode()).hexdigest()
def attacks(document: dict) -> tuple[generator.solo.types.Note, ...]:
"""Collapse tied tones before extracting monophonic melody fragments."""
result, pending = [], {}