BoxOfColors commited on
Commit
3faf5c6
·
1 Parent(s): 977875e

fix: move segment color boundary to crossfade midpoint

Browse files

Color edge was at seg[i+1].start (crossfade begins) but should be at
seg[i+1].start + crossfade/2 — the 50/50 blend point, which matches
where the cut would be with no crossfade and where listeners perceive
the transition.

Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -1711,11 +1711,12 @@ def _build_waveform_html(audio_path: str, segments: list, slot_id: str,
1711
  ctx.fillRect(0, 0, W, H);
1712
 
1713
  segments.forEach(function(seg, idx) {{
1714
- // Draw only each segment's unique (non-overlapping) region:
1715
- // from its start up to the next segment's start, or its own end if last.
 
1716
  const x1 = (seg[0] / duration) * W;
1717
  const xEnd = idx + 1 < segments.length
1718
- ? (segments[idx + 1][0] / duration) * W
1719
  : (seg[1] / duration) * W;
1720
  ctx.fillStyle = segColors[idx % segColors.length];
1721
  ctx.fillRect(x1, 0, xEnd - x1, H);
 
1711
  ctx.fillRect(0, 0, W, H);
1712
 
1713
  segments.forEach(function(seg, idx) {{
1714
+ // Color boundary = midpoint of the crossfade zone = where the blend is
1715
+ // 50/50. This is also where the cut would land if crossfade were 0, and
1716
+ // where the listener perceptually hears the transition to the next segment.
1717
  const x1 = (seg[0] / duration) * W;
1718
  const xEnd = idx + 1 < segments.length
1719
+ ? ((segments[idx + 1][0] + crossfadeSec / 2) / duration) * W
1720
  : (seg[1] / duration) * W;
1721
  ctx.fillStyle = segColors[idx % segColors.length];
1722
  ctx.fillRect(x1, 0, xEnd - x1, H);