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

Functions

 FeatureTimePeakEnvelope (x, iBlockLength, iHopLength, f_s)
 computes the peak envelope of a time domain signal
 
 ppm (x, filterbuf, alpha)
 

Function Documentation

◆ FeatureTimePeakEnvelope()

FeatureTimePeakEnvelope ( x,
iBlockLength,
iHopLength,
f_s )

computes the peak envelope of a time domain 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
Returns
vppm: peak envelope (1: max, 2: PPM)
t: time stamp

Definition at line 16 of file FeatureTimePeakEnvelope.py.

16def FeatureTimePeakEnvelope(x, iBlockLength, iHopLength, f_s):
17
18 # create blocks
19 xBlocks, t = pyACA.ToolBlockAudio(x, iBlockLength, iHopLength, f_s)
20
21 # number of results
22 iNumOfBlocks = xBlocks.shape[0]
23
24 alpha = 1 - np.array([np.exp(-2.2 / (f_s * 0.01)), np.exp(-2.2 / (f_s * 1.5))])
25
26 # allocate memory
27 vppm = np.zeros([2, iNumOfBlocks])
28 v_tmp = np.zeros(iBlockLength)
29
30 for n, block in enumerate(xBlocks):
31 x_block = np.abs(block)
32
33 # detect the maximum per block
34 vppm[0, n] = np.max(x_block)
35
36 # calculate the PPM value - take into account block overlaps
37 # and discard concerns wrt efficiency
38 v_tmp = ppm(x_block, v_tmp[iHopLength - 1], alpha)
39 vppm[1, n] = np.max(v_tmp)
40
41 # convert to dB
42 epsilon = 1e-5 # -100dB
43
44 vppm[vppm < epsilon] = epsilon
45 vppm = 20 * np.log10(vppm)
46
47 return vppm, t
48
49
Here is the call graph for this function:

◆ ppm()

ppm ( x,
filterbuf,
alpha )

Definition at line 50 of file FeatureTimePeakEnvelope.py.

50def ppm(x, filterbuf, alpha):
51
52 # initialization
53 ppmout = np.zeros(x.shape[0])
54
55 alpha_AT = alpha[0]
56 alpha_RT = alpha[1]
57
58 for i in range(0, x.shape[0]):
59 if filterbuf > x[i]:
60 # release state
61 ppmout[i] = (1 - alpha_RT) * filterbuf
62 else:
63 # attack state
64 ppmout[i] = alpha_AT * x[i] + (1 - alpha_AT) * filterbuf
65
66 filterbuf = ppmout[i]
67
68 return ppmout
Here is the caller graph for this function: