function [ibegin,iend,sambegin,samend]=hearsegm (s,vad,lseg,rseg); % functions with the OLD format of VAD files % Syntax: [ibegin, iend, sambegin, samend]=hearsegm(s,vad,lseg,rseg); % or: [ibegin, iend, sambegin, samend]=hearsegm(s,vad); % % % Hear the segment of signal, separated by beeps. % s - signal vector % vad - parameter vector % lseg - segment length (default 160) % rseg - overlapping (default 0) % ibegin - frames, where the active parts BEGIN % iend - frames, where the active parts END % sambegin - samples, where the active parts BEGIN % samend - samples, where the active parts END if(nargin==2), lseg=160; rseg=0; end wsh=lseg-rseg; % find the beginnings and ends of segments: ibegin=find ( ([vad 0] - [0 vad]) == 1 ); iend=find ( ([vad 0] - [0 vad]) == -1 )-1; % generate short sinus for separate ss=4000 * sin( 2*pi*[0:200]*1000 / 8000); ss2=4000 * sin( 2*pi*[0:200]*2000 / 8000); sambegin=[]; samend=[]; % cycle on the segments for i=1:length(ibegin), write8000('/tmp/rien', ss); begin=(ibegin(i)-1) * wsh + 1; eend=(iend(i)-1) * wsh + lseg; write8000('/tmp/rien', s(begin:eend) ); sambegin=[sambegin begin]; samend=[samend eend]; end write8000('/tmp/rien',ss2);