Audio Wave: segments = user splits only (721 groups are markers, not segments)
Per clarification: the 721 group lines are clip markers, NOT segments. Segments come ONLY from user split points, numbered globally from 1 — so the first split is seg1, not seg23. 0 splits = 0 segments; N splits = N segments (seg k = point k-1 .. split k, tail after the last split excluded). group lines still drawn (bold) + used for the group#. JS matches (segPoints/nSegs). Empty summary now prompts to add splits. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -108,19 +108,19 @@ def _parse_range(sel, n):
|
||||
|
||||
|
||||
def _segments_grouped(rms_n, times, duration, fps, group_frames, user_starts, beats):
|
||||
"""Segments = user split points UNION the fixed group boundaries (every group_frames
|
||||
frames). The group lines are hard splits, so a segment never crosses one — the last
|
||||
segment in a group ends exactly on the group boundary (e.g. frame 721)."""
|
||||
"""Segments come ONLY from the user's split points (the 721 group lines are just clip
|
||||
markers, NOT segments). Points = [0] + splits; a segment runs between consecutive
|
||||
points, so N splits -> N segments (the tail after the last split is not a segment).
|
||||
Global numbering. `group` = which 721 group each segment starts in (for reference)."""
|
||||
gstep = max(group_frames, 1) / max(fps, 1)
|
||||
gbounds, k = [], 1
|
||||
while k * gstep < duration - 1e-6:
|
||||
while k * gstep < duration - 1e-6: # for drawing + the group number only
|
||||
gbounds.append(round(k * gstep, 3)); k += 1
|
||||
allb = sorted({round(b, 3) for b in list(user_starts) + gbounds if 0 < b < duration - 1e-6})
|
||||
starts = [0.0] + allb
|
||||
pts = [0.0] + sorted({round(s, 3) for s in user_starts if 0 < s < duration - 1e-6})
|
||||
stages = ["establish", "build", "peak", "settle"]
|
||||
segs, bounds = [], [0.0]
|
||||
for i, t0 in enumerate(starts):
|
||||
t1 = starts[i + 1] if i + 1 < len(starts) else duration
|
||||
for i in range(len(pts) - 1): # exclude the tail (last point -> end)
|
||||
t0, t1 = pts[i], pts[i + 1]
|
||||
bounds.append(round(t1, 3))
|
||||
mask = (times >= t0) & (times < t1)
|
||||
e = float(rms_n[mask].mean()) if mask.any() else 0.0
|
||||
|
||||
Reference in New Issue
Block a user