Is there a difference measure that is insensitive to shifts?
Time scattering by design yields timeshift-invariant representations, with control over amount of desired invariance. An advantage is ability to compare within a frequency range of interest rather than in entirety.
It's the continuous wavelet transform, followed by modulus and lowpass filtering; nice lecture.

Distance with T=2048: 0.022988
Distance with T=1024: 0.172749
Distance with T=512:  0.415810


Code
Can only run from a dev branch, library's renovating for next release.
import numpy as np
import scipy.signal
from kymatio import Scattering1D
from kymatio.visuals import plot, imshow

def _l2(x):
    return np.sqrt(np.sum(np.abs(x)**2))

def l2(x0, x1):
    &quot;&quot;&quot;Squared relative distance measure.&quot;&quot;&quot;
    return _l2(x1 - x0) / _l2(x0)

#%% configure scattering &amp; signal ############################################
N = 4096
Q = 16
J = 9
width = N//8
shift = N//8
# set amounts of invariance
T0, T1 = N//4, N//8
freq_fracs = (4, 8, 16, 32)

#%% make signal &amp; shifted ####################################################
window = scipy.signal.tukey(width, alpha=0.5)
window = np.pad(window, (N - width) // 2)
t  = np.linspace(0, 1, N, endpoint=False)
x  = np.sum([np.cos(2*np.pi * N/ff * t) for ff in freq_fracs], axis=0
            ) * window
xs = np.roll(x, shift)

#%% visualize signals ########################################################
plot(x,  title=&quot;x, original&quot;,    show=1)
plot(xs, title=&quot;x, timeshifted&quot;, show=1)

#%% make scattering objects ##################################################
max_order = 1  # 2 yields better results but requires understanding; see docs
kw = dict(J=J, Q=Q, shape=N, average=1, out_type=&quot;array&quot;, pad_mode=&quot;zero&quot;,
          max_pad_factor=1, frontend='numpy', max_order=1)
ts0 = Scattering1D(T=T0, **kw)
ts1 = Scattering1D(T=T1, **kw)
#%% scatter 
out0_x  = ts0.scattering(x)
out0_xs = ts0.scattering(xs)
out1_x  = ts1.scattering(x)
out1_xs = ts1.scattering(xs)

#%% compute &amp; print distances ################################################
l2_0 = l2(out0_x, out0_xs)
l2_1 = l2(out1_x, out1_xs)
print(&quot;Distance with T={}: {:.6f}&quot;.format(T0, l2_0))
print(&quot;Distance with T={}: {:.6f}&quot;.format(T1, l2_1))

#%% visualize coeffs
imshow(out0_x,  title=&quot;scattering(x), original    | T=%s&quot; % T0, abs=1)
imshow(out0_xs, title=&quot;scattering(x), timeshifted | T=%s&quot; % T0, abs=1)
imshow(out1_x,  title=&quot;scattering(x), original    | T=%s&quot; % T1, abs=1)
imshow(out1_xs, title=&quot;scattering(x), timeshifted | T=%s&quot; % T1, abs=1)