-
Notifications
You must be signed in to change notification settings - Fork 0
Step 2 ‐ Correlation and Offset Detection
This stage compares normalized waveforms from the preparation phase to identify shared temporal patterns across episodes. It detects repeated segments, estimates their relative offsets, and groups them into consistent clusters representing probable intro or outro positions.
This is the computational core of the recognition pipeline. It relies on GPU-accelerated asynchronous and synchronous correlators to perform coarse and fine signal matching efficiently.
-
Normalized Waveform Sequence
- Uniformly sampled and amplitude-normalized arrays produced by Step 1.
-
precision_secsseries_window-
min_segment_length_sec/max_segment_length_sec offset_searcher_sequential_secsadjustment_threshold_secs
The correlation process is performed pairwise across signals. Signals are grouped into sequential windows defined by series_window to limit the number of comparisons. For example, with series_window=5, signal 0 is compared with signals 1 to 4, signal 1 with signals 2 to 5, and so on.
Applied to pairs.
The asynchronous correlator performs a coarse-grained scan across episode pairs. It divides each waveform into fragments and computes correlations independently, allowing non-synchronized episodes to be compared.
Process:
- Each fragment (e.g., 30 seconds block) from episode A is correlated with episode B using FFT convolution.
- For each fragment, the correlation offset with the maximum score is recorded.
- The resulting map of
(offset_A, offset_B, correlation_value)represents coarse similarity positions.
Purpose:
This pass identifies where potential matches exist without requiring global alignment. In other words, it determines how much the second episode must be shifted to align its intro with the first episode's intro.
It is tolerant to time drift or offset differences between episodes and provides high coverage at moderate precision.
Applied to pairs.
The synchronous correlator refines offsets detected during the asynchronous pass. Using those coarse offset estimates as anchors, it performs continuous, time-aligned correlation across synchronized regions.
Process:
- Correlation is computed over uniform temporal windows centered on the candidate offsets.
- Peak correlation values are re-evaluated to verify that signals align coherently.
- The refined offsets are validated and passed to clustering.
Purpose:
Ensures that candidate matches from the asynchronous pass are phase-consistent and statistically stable. It reduces false positives by confirming similarity under strict synchronization constraints.
The found offsets for each signal are collected into a list of (offset_signal_A, offset_signal_B, correlation_value) tuples.
List of clustered offsets representing detected intro/outro positions across episodes, along with correlation statistics.
flowchart TD
A[Normalized Waveforms] --> B["Async Correlator<br>(Coarse GPU Matching)"]
B --> C["Sync Correlator<br>(Fine Alignment)"]
C --> D[Correlation Normalization]
D --> E[Offset Clustering]
E --> F[Clustered Offsets + Statistics]
-
GPU Efficiency: Both correlators use CuPy for GPU acceleration. Batch execution minimizes kernel launch overhead and memory transfers.
-
Dual-Pass Strategy: The asynchronous pass provides wide coverage, detecting candidate matches even when episodes start misaligned. The synchronous pass focuses on precision, refining those candidates within time-consistent windows.
-
Precision vs. Throughput:
precision_secsdirectly affects computational density. Lower values increase detail but multiply GPU workload. -
Numerical Stability: FFT-based correlation avoids convolution edge artifacts. Zero-padding ensures unbiased normalization near signal boundaries.
-
Scalability: Pairwise correlation scales quadratically with number of episodes. The
series_windowparameter limits comparisons to manageable batches. Partial correlations or hierarchical passes can be used for very large datasets. -
Clustering Robustness: Cluster centers are averaged across correlation strength. Low-weight or inconsistent offsets are discarded before interval generation.