diff --git a/src/graph.py b/src/graph.py index 124be70..be0cc1e 100644 --- a/src/graph.py +++ b/src/graph.py @@ -277,9 +277,9 @@ class PathFinder: """Returns continuous score based on melodic threshold. - cents == 0: score = 1.0 (no movement is always ideal) - - Below min (0 < cents < min): score = (cents / min)^2 + - Below min (0 < cents < min): score = (cents / min)^3 - Within range (min <= cents <= max): score = 1.0 - - Above max (cents > max): score = ((1200 - cents) / (1200 - max))^2 + - Above max (cents > max): score = ((1200 - cents) / (1200 - max))^3 Returns product of all voice scores. """ @@ -293,12 +293,13 @@ class PathFinder: product = 1.0 for cents in cent_diffs: - if cents == 0: + abs_cents = abs(cents) + if abs_cents == 0: score = 1.0 - elif cents < melodic_min: - score = (cents / melodic_min) ** 2 - elif cents > melodic_max: - score = ((1200 - cents) / (1200 - melodic_max)) ** 2 + elif abs_cents < melodic_min: + score = (abs_cents / melodic_min) ** 3 + elif abs_cents > melodic_max: + score = ((1200 - abs_cents) / (1200 - melodic_max)) ** 3 else: score = 1.0 product *= score diff --git a/src/harmonic_space.py b/src/harmonic_space.py index 6563a87..4ac4837 100644 --- a/src/harmonic_space.py +++ b/src/harmonic_space.py @@ -258,7 +258,7 @@ class HarmonicSpace: for src_idx, dest_idx in movements.items(): src_pitch = c1.pitches[src_idx] dst_pitch = c2_transposed.pitches[dest_idx] - cents = abs(src_pitch.to_cents() - dst_pitch.to_cents()) + cents = src_pitch.to_cents() - dst_pitch.to_cents() cent_diffs.append(cents) source = list(c1.pitches)