📄 endp.m
字号:
function cropped = endp(grabname,Srate)
% takes waveform matrix and detects endpoints, then crops it
% adapted version of 'endpoint.m', part of COLEA speech program (original version within == points)
% freeware, copyright of P.C. Loizou, formerly of UALR, http://www.ualr.edu/www/index.htmlx
x = grabname;
n_samples = length(x);
if (n_samples < 30000)
tryagain; uiwait(tryagain); cropped = 0; return;
end;
% =====================================
% beginning of 'endpoint.m' fragment
n_Secs = n_samples/Srate;
Dur = 10.0;
fSize= Dur*Srate/1000;
nFrames=floor(n_samples/fSize);
k=1;
engy=zeros(1,nFrames);
for i=1:nFrames
y=x(k:k+fSize-1);
engy(i)=10*log10(norm(y));
k=k+fSize;
end;
mx=max(engy); mn=min(engy);
ind=find(engy>(mx-5));
lind=length(ind);
% =====================================
% adapted here
if (lind < 3)
tryagain; cropped = 0; return;
else
onSample=(ind(1)-1)*fSize;
end;
% ======================================
if (ind(lind)-ind(lind-1) > 1)
offSample=(ind(lind-1)-1)*fSize;
else
offSample=(ind(lind)-1)*fSize;
end;
% =====================================
% end of 'endpoint.m' fragment
if (onSample == 0)
onSample = 1;
end;
cropdur = offSample-onSample;
for count = 1:1:cropdur
cropped(count) = x(count+onSample-1);
end;
return;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -