Before starting, let me say I'm not a mathematician, I'm just a curious engineer, with a master's degree in engineering and computer science.
I have been using this book The Scientist and Engineer's Guide to Digital Signal Processing for years, as I developed many audio applications throughout my life.
This book has been very useful to me, but recently I have been struggling with correlation between signals.
Suppose I have a discrete signal $S$, with a length of $N$ samples in the time domain (where $N > 10000$). Along with that, I have another signal, $S2$ with a length of $1024$ samples, also in the time domain.
Both $S$ and $S2$ consist of samples with amplitude ranging from -128 to 127.
If I want to figure out if $S2$ appears within $S$, even in the presence of a background noise, I can use correlation. That correlation can be implemented in a way similar to a convolution (according to Chapter 7 of that book), to produce a third signal, the cross-correlation of the two input signals, which I will call $C$.
Now, how should I interpret the cross-correlation $C$, in order to extract the real useful information out of it, that is: is $S2$ present in $S$, and if so, at which sample of $S$ does $S2$ start?
The cross-correlation machine moves across the signal $S$ searching for similarities with the pattern of the shorter target signal $S2$, to assess whether it is contained in $S$. To achieve this, the original and the target waveforms $S$ and $S2$ are aligned in a given point of $S$, and then the product of the simultaneous samples is obtained. This operation is then repeated multiple times after the target waveform $S2$ has been moved (leftward or rightward) and re-aligned in other points of $S$. After a high number of operations, the whole original waveform $S$ has been completely explored. The sum of all products obtained in this way is then used to build the cross-correlation signal $C$. The amplitude of each sample in $C$ indicates how much $S2$ resembles the original signal $S$, exactly in that location. So, you have to check whether $C$ has peaks: each peak shows that $S$ and $S2$ are aligned with a similar pattern, and then indicates that $S2$ appears in $S$ in that location.