How to extract information from sound files
5 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Image Analyst
2014-12-7
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);
0 个评论
更多回答(1 个)
Star Strider
2014-12-6
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio and Video Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!