Add Reseed & Generate button; adjust voice movement weights

This commit is contained in:
Michael Winter 2026-04-19 01:34:56 +02:00
parent a377558f89
commit 3b68c1a49e
2 changed files with 15 additions and 5 deletions

View file

@ -176,8 +176,10 @@ class Path:
next_cents = destination_chord.pitches[voice_idx].to_cents() next_cents = destination_chord.pitches[voice_idx].to_cents()
if curr_cents != next_cents: if curr_cents != next_cents:
change_after[voice_idx] += 1 change_after[voice_idx] += 1
if change_after[voice_idx] >= threshold: else:
change_after[voice_idx] = 0 change_after[voice_idx] = sustain_after[voice_idx] / 10
if change_after[voice_idx] >= (threshold*1):
change_after[voice_idx] = sustain_after[voice_idx] / 10
step = PathStep( step = PathStep(
source_node=source_node, source_node=source_node,
@ -268,7 +270,7 @@ class Path:
if target_norm: if target_norm:
w *= target_norm[i] * config.get("weight_target_register", 1) w *= target_norm[i] * config.get("weight_target_register", 1)
step.weight = w**8 step.weight = w**16
weights.append(w) weights.append(w)
step.normalized_scores = { step.normalized_scores = {
@ -388,7 +390,7 @@ class Path:
if current_cents[voice_idx] != candidate_cents[voice_idx]: if current_cents[voice_idx] != candidate_cents[voice_idx]:
sum_changing += sustain_counts[voice_idx] sum_changing += sustain_counts[voice_idx]
return sum_changing return sum_changing**2
def _factor_rgr_voice_movement( def _factor_rgr_voice_movement(
self, self,
@ -421,7 +423,7 @@ class Path:
if current_cents[voice_idx] != candidate_cents[voice_idx]: if current_cents[voice_idx] != candidate_cents[voice_idx]:
sum_repeating += change_counts[voice_idx] sum_repeating += change_counts[voice_idx]
return sum_repeating return sum_repeating**8
def _factor_harmonic_compactness( def _factor_harmonic_compactness(
self, self,

View file

@ -483,6 +483,7 @@
</div> </div>
<div class="buttons"> <div class="buttons">
<button type="button" id="reseedGenerateBtn">Reseed & Generate</button>
<button type="button" id="generateBtn">Generate</button> <button type="button" id="generateBtn">Generate</button>
<button type="button" id="viewBtn">View</button> <button type="button" id="viewBtn">View</button>
<button type="button" id="transcribeBtn" class="primary">Transcribe</button> <button type="button" id="transcribeBtn" class="primary">Transcribe</button>
@ -625,6 +626,13 @@
} }
} }
function reseedAndGenerate() {
const newSeed = Math.floor(Math.random() * 999999) + 1;
document.getElementById('seed').value = newSeed;
generate();
}
document.getElementById('reseedGenerateBtn').addEventListener('click', reseedAndGenerate);
document.getElementById('generateBtn').addEventListener('click', generate); document.getElementById('generateBtn').addEventListener('click', generate);
document.getElementById('viewBtn').addEventListener('click', viewChords); document.getElementById('viewBtn').addEventListener('click', viewChords);
document.getElementById('transcribeBtn').addEventListener('click', transcribe); document.getElementById('transcribeBtn').addEventListener('click', transcribe);