For example, I have 2 audios, one is A, and another is B. I want to check whether B appears in A(if part of A is similar to B within some threshold), how many times and what are the exact times B appears. Is there any algorithm? Or some examples have already done the similar thing?
Thanks in advance.
In general terms, you need to perform a cross correlation between the two audio waveforms. If the correlation waveform peaks above a certain threshold value, then you have found a matching pair. This can be achieved in O(n log(n)) time by using techniques based on fast Fourier transforms,
For music content in particular, you can speed things up by using an acoustic fingerprinting technique. The Wikipedia article lists several open-source solutions.