From e13e9ba3bccd4b24291cc5f1ecbd7686bd458f91 Mon Sep 17 00:00:00 2001 From: Michael Winter Date: Thu, 12 Mar 2026 19:19:47 +0100 Subject: [PATCH] Add voice crossing check - reject edges where voices cross - Movement map must be identity (0->0, 1->1, 2->2) to pass - If any voice moves to a different position, weight = 0 --- compact_sets.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/compact_sets.py b/compact_sets.py index e1df171..e82c30f 100644 --- a/compact_sets.py +++ b/compact_sets.py @@ -830,10 +830,14 @@ class PathFinder: if edge_data.get("is_directly_tunable", False): w *= 10 - # Voice crossing weight (prefer no crossing) + # Voice crossing check - reject edges where voices cross if config.get("voice_crossing", False): - # Simplified: prefer edges where more pitches stay in order - w *= 10 + # Check if movement map is identity (0->0, 1->1, 2->2, etc.) + # If any voice moves to a different position, that's a crossing + num_voices = len(edge[0].pitches) + is_identity = all(movements.get(i) == i for i in range(num_voices)) + if not is_identity: + w = 0.0 # Reject edges with voice crossing weights.append(w)