Search for sound clip within larger sound clip
4 views (last 30 days)
Show older comments
I have this small 5-second sound bite which I know exists exactly n-number of times within a larger sound clip (as an exact copy). I need to find a way to "search" the larger sound clip and return the location (as a time) as an output.
I guess you could say it's like sound comparison. I'd like to avoid taking a screenshot of the sound in a program like audacity and compare images.
Any suggestions how to do this?
1 Comment
Sean de Wolski
on 10 Jun 2011
Could you please provides us with a small sample set of data?
Also, look at strfind.
Answers (2)
Daniel Shub
on 10 Jun 2011
A simple solution is to calculate the cross-correlation between the short signal and the long signal.
doc xcorr
The times of the big peaks in the cross-correlation are the times at which the signal occurred. It is a little more difficult than using findstr, but it can handle a little noise. If there is lots of noise, the problem gets harder (but you said it was exact).
If your larger sound clip is too long you will run into some problems, but with cross-correlation you can break it into shorter pieces without any problems.
0 Comments
Matt Fig
on 10 Jun 2011
Here is an example:
% Load three sound clips.
y = load('train');
y2 = load('gong');
y3 = load('handel');
% Make a new one, all three together:
soundclip = [y.y;y2.y;y3.y];
% Play sound to see what happened:
sound(soundclip,y.Fs);
When this is done playing
% Find the gong in soundclip...
idx = findstr(soundclip.',y2.y.') % Returns starting index of gong.
Notice that FINDSTR needs row vectors.
0 Comments
See Also
Categories
Find more on Audio and Video Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!