thecollabagepatch commited on
Commit
3d79c33
·
1 Parent(s): ca4c65f

i declare debugging war

Browse files
Files changed (1) hide show
  1. jam_worker.py +17 -0
jam_worker.py CHANGED
@@ -26,6 +26,17 @@ def _dbg_rms_dbfs(x: np.ndarray) -> float:
26
  r = float(np.sqrt(np.mean(x * x) + 1e-12))
27
  return 20.0 * np.log10(max(r, 1e-12))
28
 
 
 
 
 
 
 
 
 
 
 
 
29
  # -----------------------------
30
  # Data classes
31
  # -----------------------------
@@ -469,6 +480,9 @@ class JamWorker(threading.Thread):
469
  # ------------------------------------------
470
  if self._pending_tail_model is not None and self._pending_tail_model.shape[0] == xfade_n and xfade_n > 0 and n_samps >= xfade_n:
471
  head = s[:xfade_n, :]
 
 
 
472
  t = np.linspace(0.0, np.pi/2.0, xfade_n, endpoint=False, dtype=np.float32)[:, None]
473
  cosw = np.cos(t, dtype=np.float32)
474
  sinw = np.sin(t, dtype=np.float32)
@@ -517,6 +531,7 @@ class JamWorker(threading.Thread):
517
  # ------------------------------------------
518
  if xfade_n > 0 and n_samps >= (2 * xfade_n):
519
  body = s[xfade_n:-xfade_n, :]
 
520
  if body.size:
521
  y_body = to_target(body.astype(np.float32))
522
  if y_body.size:
@@ -528,6 +543,7 @@ class JamWorker(threading.Thread):
528
  # If chunk too short for head+tail split, treat all (minus preroll) as body
529
  if xfade_n > 0 and n_samps > xfade_n:
530
  body = s[xfade_n:, :]
 
531
  y_body = to_target(body.astype(np.float32))
532
  if y_body.size:
533
  # DEBUG: body RMS in short-chunk path
@@ -542,6 +558,7 @@ class JamWorker(threading.Thread):
542
  # Tail (always remember how many TARGET samples we append)
543
  if xfade_n > 0 and n_samps >= xfade_n:
544
  tail = s[-xfade_n:, :]
 
545
  y_tail = to_target(tail.astype(np.float32))
546
  Ltail = int(y_tail.shape[0])
547
  if Ltail:
 
26
  r = float(np.sqrt(np.mean(x * x) + 1e-12))
27
  return 20.0 * np.log10(max(r, 1e-12))
28
 
29
+ def _dbg_rms_dbfs_model(x: np.ndarray) -> float:
30
+ # x is model-rate, shape [S,C] or [S]
31
+
32
+ if x.ndim == 2:
33
+ x = x.mean(axis=1)
34
+ r = float(np.sqrt(np.mean(x * x) + 1e-12))
35
+ return 20.0 * np.log10(max(r, 1e-12))
36
+
37
+ def _dbg_shape(x):
38
+ return tuple(x.shape) if hasattr(x, "shape") else ("-",)
39
+
40
  # -----------------------------
41
  # Data classes
42
  # -----------------------------
 
480
  # ------------------------------------------
481
  if self._pending_tail_model is not None and self._pending_tail_model.shape[0] == xfade_n and xfade_n > 0 and n_samps >= xfade_n:
482
  head = s[:xfade_n, :]
483
+
484
+ print(f"[model] head len={head.shape[0]} rms={_dbg_rms_dbfs_model(head):+.1f} dBFS")
485
+
486
  t = np.linspace(0.0, np.pi/2.0, xfade_n, endpoint=False, dtype=np.float32)[:, None]
487
  cosw = np.cos(t, dtype=np.float32)
488
  sinw = np.sin(t, dtype=np.float32)
 
531
  # ------------------------------------------
532
  if xfade_n > 0 and n_samps >= (2 * xfade_n):
533
  body = s[xfade_n:-xfade_n, :]
534
+ print(f"[model] body len={body.shape[0]} rms={_dbg_rms_dbfs_model(body):+.1f} dBFS")
535
  if body.size:
536
  y_body = to_target(body.astype(np.float32))
537
  if y_body.size:
 
543
  # If chunk too short for head+tail split, treat all (minus preroll) as body
544
  if xfade_n > 0 and n_samps > xfade_n:
545
  body = s[xfade_n:, :]
546
+ print(f"[model] body(S) len={body.shape[0]} rms={_dbg_rms_dbfs_model(body):+.1f} dBFS")
547
  y_body = to_target(body.astype(np.float32))
548
  if y_body.size:
549
  # DEBUG: body RMS in short-chunk path
 
558
  # Tail (always remember how many TARGET samples we append)
559
  if xfade_n > 0 and n_samps >= xfade_n:
560
  tail = s[-xfade_n:, :]
561
+ print(f"[model] tail len={tail.shape[0]} rms={_dbg_rms_dbfs_model(tail):+.1f} dBFS")
562
  y_tail = to_target(tail.astype(np.float32))
563
  Ltail = int(y_tail.shape[0])
564
  if Ltail: