It will work when you take the 2nd gradient of the signals:
import numpy as np
from scipy import signal
s0 = np.gradient(np.gradient(s0))
s1 = np.gradient(np.gradient(s1))
np.argmax(signal.correlate(s0, s1)) -> 525358
That corresponds to a shift of 1071 which is close to your expected 1069
Interestingly the minimum (most negative correlation) is close ...
You are having trouble because that's not a Costas loop. A Costas loop uses demodulated data in some form to change the phase that's expected from the signal.
You're just taking the I/Q demodulated signal and applying it to the atan2 function; that makes a sort of linearized extended phase detector, but without determining that the phase should have ...
It seems like your error jumps to -$\pi$ and then to $\pi$
I think you need to unwrap your phase. Let me explain with an example
Say that the output of atan2 block is $\pi - 0.001$ and then the phase difference increases by 0.002 rad, the outuput of the atan 2 block should then be $\pi$ + 0.001, however the atan2 output is limited to ±$\pi$. Therefore the ...
Container formats are usually storing video and sound information in chunks that are supposed to be triggered at the same time. In turn, each chunk might further be compressed according to the specifications of a given CODEC.
For example, consider a video at $FPS=30$ with its sound sampled at $Fs = 48kHz$.
In this example, one frame of the video sequence (...