MATLAB Answers

Isolate a period of a sound

2 views (last 30 days)
George on 3 Dec 2013
Hey, I have an array of over 100K values from a wavread audio file with a pretty high sampling rate. It is the sound of a dog barking 4 times. I would like to isolate 1 bark. I've tried filtering the data so that everything beneath a signal value of 0.05 goes to 0 and everything above goes to 1. It looks like a step function, except for the fact that there are values in between that are also 0. I would like to just isolate 1 period, but I don't know how to get the indices of the FINAL drop from 1 to 0. ... not the ones in the middle.
Here's what I've tried, thanks in advance!:
%% read in the file and isolate 1 sound [Y, FS] = wavread('Bark');
%% Isolate one sound period Yabs = abs(Y); % absolute value of signal figure(999);plot(Yabs) %visualize for n = 1:length(Yabs); if Yabs(n) > 0.05; Yabs(n) = 1; else Yabs(n) = 0; %filter low signal end end
figure(888); plot(Yabs); %visualize filtered signal
% tol = 50; % for n = 1:length(Yabs-tol) % if Yabs(n+tol)-Yabs(n) == 1 % indstart = n-750; % -750 to grab the rest of the signal beneath the threshold % end % if Yabs(n+tol)-Yabs(n) == -1 % indend = n+tol; % break % end % end
Period = [indstart, indend]
Ysolo = Y(Period(1):Period(2));
% Ysolo is the isolated period.


Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by