Add --target-register-power option to curve target register progression

This commit is contained in:
Michael Winter 2026-03-26 15:41:41 +01:00
parent 8ea5c4fe0c
commit 74aa937ec2
2 changed files with 10 additions and 1 deletions

View file

@ -362,6 +362,12 @@ def main():
default=0, default=0,
help="Target register in octaves (default: disabled, 2 = two octaves)", help="Target register in octaves (default: disabled, 2 = two octaves)",
) )
parser.add_argument(
"--target-register-power",
type=float,
default=1.0,
help="Power to curve target register progress (1=linear, 2=quadratic, etc.)",
)
parser.add_argument( parser.add_argument(
"--allow-voice-crossing", "--allow-voice-crossing",
action="store_true", action="store_true",
@ -604,6 +610,7 @@ def main():
weights_config["target_register"] = True weights_config["target_register"] = True
weights_config["target_register_octaves"] = args.target_register weights_config["target_register_octaves"] = args.target_register
weights_config["weight_target_register"] = args.weight_target_register weights_config["weight_target_register"] = args.weight_target_register
weights_config["target_register_power"] = args.target_register_power
else: else:
weights_config["weight_target_register"] = 0 # disabled weights_config["weight_target_register"] = 0 # disabled

View file

@ -371,12 +371,14 @@ class Path:
target_octaves = config.get("target_register_octaves", 2.0) target_octaves = config.get("target_register_octaves", 2.0)
max_path = config.get("max_path", 50) max_path = config.get("max_path", 50)
target_cents = target_octaves * 1200 target_cents = target_octaves * 1200
power = config.get("target_register_power", 1.0)
start_avg_cents = sum(p.to_cents() for p in path_chords[0].pitches) / len( start_avg_cents = sum(p.to_cents() for p in path_chords[0].pitches) / len(
path_chords[0].pitches path_chords[0].pitches
) )
progress = len(path_chords) / max_path progress = len(path_chords) / max_path
current_target = start_avg_cents + (progress * target_cents) progress_curve = progress**power
current_target = start_avg_cents + (progress_curve * target_cents)
current_chord = path_chords[-1] current_chord = path_chords[-1]
current_avg_cents = sum(p.to_cents() for p in current_chord.pitches) / len( current_avg_cents = sum(p.to_cents() for p in current_chord.pitches) / len(