computes the zero crossing rate from a time domain signal > called by ::ComputeFeature > > @param x: audio signal > @param iBlockLength: block length in samples > @param iHopLength: hop length in samples > @param f_s: sample rate of audio data (unused) > > @retval vzc zero crossing rate > @retval t time stamp ======================================================================
0001 %computes the zero crossing rate from a time domain signal 0002 %> called by ::ComputeFeature 0003 %> 0004 %> @param x: audio signal 0005 %> @param iBlockLength: block length in samples 0006 %> @param iHopLength: hop length in samples 0007 %> @param f_s: sample rate of audio data (unused) 0008 %> 0009 %> @retval vzc zero crossing rate 0010 %> @retval t time stamp 0011 % ====================================================================== 0012 function [vzc, t] = FeatureTimeZeroCrossingRate(x, iBlockLength, iHopLength, f_s) 0013 0014 % blocking 0015 [x_b, t] = ToolBlockAudio(x, iBlockLength, iHopLength, f_s); 0016 iNumOfBlocks = size(x_b, 1); 0017 0018 % allocate memory 0019 vzc = zeros(1, iNumOfBlocks); 0020 0021 for n = 1:iNumOfBlocks 0022 % compute the zero crossing rate 0023 vzc(n) = 0.5 * mean(abs(diff(sign(x_b(n, :))))); 0024 end 0025 end