I am new to MATLAB. I have the audio files A and B, B is recorded using a mic while playing audio file A. The length of file B is different from A. A does not always start from 0 second. My program is supposed to identify, file B from file A (giving a set of files A, X, Y, Z, etc. the program can figure out that the most correlation is A) Is there any existing resource or example for my problem? Or any suggestions for me to get start? Appropriate for your any comments and thanks!
Your problem is known as "robust audio fingerprinting", and cross-correlation is not useful for solving it:
- Cross-correlation is computationally expensive for a full-length signal. Not to mention matching a collection of thousands (or even millions in industrial applications) of audio files.
- Your recorded signal B will be different enough from A (additional room noise and reverberation, loss of low and high frequencies) that the raw waveforms will poorly match.
The most common approach for solving this problem on music signals (eg as used by Shazam) is to extract "landmarks" in the spectrogram, which are sharp increases in energy at a specific time/frequency point; and to hash these. Landmark extraction reduces the amount of data to process (from >10k samples per second to 50 or so data points per second), makes the extraction process robust to noise, and yields a data-representation fast to search since it can be quantized and hashed. Matlab implementation here. You have not mentioned what kind of content your audio files have; this technique might not always work for other types of content than music.