How to extract information from sound files

5 views (last 30 days)
I have a .wav file. When listening to this file, I can hear a tone then a beep then a tone and this repeats over 1000 times (tone1 - beep1 - tone2 -beep2.....) I want to get separate these. So I want to create separate .wav files for each tone-beep pair such that file1= tone1-beep1, file2 = tone2-beep2 etc. I have no idea where to even begin. Any help will be greatly appreciated

Accepted Answer

Image Analyst
Image Analyst on 7 Dec 2014
If the beep-tone pairs always take the same number of elements, can't you just use reshape() to put each stretch into its own row of a 2D matrix?
% Open standard demo sound that ships with MATLAB.
[theSound, freq] = audioread('guitartune.wav');
numberOfElements = length(theSound);
shortLength = numberOfElements/5;
fprintf('The sound has %d elements.\n', length(theSound));
promptMessage = sprintf('Do you want to play the original sound?');
titleBarCaption = 'Continue?';
button = questdlg(promptMessage, titleBarCaption, 'Yes', 'No', 'Yes');
if strcmpi(button, 'Yes')
% Play the original sound of 661,500 elements.
soundsc(theSound, freq);
end
promptMessage = sprintf('Do you want to play the short sound?');
titleBarCaption = 'Continue?';
button = questdlg(promptMessage, titleBarCaption, 'Yes', 'No', 'Yes');
if strcmpi(button, 'No')
return;
end
% Reshape into 5 rows of 132,300 elements.
soundSegments2D = reshape(theSound, [5, shortLength]);
% Play the sound from row #1
soundsc(soundSegments2D(1, :), freq/5);

More Answers (1)

Star Strider
Star Strider on 6 Dec 2014
I would begin with the Signal Processing Toolbox spectrogram function. That will give you a visual representation of the frequencies and the times they occur. You may have to adjust its parameters to get the resolution you want, considering the number and time density of the tones and beeps, but it should give you some idea.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!