Fix voice stay count to match master behavior

Changed voice stay count calculation in Path.step() to compare
by position (position i with position i) instead of tracking
voice identity. This makes dca_voice_movement factor behave
identically to master.
This commit is contained in:
Michael Winter 2026-03-16 02:27:21 +01:00
parent f2b785c98e
commit c682a1df02
2 changed files with 3991 additions and 19 deletions

3987
session-ses_328e.md:q Normal file

File diff suppressed because one or more lines are too long

View file

@ -97,26 +97,11 @@ class Path:
for node in self._node_visit_counts:
self._node_visit_counts[node] += 1
# Update voice stay counts (comparing same voice, not position)
# Update voice stay counts (matching master: compare position i with position i)
for voice_idx in range(len(self._voice_stay_count)):
# Find which position this voice was at in previous chord
prev_voice_pos = None
for pos, voice in enumerate(self._voice_map):
if voice == voice_idx:
prev_voice_pos = pos
break
# Current position of this voice
curr_voice_pos = voice_idx
if prev_voice_pos is not None:
prev_cents = prev_output_chord.pitches[prev_voice_pos].to_cents()
else:
prev_cents = None
curr_cents = output_chord.pitches[curr_voice_pos].to_cents()
if prev_cents is not None and prev_cents == curr_cents:
curr_cents = prev_output_chord.pitches[voice_idx].to_cents()
next_cents = output_chord.pitches[voice_idx].to_cents()
if curr_cents == next_cents:
self._voice_stay_count[voice_idx] += 1
else:
self._voice_stay_count[voice_idx] = 0