computes the ACF coefficients of 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) > @param eta: index (or vector of indices) of coeff result > > @retval vacf autocorrelation coefficient > @retval t time stamp ======================================================================
0001 %computes the ACF coefficients of 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 %> @param eta: index (or vector of indices) of coeff result 0009 %> 0010 %> @retval vacf autocorrelation coefficient 0011 %> @retval t time stamp 0012 % ====================================================================== 0013 function [vacf, t] = FeatureTimeAcfCoeff(x, iBlockLength, iHopLength, f_s, eta) 0014 0015 % initialization 0016 % these values are arbitrary - adapt to your use case 0017 if (nargin < 5) 0018 eta = 20; 0019 end 0020 0021 % blocking 0022 [x_b, t] = ToolBlockAudio(x, iBlockLength, iHopLength, f_s); 0023 iNumOfBlocks = size(x_b, 1); 0024 0025 % allocate memory 0026 vacf = zeros(length(eta),iNumOfBlocks); 0027 0028 for (n = 1:iNumOfBlocks) 0029 % calculate the acf 0030 if (sum(x_b(n, :)) == 0) 0031 afCorr = zeros(2*size(x_b, 2)+1,1); 0032 else 0033 afCorr = xcorr(x_b(n, :), 'coeff'); 0034 end 0035 afCorr = afCorr((ceil((length(afCorr)/2))+1):end); 0036 0037 % find the coefficients as requested 0038 vacf(1:length(eta),n) = afCorr(eta); 0039 end 0040 end