In cima a Via dell'Antica Posta si arriva sotto la console dell'underground (il marciapiede di destra, fino in fondo); sotto una console le altre calano fino al loro filo, così lì si sente la sola musica di quella (Andrea)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GiECd9RWGMKV7n3K1mdy8T
This commit is contained in:
2026-10-31 15:09:45 +01:00
co-authored by Claude Opus 5.5
parent 04f9a5cb12
commit 23aa9c4788
3 changed files with 27 additions and 7 deletions
+10 -5
View File
@@ -26,12 +26,17 @@ export function trackFor(story, { screen, scene, phase, closeup, at, ok = () =>
}
// Il volume di ogni console: pieno fino a `near` pixel, poi cala fino a `far` (non sotto un filo, `floor`: la festa
// si sente sempre). La più forte per prima.
// si sente sempre). Sotto una console (entro `near`, sfumando fino a una volta e mezzo) le altre calano fino al loro
// filo: lì si sente bene la sola musica di quella (Andrea, 31 ottobre, in cima a Via dell'Antica Posta). La più forte
// per prima.
export function mix(stages, [x, y]) {
return stages.map(st => {
const d = Math.hypot(x - st.at[0], (y - st.at[1]) * 1.5), near = st.near ?? 90, far = st.far ?? 520;
const k = Math.max(0, Math.min(1, (d - near) / (far - near)));
return { src: st.music, gain: Math.max(st.floor ?? 0.08, (1 - k) ** 1.6) };
const near = st => st.near ?? 90, floor = st => st.floor ?? 0.08;
const d = stages.map(st => Math.hypot(x - st.at[0], (y - st.at[1]) * 1.5));
const under = stages.map((st, i) => Math.max(0, Math.min(1, (near(st) * 1.5 - d[i]) / (near(st) * 0.5))));
return stages.map((st, i) => {
const far = st.far ?? 520, k = Math.max(0, Math.min(1, (d[i] - near(st)) / (far - near(st))));
const others = Math.max(0, ...under.filter((_, j) => j !== i));
return { src: st.music, gain: Math.max(floor(st), (1 - k) ** 1.6 * (1 - others)) };
}).sort((a, b) => b.gain - a.gain);
}