view Code/Descriptors/Matlab/Common/removeSilentData.m @ 3:e1cfa7765647

initial commit - this file calculates the basic set of metrics (mean, variance, min and max, from an array of supplied data.
author Dawn Black <dawn.black@eecs.qmul.ac.uk>
date Mon, 10 Sep 2012 09:20:12 +0100
parents ea0c737c6323
children
line wrap: on
line source
function [ silentFrames ] = removeSilentData( silentSegments, noOfFrames )

%---------------- GET THE SILENT FRAME VALUES -------------------
% only wish to consider values from voiced frames.
% silent frames will produce data values that
% are random and therefore will bias our results
% returns an array of values where '1' indicates a non-silent frame

    silentFrames = zeros(1,noOfFrames);
    [m n] = size(silentSegments);
    if(  silentSegments(1,1) == 0 && silentSegments(1,2) == 0 )
        % we have only one segment - the entire file
        silentSegments(1,1) = 1;
        silentSegments(1,2) = floor(length(x)/frameLength);
        [m n] = size(silentSegments);
    end
    
    % check for start at sample 0
    if( silentSegments(1,1) == 0)
        silentSegments(1,1) = 1;
    end
    
    for i=1:m
        start = silentSegments(i,1);
        stop = silentSegments(i,2);
        if( stop > noOfFrames )
            stop = noOfFrames;
            silentSegments(i,2) = noOfFrames;
        end
            
        if( start == 0 ) 
            start = 1;
        end
        
        
        silentFrames( start : stop ) = 1;
    end
    
end