Home > ACA-Code > FeatureTimeMaxAcf.m

FeatureTimeMaxAcf

PURPOSE ^

computes the ACF maxima of a time domain signal

SYNOPSIS ^

function [vta, t] = FeatureTimeMaxAcf(x, iBlockLength, iHopLength, f_s, f_max, fMinThresh)

DESCRIPTION ^

computes the ACF maxima 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)
>
> @retval vta autocorrelation maximum
> @retval t time stamp
 ======================================================================

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %computes the ACF maxima 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 %>
0009 %> @retval vta autocorrelation maximum
0010 %> @retval t time stamp
0011 % ======================================================================
0012 function [vta, t] = FeatureTimeMaxAcf(x, iBlockLength, iHopLength, f_s, f_max, fMinThresh)
0013  
0014     % initialization
0015     % these values are arbitrary - adapt to your use case
0016     if (nargin < 6)
0017         f_max = 2000;
0018     end
0019     if (nargin < 5)
0020         fMinThresh = 0.35;
0021     end
0022     
0023     % blocking
0024     [x_b, t] = ToolBlockAudio(x, iBlockLength, iHopLength, f_s);
0025     iNumOfBlocks = size(x_b, 1);
0026     
0027     % allocate memory
0028     vta = zeros(1, iNumOfBlocks);
0029     
0030     for n = 1:iNumOfBlocks
0031         eta_min = ceil(f_s / f_max);
0032         
0033         % calculate the acf
0034         afCorr = xcorr(x_b(n, :), 'coeff');
0035         afCorr = afCorr((ceil((length(afCorr)/2))+1):end);
0036         
0037         % ignore values until threshold was crossed
0038         eta_tmp = find (afCorr < fMinThresh, 1);
0039         if (~isempty(eta_tmp))
0040             eta_min = max(eta_min, eta_tmp);
0041         end
0042         
0043         % only take into account values after the first minimum
0044         afDeltaCorr = diff(afCorr);
0045         eta_tmp = find(afDeltaCorr > 0, 1);
0046         if (~isempty(eta_tmp))
0047             eta_min = max(eta_min, eta_tmp);
0048         end
0049         
0050         % find the maximum in the computed range
0051         vta(n) = max(afCorr(1+eta_min:end));
0052     end
0053 end

Generated on Fri 22-Apr-2022 20:59:51 by m2html © 2005