I have looked at the audio visualization example posted a long time ago, but it isn’t exactly what I’m looking for.
Any more details on that?
If you have a string of discrete samples (obviously a problem in itself
), you can represent them as a sum of cosine and sine waves:
a1 * cos(0) + b1 * sin(0) + a2 * cos(wavelength1) + b2 * sin(wavelength1) + …
where the wavelengths are multiples of pi, according to how many samples you provide.
b1 is irrelevant but shown for consistency. If all your samples are alike, only a1 will be non-0 and will have that value.
You can figure out all those a1 , b1 , etc. coefficients with stuff like the Discrete Fourier Transform (this is what the “fft2048” is in the audio visualization sample, assuming I’m looking at the one you refer to).
Once you’re in this frequency space it’s easy to do something called convolution (which back in samples-land is a bit like a smearing average of two groups of samples) just by multiplying the complex number pairs (e.g. a1 , b1 ), where your other set of samples would match some reference pattern, like the beat you want to match. Then you can invert the result and see if any of the spikes line up with your samples.