From 1a2deb88a00a2bfd3d30611443df62b73266af2d Mon Sep 17 00:00:00 2001 From: Honney OC Date: Tue, 15 Sep 2026 21:03:37 +0000 Subject: [PATCH] fix: pad delayed signal instead of trimming leading samples in apply_lag --- verify_sync.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/verify_sync.py b/verify_sync.py index 0cd5d00..72d8294 100644 --- a/verify_sync.py +++ b/verify_sync.py @@ -103,12 +103,14 @@ def extract_audio_from_mkv(mkv_path: str, stream_index: int, out_wav: str, sr: i def apply_lag(a: np.ndarray, b: np.ndarray, lag_samples: int) -> tuple[np.ndarray, np.ndarray]: if lag_samples >= 0: - a_out = a[lag_samples:] + # B is delayed by lag_samples — pad B with silence, A stays in place b_out = np.concatenate([np.zeros(lag_samples, dtype=np.float32), b]) + a_out = a else: + # A is delayed by |lag_samples| — pad A with silence, B stays in place pad = -lag_samples a_out = np.concatenate([np.zeros(pad, dtype=np.float32), a]) - b_out = b[pad:] + b_out = b ml = min(len(a_out), len(b_out)) return a_out[:ml], b_out[:ml]