pyACA: Documentation 0.3.1
Source Code for Audio Content Analysis
Loading...
Searching...
No Matches
Functions
pyACA.FeatureTimeMaxAcf Namespace Reference

Functions

 FeatureTimeMaxAcf (x, iBlockLength, iHopLength, f_s, f_max=2000, fMinThresh=0.35)
 finds the maximum of the ACF of an audio signal
 

Function Documentation

◆ FeatureTimeMaxAcf()

FeatureTimeMaxAcf ( x,
iBlockLength,
iHopLength,
f_s,
f_max = 2000,
fMinThresh = 0.35 )

finds the maximum of the ACF of an audio signal

Parameters
xarray with floating point audio data (dimension samples x channels)
iBlockLengthblock length in samples
iHopLengthhop length in samples
f_ssample rate of audio data
f_maxmaximum frequency to look at (default: 2000)
fMinThreshminimum threshold for avoidance of main lobe (default: 0.35)
Returns
vta: autocorrelation maximum
t: time stamp

Definition at line 18 of file FeatureTimeMaxAcf.py.

18def FeatureTimeMaxAcf(x, iBlockLength, iHopLength, f_s, f_max=2000, fMinThresh=0.35):
19
20 # create blocks
21 x_b, t = pyACA.ToolBlockAudio(x, iBlockLength, iHopLength, f_s)
22
23 # number of results
24 iNumOfBlocks = x_b.shape[0]
25
26 # allocate memory
27 vacf = np.zeros(iNumOfBlocks)
28
29 for n, block in enumerate(x_b):
30 eta_min = np.floor(f_s / f_max).astype(int)
31
32 # calculate the acf if nonzero
33 if not block.sum():
34 continue
35 else:
36 afCorr = np.correlate(block, block, "full") / np.dot(block, block)
37
38 afCorr = afCorr[np.arange(iBlockLength, afCorr.size)]
39
40 # update eta_min to avoid main lobe
41 eta_tmp = np.argmax(afCorr < fMinThresh)
42 eta_min = np.max([eta_min, eta_tmp])
43
44 afDeltaCorr = np.diff(afCorr)
45 eta_tmp = np.argmax(afDeltaCorr > 0)
46 eta_min = np.max([eta_min, eta_tmp])
47
48 # find the coefficients specified in eta
49 vacf[n] = np.max(np.abs(afCorr[np.arange(eta_min + 1, afCorr.size)]))
50
51 return vacf, t